array-pull-all-with-glob4.13.0
PullAllWithGlob - like
_.pullAll
but pulling stronger, with globs§ Quick Take
import { strict as assert } from "assert";
import pullAllWithGlob from "array-pull-all-with-glob";
assert.deepEqual(
pullAllWithGlob(
[
"keep_me",
"name-1",
"name-2",
"name-jhkgdhgkhdfghdkghfdk",
],
["name-*"]
),
["keep_me"]
);
§ 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
pullAllWithGlob( sourceArray, removeThese, [opts] )
In other words, it's a function which takes three input arguments, third-one being optional (marked by square brackets).
§ API - Input
Input argument | Type | Obligatory? | Description |
---|---|---|---|
sourceArray | Array | yes | Source array of strings |
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 |
otps | Plain object | no | An 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 key | Type | Default | Description |
---|---|---|---|
caseSensitive | Boolean | true | Are 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
Type | Description |
---|---|
Array | Array of strings with elements removed |
§ Changelog
See it in the monorepo , on Sourcehut.
§ Licence
Copyright © 2010–2020 Roy Revelt and other contributors
Related packages:
📦 lodash.pullall
The lodash method `_.pullAll` exported as a module
📦 globby
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