Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simplisticated/flexible
Smart arrays implemented in Swift
https://github.com/simplisticated/flexible
array array-filtering array-search ios nsarray swift xcode
Last synced: 1 day ago
JSON representation
Smart arrays implemented in Swift
- Host: GitHub
- URL: https://github.com/simplisticated/flexible
- Owner: simplisticated
- License: apache-2.0
- Created: 2018-08-01T18:46:34.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-31T21:08:44.000Z (over 6 years ago)
- Last Synced: 2025-02-01T18:22:52.224Z (10 days ago)
- Topics: array, array-filtering, array-search, ios, nsarray, swift, xcode
- Language: Swift
- Homepage:
- Size: 93.8 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
## At a Glance
`Flexible` is a tool that simplifies work with arrays in Swift.
## How To Get Started
- Copy content of `Source` folder to your project.
or
- Use `Flexible` cocoapod
## Requirements
* iOS 9 and later
* Xcode 9 and later
* Swift 4.1## Usage
Filtering array is much easier with `Flexible`:
```swift
let sourceArray = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
]let result = sourceArray.flx
.take(.last(count: 4)) // Take last 4 elements
.mapped { "value = \($0)" } // Map Int element to String value
.where { $0 < 8 } // Filter source elementsprint(result) // ["value = 4", "value = 5", "value = 6", "value = 7"]
```Take first 4 elements from array:
```swift
let result = sourceArray.flx
.take(.first(count: 4))
.noMapping()
.noFilter()print(result) // [1, 2, 3, 4]
```Retrieve array with elements multiplied by 2:
```swift
let result = sourceArray.flx
.take(.all)
.mapped { $0 * 2 }
.noFilter()print(result) // [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
```## License
`Flexible` is available under the Apache 2.0 license. See the [LICENSE](./LICENSE) file for more info.