@bytebury/toolkit 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/build_message.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/internal/1.0.12 → esm/deps/jsr.io/@std/internal/1.0.13}/diff.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/internal/1.0.12 → esm/deps/jsr.io/@std/internal/1.0.13}/diff_str.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/internal/1.0.12 → esm/deps/jsr.io/@std/internal/1.0.13}/format.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/styles.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/types.d.ts.map +1 -1
- package/esm/src/core.d.ts +55 -10
- package/esm/src/core.d.ts.map +1 -1
- package/esm/src/core.js +87 -0
- package/package.json +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/build_message.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/internal/1.0.12 → script/deps/jsr.io/@std/internal/1.0.13}/diff.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/internal/1.0.12 → script/deps/jsr.io/@std/internal/1.0.13}/diff_str.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/internal/1.0.12 → script/deps/jsr.io/@std/internal/1.0.13}/format.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/styles.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/types.d.ts.map +1 -1
- package/script/src/core.d.ts +55 -10
- package/script/src/core.d.ts.map +1 -1
- package/script/src/core.js +89 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_message.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"build_message.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/build_message.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,QAAQ;AAClB;;;GAGG;AACH,UAAU,UAAQ,GACjB,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAWvB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CASrD;AAED,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC7C,OAAO,GAAE,mBAAwB,EACjC,YAAY,CAAC,EAAE,CACb,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC7C,UAAU,EAAE,OAAO,EACnB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,KAC1B,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,GACrC,MAAM,EAAE,CA8BV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/diff.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEvD,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B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/1.0.
|
|
1
|
+
{"version":3,"file":"diff_str.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/diff_str.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqB,UAAU,EAAE,MAAM,YAAY,CAAC;AAGhE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAY/C;AAKD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,UAAQ,GAAG,MAAM,EAAE,CAiBnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,EACxB,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,GAC3B,UAAU,CAAC,MAAM,CAAC,EAAE,CAetB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,CAkDlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/format.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,SAAS,GAAG,CACtB,CAAC,EAAE,OAAO,EACV,OAAO,EAAE;IACP,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,KACE,MAAM,CAAC;AAEZ;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAmBzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/styles.ts"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAWD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/types.ts"],"names":[],"mappings":"AAGA,kDAAkD;AAClD,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEvE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,IAAI,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC9B,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,KAAK,EAAE,CAAC,CAAC;IACT,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;CAC3B,CAAC"}
|
package/esm/src/core.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { NonEmptyList } from "./utility_types.js";
|
|
2
1
|
/**
|
|
3
2
|
* Clone an object using structuredClone.
|
|
4
3
|
*/
|
|
@@ -23,31 +22,33 @@ export declare function isEqual(thing1: unknown, thing2: unknown): boolean;
|
|
|
23
22
|
* is a string, then it will return the first character.
|
|
24
23
|
*
|
|
25
24
|
* @remarks
|
|
26
|
-
* If an empty list is passed then this will return undefined.
|
|
25
|
+
* If an empty list or string is passed then this will return undefined.
|
|
27
26
|
*
|
|
28
27
|
* @example
|
|
29
28
|
* ```ts
|
|
30
29
|
* first("hello"); // "h"
|
|
31
30
|
* first([1, 2, 3]); // 1
|
|
31
|
+
* first([]); // undefined
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
export declare function first
|
|
35
|
-
export declare function first(
|
|
34
|
+
export declare function first(value: string): string | undefined;
|
|
35
|
+
export declare function first<T>(list: T[]): T | undefined;
|
|
36
36
|
/**
|
|
37
37
|
* Returns the last thing in a list. If the value
|
|
38
38
|
* is a string, then it will return the last character.
|
|
39
39
|
*
|
|
40
40
|
* @remarks
|
|
41
|
-
* If an empty list is passed then this will return undefined.
|
|
41
|
+
* If an empty list or string is passed then this will return undefined.
|
|
42
42
|
*
|
|
43
43
|
* @example
|
|
44
44
|
* ```ts
|
|
45
45
|
* last("hello"); // "o"
|
|
46
46
|
* last([1, 2, 3]); // 3
|
|
47
|
+
* last([]); // undefined
|
|
47
48
|
* ```
|
|
48
49
|
*/
|
|
49
|
-
export declare function last
|
|
50
|
-
export declare function last(
|
|
50
|
+
export declare function last(value: string): string | undefined;
|
|
51
|
+
export declare function last<T>(list: T[]): T | undefined;
|
|
51
52
|
/**
|
|
52
53
|
* Compares two things by turning them into strings,
|
|
53
54
|
* and comparing them by their string value.
|
|
@@ -161,7 +162,6 @@ export declare function reverse<T>(thing: Set<T>): Set<T>;
|
|
|
161
162
|
* isEmpty(new Map()); // true
|
|
162
163
|
* ```
|
|
163
164
|
*/
|
|
164
|
-
export declare function isEmpty(thing: unknown[]): boolean;
|
|
165
165
|
export declare function isEmpty(thing: unknown): boolean;
|
|
166
166
|
/**
|
|
167
167
|
* Determines if the given thing is not empty.
|
|
@@ -179,7 +179,6 @@ export declare function isEmpty(thing: unknown): boolean;
|
|
|
179
179
|
* isNotEmpty(new Map()); // false
|
|
180
180
|
* ```
|
|
181
181
|
*/
|
|
182
|
-
export declare function isNotEmpty(thing: unknown[]): boolean;
|
|
183
182
|
export declare function isNotEmpty(thing: unknown): boolean;
|
|
184
183
|
/**
|
|
185
184
|
* Returns the distinct values from a list.
|
|
@@ -220,7 +219,7 @@ export declare function distinct<T>(list: T[]): T[];
|
|
|
220
219
|
* console.log(sample([])); // undefined
|
|
221
220
|
* ```
|
|
222
221
|
*/
|
|
223
|
-
export declare function sample<T>(list:
|
|
222
|
+
export declare function sample<T>(list: T[]): T | undefined;
|
|
224
223
|
/**
|
|
225
224
|
* Gives a random number in the given range. The first parameter is inclusive
|
|
226
225
|
* and the second one is exclusive. Therefore, it will work with lists out of
|
|
@@ -354,4 +353,50 @@ export declare function difference<T>(...lists: T[][]): T[];
|
|
|
354
353
|
* ```
|
|
355
354
|
*/
|
|
356
355
|
export declare function intersection<T>(...lists: T[][]): T[];
|
|
356
|
+
/**
|
|
357
|
+
* Determines if `searchIn` contains the given `searchFor` term(s).
|
|
358
|
+
*
|
|
359
|
+
* When `searchIn` is a string, this performs a substring check.
|
|
360
|
+
* When `searchIn` is a list, this performs an element check.
|
|
361
|
+
* When `searchFor` is a list, every item must be found.
|
|
362
|
+
*
|
|
363
|
+
* @remarks
|
|
364
|
+
* If `searchFor` is an empty list, this returns `true` (vacuously, since
|
|
365
|
+
* every item in an empty list is found).
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```ts
|
|
369
|
+
* includes("hello world", "hello"); // true
|
|
370
|
+
* includes("hello world", ["hello", "world"]); // true
|
|
371
|
+
* includes("hello world", ["hello", "moon"]); // false
|
|
372
|
+
* includes(["a", "b", "c"], "a"); // true
|
|
373
|
+
* includes(["a", "b", "c"], ["a", "b"]); // true
|
|
374
|
+
* includes(["a", "b", "c"], ["a", "d"]); // false
|
|
375
|
+
* includes("hello world", []); // true
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
export declare function includes(searchIn: string | string[], searchFor: string | string[]): boolean;
|
|
379
|
+
/**
|
|
380
|
+
* Determines if `searchIn` contains any of the given `searchFor` term(s).
|
|
381
|
+
*
|
|
382
|
+
* When `searchIn` is a string, this performs a substring check.
|
|
383
|
+
* When `searchIn` is a list, this performs an element check.
|
|
384
|
+
* When `searchFor` is a list, at least one item must be found.
|
|
385
|
+
*
|
|
386
|
+
* @remarks
|
|
387
|
+
* If `searchFor` is an empty list, this returns `false` (there is no term
|
|
388
|
+
* to match).
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```ts
|
|
392
|
+
* includesAny("hello world", "hello"); // true
|
|
393
|
+
* includesAny("hello world", ["hello", "moon"]); // true
|
|
394
|
+
* includesAny("hello world", ["sun", "moon"]); // false
|
|
395
|
+
* includesAny(["a", "b", "c"], "a"); // true
|
|
396
|
+
* includesAny(["a", "b", "c"], ["a", "d"]); // true
|
|
397
|
+
* includesAny(["a", "b", "c"], ["d", "e"]); // false
|
|
398
|
+
* includesAny("hello world", []); // false
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
export declare function includesAny(searchIn: string | string[], searchFor: string | string[]): boolean;
|
|
357
402
|
//# sourceMappingURL=core.d.ts.map
|
package/esm/src/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/src/core.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/src/core.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAElC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAEjE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AACzD,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;AAKnD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AACxD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E,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAQlD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAOpD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,EAC3B,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,GAC3B,OAAO,CAGT;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,EAC3B,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,GAC3B,OAAO,CAGT"}
|
package/esm/src/core.js
CHANGED
|
@@ -128,6 +128,25 @@ export function reverse(thing) {
|
|
|
128
128
|
return new Set([...thing].reverse());
|
|
129
129
|
return thing.reverse();
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Determines if the given thing is empty.
|
|
133
|
+
*
|
|
134
|
+
* Things are empty when:
|
|
135
|
+
* * They are `None`
|
|
136
|
+
* * They are empty strings
|
|
137
|
+
* * They have no length or size
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* isEmpty([]); // true
|
|
142
|
+
* isEmpty([0]); // false
|
|
143
|
+
* isEmpty(""); // true
|
|
144
|
+
* isEmpty(" "); // false
|
|
145
|
+
* isEmpty(new Set()); // true
|
|
146
|
+
* isEmpty({}); // true
|
|
147
|
+
* isEmpty(new Map()); // true
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
131
150
|
export function isEmpty(thing) {
|
|
132
151
|
if (isNone(thing))
|
|
133
152
|
return true;
|
|
@@ -141,6 +160,22 @@ export function isEmpty(thing) {
|
|
|
141
160
|
return Object.keys(thing).length === 0;
|
|
142
161
|
return false;
|
|
143
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Determines if the given thing is not empty.
|
|
165
|
+
*
|
|
166
|
+
* @remarks this is the inverse of `isEmpty`.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* isNotEmpty([]); // false
|
|
171
|
+
* isNotEmpty([0]); // true
|
|
172
|
+
* isNotEmpty(""); // false
|
|
173
|
+
* isNotEmpty(" "); // true
|
|
174
|
+
* isNotEmpty(new Set()); // false
|
|
175
|
+
* isNotEmpty({}); // false
|
|
176
|
+
* isNotEmpty(new Map()); // false
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
144
179
|
export function isNotEmpty(thing) {
|
|
145
180
|
return !isEmpty(thing);
|
|
146
181
|
}
|
|
@@ -365,3 +400,55 @@ export function intersection(...lists) {
|
|
|
365
400
|
return acc.filter((item) => currentSet.has(item));
|
|
366
401
|
});
|
|
367
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* Determines if `searchIn` contains the given `searchFor` term(s).
|
|
405
|
+
*
|
|
406
|
+
* When `searchIn` is a string, this performs a substring check.
|
|
407
|
+
* When `searchIn` is a list, this performs an element check.
|
|
408
|
+
* When `searchFor` is a list, every item must be found.
|
|
409
|
+
*
|
|
410
|
+
* @remarks
|
|
411
|
+
* If `searchFor` is an empty list, this returns `true` (vacuously, since
|
|
412
|
+
* every item in an empty list is found).
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* ```ts
|
|
416
|
+
* includes("hello world", "hello"); // true
|
|
417
|
+
* includes("hello world", ["hello", "world"]); // true
|
|
418
|
+
* includes("hello world", ["hello", "moon"]); // false
|
|
419
|
+
* includes(["a", "b", "c"], "a"); // true
|
|
420
|
+
* includes(["a", "b", "c"], ["a", "b"]); // true
|
|
421
|
+
* includes(["a", "b", "c"], ["a", "d"]); // false
|
|
422
|
+
* includes("hello world", []); // true
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
export function includes(searchIn, searchFor) {
|
|
426
|
+
const terms = Array.isArray(searchFor) ? searchFor : [searchFor];
|
|
427
|
+
return terms.every((term) => searchIn.includes(term));
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Determines if `searchIn` contains any of the given `searchFor` term(s).
|
|
431
|
+
*
|
|
432
|
+
* When `searchIn` is a string, this performs a substring check.
|
|
433
|
+
* When `searchIn` is a list, this performs an element check.
|
|
434
|
+
* When `searchFor` is a list, at least one item must be found.
|
|
435
|
+
*
|
|
436
|
+
* @remarks
|
|
437
|
+
* If `searchFor` is an empty list, this returns `false` (there is no term
|
|
438
|
+
* to match).
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```ts
|
|
442
|
+
* includesAny("hello world", "hello"); // true
|
|
443
|
+
* includesAny("hello world", ["hello", "moon"]); // true
|
|
444
|
+
* includesAny("hello world", ["sun", "moon"]); // false
|
|
445
|
+
* includesAny(["a", "b", "c"], "a"); // true
|
|
446
|
+
* includesAny(["a", "b", "c"], ["a", "d"]); // true
|
|
447
|
+
* includesAny(["a", "b", "c"], ["d", "e"]); // false
|
|
448
|
+
* includesAny("hello world", []); // false
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
export function includesAny(searchIn, searchFor) {
|
|
452
|
+
const terms = Array.isArray(searchFor) ? searchFor : [searchFor];
|
|
453
|
+
return terms.some((term) => searchIn.includes(term));
|
|
454
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebury/toolkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "TypeScript utility library to help energize your projects with useful functions for any size project. Save yourself some time and focus on shipping features.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_message.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"build_message.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/build_message.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,QAAQ;AAClB;;;GAGG;AACH,UAAU,UAAQ,GACjB,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAWvB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CASrD;AAED,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC7C,OAAO,GAAE,mBAAwB,EACjC,YAAY,CAAC,EAAE,CACb,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC7C,UAAU,EAAE,OAAO,EACnB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,KAC1B,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,GACrC,MAAM,EAAE,CA8BV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/diff.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEvD,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACr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
|
+
{"version":3,"file":"diff_str.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/diff_str.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqB,UAAU,EAAE,MAAM,YAAY,CAAC;AAGhE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAY/C;AAKD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,UAAQ,GAAG,MAAM,EAAE,CAiBnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,EACxB,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,GAC3B,UAAU,CAAC,MAAM,CAAC,EAAE,CAetB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,CAkDlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/format.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,SAAS,GAAG,CACtB,CAAC,EAAE,OAAO,EACV,OAAO,EAAE;IACP,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,KACE,MAAM,CAAC;AAEZ;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAmBzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/styles.ts"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAWD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/types.ts"],"names":[],"mappings":"AAGA,kDAAkD;AAClD,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEvE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,IAAI,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC9B,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,KAAK,EAAE,CAAC,CAAC;IACT,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;CAC3B,CAAC"}
|
package/script/src/core.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { NonEmptyList } from "./utility_types.js";
|
|
2
1
|
/**
|
|
3
2
|
* Clone an object using structuredClone.
|
|
4
3
|
*/
|
|
@@ -23,31 +22,33 @@ export declare function isEqual(thing1: unknown, thing2: unknown): boolean;
|
|
|
23
22
|
* is a string, then it will return the first character.
|
|
24
23
|
*
|
|
25
24
|
* @remarks
|
|
26
|
-
* If an empty list is passed then this will return undefined.
|
|
25
|
+
* If an empty list or string is passed then this will return undefined.
|
|
27
26
|
*
|
|
28
27
|
* @example
|
|
29
28
|
* ```ts
|
|
30
29
|
* first("hello"); // "h"
|
|
31
30
|
* first([1, 2, 3]); // 1
|
|
31
|
+
* first([]); // undefined
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
export declare function first
|
|
35
|
-
export declare function first(
|
|
34
|
+
export declare function first(value: string): string | undefined;
|
|
35
|
+
export declare function first<T>(list: T[]): T | undefined;
|
|
36
36
|
/**
|
|
37
37
|
* Returns the last thing in a list. If the value
|
|
38
38
|
* is a string, then it will return the last character.
|
|
39
39
|
*
|
|
40
40
|
* @remarks
|
|
41
|
-
* If an empty list is passed then this will return undefined.
|
|
41
|
+
* If an empty list or string is passed then this will return undefined.
|
|
42
42
|
*
|
|
43
43
|
* @example
|
|
44
44
|
* ```ts
|
|
45
45
|
* last("hello"); // "o"
|
|
46
46
|
* last([1, 2, 3]); // 3
|
|
47
|
+
* last([]); // undefined
|
|
47
48
|
* ```
|
|
48
49
|
*/
|
|
49
|
-
export declare function last
|
|
50
|
-
export declare function last(
|
|
50
|
+
export declare function last(value: string): string | undefined;
|
|
51
|
+
export declare function last<T>(list: T[]): T | undefined;
|
|
51
52
|
/**
|
|
52
53
|
* Compares two things by turning them into strings,
|
|
53
54
|
* and comparing them by their string value.
|
|
@@ -161,7 +162,6 @@ export declare function reverse<T>(thing: Set<T>): Set<T>;
|
|
|
161
162
|
* isEmpty(new Map()); // true
|
|
162
163
|
* ```
|
|
163
164
|
*/
|
|
164
|
-
export declare function isEmpty(thing: unknown[]): boolean;
|
|
165
165
|
export declare function isEmpty(thing: unknown): boolean;
|
|
166
166
|
/**
|
|
167
167
|
* Determines if the given thing is not empty.
|
|
@@ -179,7 +179,6 @@ export declare function isEmpty(thing: unknown): boolean;
|
|
|
179
179
|
* isNotEmpty(new Map()); // false
|
|
180
180
|
* ```
|
|
181
181
|
*/
|
|
182
|
-
export declare function isNotEmpty(thing: unknown[]): boolean;
|
|
183
182
|
export declare function isNotEmpty(thing: unknown): boolean;
|
|
184
183
|
/**
|
|
185
184
|
* Returns the distinct values from a list.
|
|
@@ -220,7 +219,7 @@ export declare function distinct<T>(list: T[]): T[];
|
|
|
220
219
|
* console.log(sample([])); // undefined
|
|
221
220
|
* ```
|
|
222
221
|
*/
|
|
223
|
-
export declare function sample<T>(list:
|
|
222
|
+
export declare function sample<T>(list: T[]): T | undefined;
|
|
224
223
|
/**
|
|
225
224
|
* Gives a random number in the given range. The first parameter is inclusive
|
|
226
225
|
* and the second one is exclusive. Therefore, it will work with lists out of
|
|
@@ -354,4 +353,50 @@ export declare function difference<T>(...lists: T[][]): T[];
|
|
|
354
353
|
* ```
|
|
355
354
|
*/
|
|
356
355
|
export declare function intersection<T>(...lists: T[][]): T[];
|
|
356
|
+
/**
|
|
357
|
+
* Determines if `searchIn` contains the given `searchFor` term(s).
|
|
358
|
+
*
|
|
359
|
+
* When `searchIn` is a string, this performs a substring check.
|
|
360
|
+
* When `searchIn` is a list, this performs an element check.
|
|
361
|
+
* When `searchFor` is a list, every item must be found.
|
|
362
|
+
*
|
|
363
|
+
* @remarks
|
|
364
|
+
* If `searchFor` is an empty list, this returns `true` (vacuously, since
|
|
365
|
+
* every item in an empty list is found).
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```ts
|
|
369
|
+
* includes("hello world", "hello"); // true
|
|
370
|
+
* includes("hello world", ["hello", "world"]); // true
|
|
371
|
+
* includes("hello world", ["hello", "moon"]); // false
|
|
372
|
+
* includes(["a", "b", "c"], "a"); // true
|
|
373
|
+
* includes(["a", "b", "c"], ["a", "b"]); // true
|
|
374
|
+
* includes(["a", "b", "c"], ["a", "d"]); // false
|
|
375
|
+
* includes("hello world", []); // true
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
export declare function includes(searchIn: string | string[], searchFor: string | string[]): boolean;
|
|
379
|
+
/**
|
|
380
|
+
* Determines if `searchIn` contains any of the given `searchFor` term(s).
|
|
381
|
+
*
|
|
382
|
+
* When `searchIn` is a string, this performs a substring check.
|
|
383
|
+
* When `searchIn` is a list, this performs an element check.
|
|
384
|
+
* When `searchFor` is a list, at least one item must be found.
|
|
385
|
+
*
|
|
386
|
+
* @remarks
|
|
387
|
+
* If `searchFor` is an empty list, this returns `false` (there is no term
|
|
388
|
+
* to match).
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```ts
|
|
392
|
+
* includesAny("hello world", "hello"); // true
|
|
393
|
+
* includesAny("hello world", ["hello", "moon"]); // true
|
|
394
|
+
* includesAny("hello world", ["sun", "moon"]); // false
|
|
395
|
+
* includesAny(["a", "b", "c"], "a"); // true
|
|
396
|
+
* includesAny(["a", "b", "c"], ["a", "d"]); // true
|
|
397
|
+
* includesAny(["a", "b", "c"], ["d", "e"]); // false
|
|
398
|
+
* includesAny("hello world", []); // false
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
export declare function includesAny(searchIn: string | string[], searchFor: string | string[]): boolean;
|
|
357
402
|
//# sourceMappingURL=core.d.ts.map
|
package/script/src/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/src/core.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/src/core.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAElC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAEjE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AACzD,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;AAKnD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AACxD,wBAAgB,IAAI,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AAE,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAQlD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAOpD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,EAC3B,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,GAC3B,OAAO,CAGT;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,EAC3B,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,GAC3B,OAAO,CAGT"}
|
package/script/src/core.js
CHANGED
|
@@ -27,6 +27,8 @@ exports.chunk = chunk;
|
|
|
27
27
|
exports.union = union;
|
|
28
28
|
exports.difference = difference;
|
|
29
29
|
exports.intersection = intersection;
|
|
30
|
+
exports.includes = includes;
|
|
31
|
+
exports.includesAny = includesAny;
|
|
30
32
|
const strings_js_1 = require("./strings.js");
|
|
31
33
|
/**
|
|
32
34
|
* Clone an object using structuredClone.
|
|
@@ -157,6 +159,25 @@ function reverse(thing) {
|
|
|
157
159
|
return new Set([...thing].reverse());
|
|
158
160
|
return thing.reverse();
|
|
159
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Determines if the given thing is empty.
|
|
164
|
+
*
|
|
165
|
+
* Things are empty when:
|
|
166
|
+
* * They are `None`
|
|
167
|
+
* * They are empty strings
|
|
168
|
+
* * They have no length or size
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* isEmpty([]); // true
|
|
173
|
+
* isEmpty([0]); // false
|
|
174
|
+
* isEmpty(""); // true
|
|
175
|
+
* isEmpty(" "); // false
|
|
176
|
+
* isEmpty(new Set()); // true
|
|
177
|
+
* isEmpty({}); // true
|
|
178
|
+
* isEmpty(new Map()); // true
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
160
181
|
function isEmpty(thing) {
|
|
161
182
|
if (isNone(thing))
|
|
162
183
|
return true;
|
|
@@ -170,6 +191,22 @@ function isEmpty(thing) {
|
|
|
170
191
|
return Object.keys(thing).length === 0;
|
|
171
192
|
return false;
|
|
172
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Determines if the given thing is not empty.
|
|
196
|
+
*
|
|
197
|
+
* @remarks this is the inverse of `isEmpty`.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* isNotEmpty([]); // false
|
|
202
|
+
* isNotEmpty([0]); // true
|
|
203
|
+
* isNotEmpty(""); // false
|
|
204
|
+
* isNotEmpty(" "); // true
|
|
205
|
+
* isNotEmpty(new Set()); // false
|
|
206
|
+
* isNotEmpty({}); // false
|
|
207
|
+
* isNotEmpty(new Map()); // false
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
173
210
|
function isNotEmpty(thing) {
|
|
174
211
|
return !isEmpty(thing);
|
|
175
212
|
}
|
|
@@ -394,3 +431,55 @@ function intersection(...lists) {
|
|
|
394
431
|
return acc.filter((item) => currentSet.has(item));
|
|
395
432
|
});
|
|
396
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Determines if `searchIn` contains the given `searchFor` term(s).
|
|
436
|
+
*
|
|
437
|
+
* When `searchIn` is a string, this performs a substring check.
|
|
438
|
+
* When `searchIn` is a list, this performs an element check.
|
|
439
|
+
* When `searchFor` is a list, every item must be found.
|
|
440
|
+
*
|
|
441
|
+
* @remarks
|
|
442
|
+
* If `searchFor` is an empty list, this returns `true` (vacuously, since
|
|
443
|
+
* every item in an empty list is found).
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```ts
|
|
447
|
+
* includes("hello world", "hello"); // true
|
|
448
|
+
* includes("hello world", ["hello", "world"]); // true
|
|
449
|
+
* includes("hello world", ["hello", "moon"]); // false
|
|
450
|
+
* includes(["a", "b", "c"], "a"); // true
|
|
451
|
+
* includes(["a", "b", "c"], ["a", "b"]); // true
|
|
452
|
+
* includes(["a", "b", "c"], ["a", "d"]); // false
|
|
453
|
+
* includes("hello world", []); // true
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
function includes(searchIn, searchFor) {
|
|
457
|
+
const terms = Array.isArray(searchFor) ? searchFor : [searchFor];
|
|
458
|
+
return terms.every((term) => searchIn.includes(term));
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Determines if `searchIn` contains any of the given `searchFor` term(s).
|
|
462
|
+
*
|
|
463
|
+
* When `searchIn` is a string, this performs a substring check.
|
|
464
|
+
* When `searchIn` is a list, this performs an element check.
|
|
465
|
+
* When `searchFor` is a list, at least one item must be found.
|
|
466
|
+
*
|
|
467
|
+
* @remarks
|
|
468
|
+
* If `searchFor` is an empty list, this returns `false` (there is no term
|
|
469
|
+
* to match).
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* ```ts
|
|
473
|
+
* includesAny("hello world", "hello"); // true
|
|
474
|
+
* includesAny("hello world", ["hello", "moon"]); // true
|
|
475
|
+
* includesAny("hello world", ["sun", "moon"]); // false
|
|
476
|
+
* includesAny(["a", "b", "c"], "a"); // true
|
|
477
|
+
* includesAny(["a", "b", "c"], ["a", "d"]); // true
|
|
478
|
+
* includesAny(["a", "b", "c"], ["d", "e"]); // false
|
|
479
|
+
* includesAny("hello world", []); // false
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
function includesAny(searchIn, searchFor) {
|
|
483
|
+
const terms = Array.isArray(searchFor) ? searchFor : [searchFor];
|
|
484
|
+
return terms.some((term) => searchIn.includes(term));
|
|
485
|
+
}
|