§ Quick Take

import { strict as assert } from "assert";
import { pull } from "array-pull-all-with-glob";


§ Purpose

This program removes strings from array if they match a glob pattern. It's like Lodash's _.pullAll opens in a new tab except with globby opens in a new tab on top.

For example, we use it in email-comb to whitelist CSS class/id names.



In other words, it's a function which takes three input arguments, third-one being optional (marked by square brackets).

§ API - Input

Input argumentTypeObligatory?Description
sourceArrayArray of zero or more stringsyesSource array of zero or more strings
removeTheseArray of zero or more strings or a stringyesArray of zero or more strings or a single string to be removed from the source array
otpsPlain objectnoAn Optional Options Object. See its API below.

By the way, none of the input arguments are mutated. That's checked by unit tests from group 4.x

§ An Optional Options Object

Type: object - an Optional Options Object.

options object's keyTypeDefaultDescription
caseSensitiveBooleantrueAre comparisons case-sensitive? Default answer is yes, but you can override it to no using this.

Here are all defaults in one place for copying:

caseSensitive: true,

When unused, Optional Options Object can be also passed as a null or undefined value.

§ API - Output

ArrayArray of strings with elements removed

§ Changelog

See it in the monorepo opens in a new tab, on GitHub.

§ Contributing

To report bugs or request features or assistance, raise an issue on GitHub opens in a new tab.

Any code contributions welcome! All Pull Requests will be dealt promptly.

§ Licence

MIT opens in a new tab

Copyright © 2010–2021 Roy Revelt and other contributors

Related packages:

📦 lodash.pullall opens in a new tab
The lodash method `_.pullAll` exported as a module
📦 globby opens in a new tab
User-friendly glob matching
📦 array-includes-with-glob 3.0.14
Like _.includes but with wildcards
📦 array-group-str-omit-num-char 4.0.14
Groups array of strings by omitting number characters
📦 array-of-arrays-into-ast 2.0.14
Turns an array of arrays of data into a nested tree of plain objects
📦 array-of-arrays-sort-by-col 3.0.14
Sort array of arrays by column, rippling the sorting outwards from that column
📦 arrayiffy-if-string 3.13.14
Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else