Lightweight and context-free array operations
// ES6:
const { append, insert, remove, locate } = require('list')// ES5:
var append = require('list/append')Adds item to the end of list and returns list.
> append(['foo', 'bar'], 'baz')
['foo', 'bar', 'baz']Inserts item at index in list. The item in list located at index and all subsequent items are shifted by one index to accommodate item.
> insert(['foo', 'baz'], 1, 'bar')
['foo', 'bar', 'baz']To prepend to a list, insert at index 0.
> insert(['bar', 'baz'], 0, 'foo')
['foo', 'bar', 'baz']list is not modified if index is less than 0 or greater than or equal to list.length. Therefore, insert cannot be used to add items to the end of a list - use append instead.
Removes the item located at index from list. Returns the item if it exists, otherwise undefined.
> remove(['foo', 'bar', 'baz'], 1)
'bar'> remove(['foo', 'bar', 'baz'], 'qux')
undefinedFinds the first index where list[index] === item, or undefined if no item is found.
> locate(['foo', 'bar', 'baz'], 'baz')
2> locate(['foo', 'bar', 'baz'], 'qux')
undefinedsemibran/map- simple key-value maps
- leo - for donating the package name
