Installation
Quick Take
Purpose
This program removes strings from array if they match a glob pattern. It’s like Lodash’s _.pullAll
except with globby
on top.
For example, we use it in email-comb to whitelist CSS class
/id
names.
API — pull()
The main function pull()
is imported like this:
It is a function which takes three input arguments: 1. a source from which to remove, 2. what to remove and 3. an optional options object:
Input argument | Type | Obligatory | Description |
---|---|---|---|
sourceArray Type: Array of zero or more strings Obligatory: yes | |||
sourceArray | Array of zero or more strings | yes | Source array of zero or more strings |
removeThese Type: Array of zero or more strings or a string Obligatory: yes | |||
removeThese | Array of zero or more strings or a string | yes | Array of zero or more strings or a single string to be removed from the source array |
opts Type: Plain object Obligatory: no | |||
opts | Plain object | no | An Optional Options Object. See its API below. |
None of the input arguments will be mutated by this program, we have unit tests to prove that.
The optional options object has the following shape:
Key | Type | Default | Description |
---|---|---|---|
caseSensitive Type: Boolean Default: true | |||
caseSensitive | Boolean | true | Are comparisons case-sensitive? Default answer is “yes”, but you can override it. |
Here are all defaults in one place for copying:
The function returns an array with requested elements removed.
API — defaults
You can import defaults
:
It's a plain object:
The main function calculates the options to be used by merging the options you passed with these defaults.
API — version
You can import version
: