1.0.6 • Published 6 years ago

js-functional-helpers v1.0.6

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

js-functional-helpers

A growing library of functional javascript helpers.

To install:

npm install js-functional-helpers

Usage:

const helpers = require('js-functional-helpers');

A Few Examples

Working with arrays

Pop an element off of the end of an array (returns a new, non-mutated array):

helpers.array.immutablePop([1, 2, 3]);
// returns [1, 2]

Push an new array element (returns a new, non-mutated array):

helpers.array.immutablePushElement([1, 2, 3], 4);
// returns [1, 2, 3, 4]

Replace an array element at a given index (returns a new, non-mutated array):

helpers.array.immutableReplaceElement([1, 2, 3], 1, 'hello');
// returns [1, 'hello', 3]

Reverse an array (returns a new, non-mutated array):

helpers.array.immutableReverse([1, 2, 3]);
// returns [3, 2, 1]

Working with objects

Remove a key from an object (returns a new, non-mutated object):

helpers.object.immutableRemoveKey({ id: '1', age: 200}, 'age');
// returns { id: '1' }

Replace the value of a given key within an object (returns a new, non-mutated object):

helpers.object.immutableReplaceKeyValue({ id: '1', age: 200}, 'age', 700);
// returns { id: '1', age: 700 }
1.0.6

6 years ago

1.0.5

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