PullAllWithGlob - like _.pullAll but pulling stronger, with globs

§ Quick Take

import { strict as assert } from "assert";
import pullAllWithGlob 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
sourceArrayArrayyesSource array of 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 Sourcehut.

§ Licence

MIT opens in a new tab

Copyright © 2010–2020 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 2.13.0
Like _.includes but with wildcards
📦 array-of-arrays-sort-by-col 2.13.0
Sort array of arrays by column, rippling the sorting outwards from that column
📦 arrayiffy-if-string 3.12.0
Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else
📦 array-of-arrays-into-ast 1.10.1
Turns an array of arrays of data into a nested tree of plain objects
📦 array-group-str-omit-num-char 3.0.3
Groups array of strings by omitting number characters