UNPKG

@extra-array/fill-update

Version:
59 lines (43 loc) 1.47 kB
Fills with given value. [:package:](https://www.npmjs.com/package/@extra-array/fill-update) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/fill-update) [:vhs:](https://asciinema.org/a/332043) [:moon:](https://www.npmjs.com/package/@extra-array/fill-update.min) [:scroll:](https://unpkg.com/@extra-array/fill-update/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [fill], [fill$]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.fill$(x, v, [i], [I]); // x: an array (updated) // v: value // i: start index (0) // I: end index (X) // → x ``` ```javascript const array = require("extra-array"); var x = [1, 2, 3, 4]; array.fill$(x, 2); // [ 2, 2, 2, 2 ] x; // [ 2, 2, 2, 2 ] var x = [1, 2, 3, 4]; array.fill$(x, 2, 1); // [ 1, 2, 2, 2 ] var x = [1, 2, 3, 4]; array.fill$(x, 2, 1, 3); // [ 1, 2, 2, 4 ] ``` <br> <br> ## References - [Array.prototype.fill: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) - [_.fill: lodash](https://lodash.com/docs/4.17.15#fill) - [immutable-iterable-prototype: @azu](https://github.com/azu/immutable-iterable-prototype) [fill]: https://github.com/nodef/extra-array/wiki/fill [fill$]: https://github.com/nodef/extra-array/wiki/fill$