5.1.3 • Published 6 years ago

@lbzg/array-help v5.1.3

Weekly downloads
1
License
ISC
Repository
bitbucket
Last release
6 years ago

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 array

add(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 array

has(value) - accepts value or array of values, true if has all
length()

References

@lbzg/validate
lodash.clonedeep
lodash.isequal

5.1.3

6 years ago

5.1.2

6 years ago

5.1.1

6 years ago

5.1.0

6 years ago

5.0.2

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.0.5

6 years ago

4.0.4

6 years ago

4.0.3

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.1.4

6 years ago

3.1.3

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.0

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.14

6 years ago

2.0.13

6 years ago

2.0.12

6 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago