2.0.5 • Published 4 years ago

golden-array-utils v2.0.5

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

Golden Array Utils

Immutable Array Utility Functions

I found myself repeating logic repeatedly when working with immutable or stateful data. To save some time I have compiled some useful array functionality into an importable package... with tests!

The purpose of this package is that it will never modify the original array.

Installation

Just run npm install golden-array-utils and you're good to go!

Usage

To use the array utils in your project simply import the Array Utils (Au) object

import Au from 'golden-array-utils'

And use one of it's functions

this.setState({ todos: Au.remove(this.state.todos, clickedIndex) })

or to improve tree shaking import a specific part of the package

import operations from 'golden-array-utils/operations'
import addManyAt from 'golden-array-utils/operations/addManyAt'

Functions

Every function returns a new array with the function applied. The original array will never be altered.

NameFunction
.clone()Returns a brand new version of the exact same array.
.move()Moves an element of the array from one index to another
.remove()Removes an array element at index
.replace()Replaces the element at index with value
.add()Push value on to the end of the array
.addAt()Add value at a specific index
.addManyAt()Add all values starting at index
2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago