Immutable Array.prototype.fill()
.
Install with npm:
npm install @immutable-array/fill
Same API with Array.prototype.fill()
.
/**
* Returns the this object after filling the section identified by start and end with value
* @param array base array
* @param value value to fill array section with
* @param start index to start filling the array at. If start is negative, it is treated as
* length+start where length is the length of the array.
* @param end index to stop filling the array at. If end is negative, it is treated as
* length+end.
*/
export declare function fill<T>(array: Array<T>, value: T, start?: number, end?: number): Array<T>;
import { fill } from "@immutable-array/fill"
const originalArray = [1, 2, 3];
assert.deepStrictEqual(fill(originalArray, "x"), ["x", "x", "x"]);
assert.deepStrictEqual(fill(originalArray, "x", 1, 2), [1, "x", 3]);
See Releases page.
Install devDependencies and Run npm test
:
npm i -d && npm 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