Skip to content

Instantly share code, notes, and snippets.

@jurassix
Created April 5, 2016 15:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jurassix/6658fb564a6349afeae434e5907004c3 to your computer and use it in GitHub Desktop.
Save jurassix/6658fb564a6349afeae434e5907004c3 to your computer and use it in GitHub Desktop.
export const contains = (list = [], test) => list.indexOf(test) >= 0;
export const removeItemAt = (list = [], index = 0) =>
[
...list.slice(0, index),
...list.slice(index + 1),
];
export const insertItemAt = (list = [], index = 0, item) =>
[
...list.slice(0, index),
item,
...list.slice(index),
];
export const replaceItemAt = (list = [], index = 0, item) =>
[
...list.slice(0, index),
item,
...list.slice(index + 1),
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment