1.1.1 • Published 8 years ago

remove-array-item v1.1.1

Weekly downloads
15
License
MIT
Repository
github
Last release
8 years ago

remove-array-item

Build Status Build Status David

A simple utility to (recursively) remove specified item(s) from an array.

Install

npm i remove-array-item --save

Usage

removeArrayItem(arr, item)

The module simply exports a function; the first argument is the current array, the next is the item that should be removed from all arrays/nested arrays.

It uses a "naive" indexOf implementation, and so does not do any deep equality checks on objects or the like.

Examples

import removeArrayItem from 'remove-array-item';

const arr = removeArrayItem(['red', 'green', ['red', 'blue']], 'red');

// arr will be ['green', ['blue']]

Aditionally, note that additional arguments can be passed (in sequence), and so multiple items can be removed in one statement, a la the following example:

const arr = removeArrayItem(['red', 'green', ['blue']], 'red', 'green');

// arr will be [['blue']]
1.1.1

8 years ago

1.1.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago