Immutable Array prototype methods.
- TypeScript
- Small and Thin
- Per method packages
@immutable-array/push
ECMAScript Array
has some mutable methods.
This library provide immutable version of each methods.
Native method: Retrun type | Library |
---|---|
Array.prototype.copyWithin() : Array |
copyWithin() : new Array |
Array.prototype.fill() : Array |
fill() : new Array |
Array.prototype.pop() : any |
pop() : new Array |
Array.prototype.push() : Number |
push() : new Array |
Array.prototype.splice() : Array |
splice() : new Array |
Array.prototype.reverse() : Array |
reverse() : new Array |
Array.prototype.shift() : any |
shift() : new Array |
Array.prototype.sort() : Array |
sort() : new Array |
Array.prototype.unshift() : any |
unshift() : new Array |
Install with npm:
npm install @immutable-array/prototype
import { push } from "@immutable-array/prototype"
const array = [0, 1, 2];
push(array, 3); // => [0, 1, 2, 3]
console.log(array); // => [0, 1, 2]
- Provide immutable version of
Array.prototype
method - Provide each method as an module
- e.g.)
import push from "@immutable-array/push"
- All prototype method:
import { push } from "@immutable-array/prototype"
- e.g.)
- Add non-standard method in ECMAScript
- e.g.)
update
,delete
,merge
...
- e.g.)
- Each method depended on other method
- Pure javascript immutable arrays
- georapbox/immutable-arrays: Immutable versions of normally mutable array methods
- micnews/immutable-array-methods
- kolodny/immutability-helper: mutate a copy of data without changing the original source
See Releases page.
Install devDependencies and Run yarn test
:
yarn test
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT © azu