Immutable versions of normally mutable array methods, such as pop(), push(), splice()
Download node at nodejs.org and install it, if you haven't already.
npm install immutable-array-methods --save
var methods = require("immutable-array-methods");
var input = [1, 2, 3];
var result = methods.pop(input, 4);
console.log('pop()');
console.log('input is unchanged', input);
console.log('result', result);
result = methods.splice(input, 1, 1, 'foo');
console.log('splice()');
console.log('input is unchanged', input);
console.log('result', result);
// num() doesnt' return a new array if the values are unchanged
result = methods.map(input, function (num) {
return num % 2;
});
result = methods.move([1, 2, 3], 0, 1);
console.log('move()');
console.log('input is unchanged', input);
console.log('result', result);
// also available is .push(), .shift(), .unshift(), .set()
npm install
npm test
None
- ava: Futuristic test runner 🚀
- babel-cli: Babel command line.
- babel-core: Babel compiler core.
- babel-preset-es2015: Babel preset for all es2015 plugins.
- package-json-to-readme: Generate a README.md from package.json contents
MIT
Generated by package-json-to-readme