@lbzg/array-help v5.1.3
Js (immutable) array helper.
w/ type declarations
Installation & Usage
npm i @lbzg/array-help
const Arr = require('@lbzg/array-help').Arr
# import { Arr } from '@lbzg/array-help'
const origin1 = [1, 2, 2, 3]
const origin2 = [1, 2, 2, 3]
const method1 = Arr(origin1).immutable().remove([1, 2])
const method2 = Arr(origin2).add([4, 1])
Arr(origin2).add(5)
Arr(origin2).removeFilter(x => x === 1 || x === 2)
console.log(origin1) # [1, 2, 2, 3]
console.log(origin2) # [3, 4, 5]
console.log(method1) # [3]
console.log(method2) # [3, 4, 5]
Info
Arr(inputArr).method
Methods return modified array.
Input array is modified unless immutable() is used.
Added values are cloned if cloneValue or immutableDeep.
Methods
immutable() - chain before modifier function, copies array
immutableDeep() - chain before modifier function, deep copies arrayadd(value, cloneValue?) - accepts value or array of values
addUnique(value, cloneValue?) - accepts value or array of values
get(value, cloneValue?) - accepts value or array of values, returns matched values
remove(value) - accepts value or array of values, removes values
removeFilter(cb)
filter(cb)
find(cb) - returns x instead of usual x
map(cb)
replace(value, newValue, cloneValue?)
flush() - empties arrayhas(value) - accepts value or array of values, true if has all
length()
References
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago