swifty-array-helpers 2.0.5
Install from the command line:
Learn more about npm packages
$ npm install @henrik-dmg/swifty-array-helpers@2.0.5
Install via package.json:
"@henrik-dmg/swifty-array-helpers": "2.0.5"
About this version
A collection of functions for working with arrays inspired by the methods that are available in Swift
You need to import the methods first. Example:
// ES6 module
import '@henrik-dmg/swifty-array-helpers'
// node.js
require('@henrik-dmg/swifty-array-helpers')
Finds the index of the first element matching the predicate. Example:
const array = [5, 3, 7, 12]
const index = firstIndex(array, x => x <= 4) // 1
Finds the first element matching the predicate (similar to firstIndex
).
Example:
const array = [5, 3, 7, 12]
const firstElementMatchingPredicate = firstWhere(array, x => x <= 4) // 3
Maps all values, filtering null
or undefined
values out
Example:
const array = [
{ name: 'Henrik' },
{ name: 'Henrik', lastName: 'Panhans' },
{ name: 'Henrik' },
{ name: 'Henrik' }
]
const lastNames = compactMap(array, value => value.lastName) // ["Panhans"]
Details
- swifty-array-helpers
- henrik-dmg
- almost 2 years ago
- MIT
- 13 dependencies
Assets
- swifty-array-helpers-2.0.5.tgz
Download activity
- Total downloads 0
- Last 30 days 0
- Last week 0
- Today 0