UNPKG

@extra-array/remove-path-update

Version:

Removes value at path in a nested array.

63 lines (47 loc) 1.92 kB
Removes value at path in a nested array. [:package:](https://www.npmjs.com/package/@extra-array/remove-path-update) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/remove-path-update) [:vhs:](https://asciinema.org/a/343815) [:moon:](https://www.npmjs.com/package/@extra-array/remove-path-update.min) [:scroll:](https://unpkg.com/@extra-array/remove-path-update/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [remove], [remove$], [removePath$].<br> > Similar: [hasPath], [getPath], [setPath$], [removePath$].<br> > Similar: [get], [set], [remove]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.removePath$(x, p); // x: a nested array (updated) // p: path // → x ``` ```javascript const array = require("extra-array"); var x = [[2, 4], 6, 8]; array.removePath$(x, [1], 60); // [ [ 2, 4 ], 8 ] x; // [ [ 2, 4 ], 8 ] array.removePath$(x, [0, 1], 40); // [ [ 2 ], 8 ] array.removePath$(x, [0, 1, 2], 100); // [ [ 2 ], 8 ] (path not present, no effect) ``` <br> <br> ## References - [ArrayList.get: Java](https://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html#get(int)) - [_.nth: lodash](https://lodash.com/docs/4.17.15#nth) - [Array.at: sugarjs](https://sugarjs.com/docs/#/Array/at) [remove]: https://github.com/nodef/extra-array/wiki/remove [remove$]: https://github.com/nodef/extra-array/wiki/remove$ [removePath$]: https://github.com/nodef/extra-array/wiki/removePath$ [hasPath]: https://github.com/nodef/extra-array/wiki/hasPath [getPath]: https://github.com/nodef/extra-array/wiki/getPath [setPath$]: https://github.com/nodef/extra-array/wiki/setPath$ [get]: https://github.com/nodef/extra-array/wiki/get [set]: https://github.com/nodef/extra-array/wiki/set