Skip to content

suguru03/immutable-array-prototype

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

immutable-array-prototype

Immutable Array prototype methods.

  • TypeScript
  • Small and Thin
  • Per method packages
    • @immutable-array/push

Why?

ECMAScript Array has some mutable methods. This library provide immutable version of each methods.

Mutable method on Array.prototype

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

Install with npm:

npm install @immutable-array/prototype

Usage

import { push } from "@immutable-array/prototype"
const array = [0, 1, 2];
push(array, 3); // => [0, 1, 2, 3]
console.log(array); // => [0, 1, 2]

Support Policy

Do

  • 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"

Do not

  • Add non-standard method in ECMAScript
    • e.g.) update, delete, merge...
  • Each method depended on other method

Related

Changelog

See Releases page.

Running tests

Install devDependencies and Run yarn test:

yarn test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

About

[WIP] Immutable Array prototype methods.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%