@oscarpalmer/atoms 0.74.1 → 0.76.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/dist/js/array/chunk.cjs +18 -0
- package/dist/js/array/{chunk.mjs → chunk.js} +2 -2
- package/dist/js/array/compact.cjs +6 -0
- package/dist/js/array/{compact.mjs → compact.js} +0 -1
- package/dist/js/array/count.cjs +14 -0
- package/dist/js/array/count.js +14 -0
- package/dist/js/array/exists.cjs +14 -0
- package/dist/js/array/exists.js +14 -0
- package/dist/js/array/filter.cjs +14 -0
- package/dist/js/array/filter.js +14 -0
- package/dist/js/array/find.cjs +14 -0
- package/dist/js/array/find.js +14 -0
- package/dist/js/array/group-by.cjs +35 -0
- package/dist/js/array/group-by.js +35 -0
- package/dist/js/array/index-of.cjs +14 -0
- package/dist/js/array/index-of.js +14 -0
- package/dist/js/array/index.cjs +40 -0
- package/dist/js/array/index.js +34 -381
- package/dist/js/array/insert.cjs +31 -0
- package/dist/js/array/insert.js +31 -0
- package/dist/js/array/models.cjs +1 -0
- package/dist/js/array/models.js +1 -0
- package/dist/js/array/shuffle.cjs +13 -0
- package/dist/js/array/{shuffle.mjs → shuffle.js} +2 -3
- package/dist/js/array/sort.cjs +53 -0
- package/dist/js/array/{sort.mjs → sort.js} +13 -9
- package/dist/js/array/splice.cjs +14 -0
- package/dist/js/array/splice.js +14 -0
- package/dist/js/array/to-map.cjs +27 -0
- package/dist/js/array/to-map.js +27 -0
- package/dist/js/array/to-record.cjs +12 -0
- package/dist/js/array/to-record.js +12 -0
- package/dist/js/array/unique.cjs +7 -0
- package/dist/js/array/unique.js +7 -0
- package/dist/js/colour/base.cjs +18 -0
- package/dist/js/colour/{base.mjs → base.js} +4 -3
- package/dist/js/colour/functions.cjs +96 -0
- package/dist/js/colour/{functions.mjs → functions.js} +18 -19
- package/dist/js/colour/hex.cjs +56 -0
- package/dist/js/colour/{hex.mjs → hex.js} +34 -15
- package/dist/js/colour/hsl.cjs +85 -0
- package/dist/js/colour/{hsl.mjs → hsl.js} +40 -12
- package/dist/js/colour/index.cjs +29 -0
- package/dist/js/colour/index.js +14 -272
- package/dist/js/colour/is.cjs +27 -0
- package/dist/js/colour/{is.mjs → is.js} +7 -6
- package/dist/js/colour/rgb.cjs +87 -0
- package/dist/js/colour/{rgb.mjs → rgb.js} +43 -12
- package/dist/js/{emitter.mjs → emitter.cjs} +88 -56
- package/dist/js/emitter.js +85 -56
- package/dist/js/{function.mjs → function.cjs} +66 -46
- package/dist/js/function.js +61 -48
- package/dist/js/index.cjs +136 -0
- package/dist/js/index.js +133 -1724
- package/dist/js/internal/array/callbacks.cjs +23 -0
- package/dist/js/internal/array/callbacks.js +23 -0
- package/dist/js/internal/array/find.cjs +51 -0
- package/dist/js/internal/array/find.js +51 -0
- package/dist/js/internal/value/handle.cjs +21 -0
- package/dist/js/internal/{value-handle.mjs → value/handle.js} +0 -1
- package/dist/js/{is.mjs → is.cjs} +17 -18
- package/dist/js/is.js +15 -27
- package/dist/js/logger.cjs +108 -0
- package/dist/js/logger.js +44 -8
- package/dist/js/{math.mjs → math.cjs} +7 -8
- package/dist/js/math.js +4 -5
- package/dist/js/models.cjs +1 -0
- package/dist/js/models.js +1 -0
- package/dist/js/{number.mjs → number.cjs} +8 -8
- package/dist/js/number.js +5 -5
- package/dist/js/{query.mjs → query.cjs} +18 -18
- package/dist/js/query.js +17 -86
- package/dist/js/{queue.mjs → queue.cjs} +12 -13
- package/dist/js/queue.js +9 -10
- package/dist/js/{random.mjs → random.cjs} +14 -21
- package/dist/js/random.js +9 -26
- package/dist/js/{sized.mjs → sized.cjs} +68 -33
- package/dist/js/sized.js +66 -38
- package/dist/js/string/case.cjs +41 -0
- package/dist/js/string/{case.mjs → case.js} +13 -9
- package/dist/js/string/index.cjs +59 -0
- package/dist/js/string/index.js +30 -100
- package/dist/js/string/template.cjs +21 -0
- package/dist/js/string/{template.mjs → template.js} +4 -5
- package/dist/js/{touch.mjs → touch.cjs} +4 -7
- package/dist/js/touch.js +3 -5
- package/dist/js/value/clone.cjs +76 -0
- package/dist/js/value/{clone.mjs → clone.js} +5 -6
- package/dist/js/value/compare.cjs +59 -0
- package/dist/js/value/{compare.mjs → compare.js} +4 -6
- package/dist/js/value/diff.cjs +75 -0
- package/dist/js/value/{diff.mjs → diff.js} +13 -11
- package/dist/js/value/equal.cjs +106 -0
- package/dist/js/value/{equal.mjs → equal.js} +13 -8
- package/dist/js/value/get.cjs +21 -0
- package/dist/js/value/{get.mjs → get.js} +9 -4
- package/dist/js/value/index.cjs +30 -0
- package/dist/js/value/index.js +19 -510
- package/dist/js/value/merge.cjs +35 -0
- package/dist/js/value/{merge.mjs → merge.js} +7 -6
- package/dist/js/value/set.cjs +25 -0
- package/dist/js/value/{set.mjs → set.js} +3 -4
- package/dist/js/value/smush.cjs +26 -0
- package/dist/js/value/{smush.mjs → smush.js} +3 -4
- package/dist/js/value/unsmush.cjs +39 -0
- package/dist/js/value/{unsmush.mjs → unsmush.js} +10 -7
- package/package.json +50 -47
- package/src/js/array/chunk.ts +6 -5
- package/src/js/array/compact.ts +8 -10
- package/src/js/array/count.ts +39 -19
- package/src/js/array/exists.ts +39 -15
- package/src/js/array/filter.ts +42 -20
- package/src/js/array/find.ts +45 -20
- package/src/js/array/group-by.ts +158 -27
- package/src/js/array/index-of.ts +40 -18
- package/src/js/array/index.ts +10 -9
- package/src/js/array/insert.ts +28 -14
- package/src/js/array/models.ts +18 -15
- package/src/js/array/shuffle.ts +3 -3
- package/src/js/array/sort.ts +32 -34
- package/src/js/array/splice.ts +22 -26
- package/src/js/array/to-map.ts +133 -45
- package/src/js/array/to-record.ts +137 -39
- package/src/js/array/unique.ts +20 -15
- package/src/js/colour/base.ts +3 -3
- package/src/js/colour/functions.ts +4 -6
- package/src/js/colour/hex.ts +5 -5
- package/src/js/colour/hsl.ts +18 -12
- package/src/js/colour/index.ts +1 -1
- package/src/js/colour/is.ts +3 -3
- package/src/js/colour/rgb.ts +17 -11
- package/src/js/emitter.ts +12 -9
- package/src/js/function.ts +17 -17
- package/src/js/index.ts +16 -16
- package/src/js/internal/array/callbacks.ts +33 -0
- package/src/js/internal/{array-find.ts → array/find.ts} +23 -24
- package/src/js/internal/{value-handle.ts → value/handle.ts} +1 -1
- package/src/js/is.ts +2 -2
- package/src/js/logger.ts +14 -14
- package/src/js/math.ts +1 -1
- package/src/js/models.ts +5 -5
- package/src/js/number.ts +2 -2
- package/src/js/query.ts +6 -10
- package/src/js/queue.ts +1 -1
- package/src/js/random.ts +9 -19
- package/src/js/sized.ts +145 -145
- package/src/js/string/case.ts +1 -1
- package/src/js/string/index.ts +13 -7
- package/src/js/string/template.ts +6 -3
- package/src/js/value/clone.ts +3 -7
- package/src/js/value/compare.ts +3 -5
- package/src/js/value/diff.ts +4 -4
- package/src/js/value/equal.ts +2 -2
- package/src/js/value/get.ts +3 -3
- package/src/js/value/index.ts +2 -2
- package/src/js/value/merge.ts +3 -3
- package/src/js/value/set.ts +3 -4
- package/src/js/value/smush.ts +4 -4
- package/src/js/value/unsmush.ts +4 -4
- package/types/array/chunk.d.cts +8 -0
- package/types/array/chunk.d.ts +2 -2
- package/types/array/compact.d.cts +12 -0
- package/types/array/compact.d.ts +4 -4
- package/types/array/count.d.cts +24 -0
- package/types/array/count.d.ts +13 -7
- package/types/array/exists.d.cts +26 -0
- package/types/array/exists.d.ts +11 -3
- package/types/array/filter.d.cts +26 -0
- package/types/array/filter.d.ts +14 -6
- package/types/array/find.d.cts +26 -0
- package/types/array/find.d.ts +14 -6
- package/types/array/group-by.d.cts +58 -0
- package/types/array/group-by.d.ts +49 -5
- package/types/array/index-of.d.cts +26 -0
- package/types/array/index-of.d.ts +14 -6
- package/types/array/index.d.cts +239 -95
- package/types/array/index.d.ts +7 -6
- package/types/array/insert.d.cts +16 -0
- package/types/array/insert.d.ts +10 -5
- package/types/array/models.d.cts +14 -11
- package/types/array/models.d.ts +14 -12
- package/types/array/shuffle.d.cts +8 -0
- package/types/array/shuffle.d.ts +2 -2
- package/types/array/sort.d.cts +24 -0
- package/types/array/sort.d.ts +10 -10
- package/types/array/splice.d.cts +22 -0
- package/types/array/splice.d.ts +4 -4
- package/types/array/to-map.d.cts +61 -0
- package/types/array/to-map.d.ts +42 -20
- package/types/array/to-record.d.cts +61 -0
- package/types/array/to-record.d.ts +42 -20
- package/types/array/unique.d.cts +21 -0
- package/types/array/unique.d.ts +10 -6
- package/types/colour/base.d.cts +153 -0
- package/types/colour/base.d.ts +2 -2
- package/types/colour/functions.d.cts +173 -0
- package/types/colour/functions.d.ts +3 -3
- package/types/colour/hex.d.cts +157 -0
- package/types/colour/hex.d.ts +4 -4
- package/types/colour/hsl.d.cts +157 -0
- package/types/colour/hsl.d.ts +16 -10
- package/types/colour/index.d.cts +28 -16
- package/types/colour/index.d.ts +1 -1
- package/types/colour/is.d.cts +170 -0
- package/types/colour/is.d.ts +3 -3
- package/types/colour/rgb.d.cts +157 -0
- package/types/colour/rgb.d.ts +15 -9
- package/types/emitter.d.cts +11 -8
- package/types/emitter.d.ts +11 -8
- package/types/function.d.cts +10 -10
- package/types/function.d.ts +11 -11
- package/types/index.d.cts +1120 -736
- package/types/index.d.ts +16 -16
- package/types/internal/array/callbacks.d.cts +11 -0
- package/types/internal/array/callbacks.d.ts +2 -0
- package/types/internal/array/find.d.cts +7 -0
- package/types/internal/array/find.d.ts +3 -0
- package/types/internal/value/handle.d.cts +37 -0
- package/types/internal/{value-handle.d.ts → value/handle.d.ts} +1 -1
- package/types/is.d.ts +1 -1
- package/types/logger.d.cts +13 -21
- package/types/logger.d.ts +13 -21
- package/types/math.d.cts +1 -1
- package/types/math.d.ts +1 -1
- package/types/models.d.cts +4 -4
- package/types/models.d.ts +1 -4
- package/types/number.d.cts +2 -2
- package/types/number.d.ts +2 -2
- package/types/query.d.cts +2 -2
- package/types/query.d.ts +3 -3
- package/types/queue.d.cts +1 -1
- package/types/queue.d.ts +1 -1
- package/types/random.d.cts +8 -12
- package/types/random.d.ts +8 -12
- package/types/sized.d.cts +6 -6
- package/types/sized.d.ts +6 -6
- package/types/string/case.d.cts +28 -0
- package/types/string/index.d.cts +30 -27
- package/types/string/index.d.ts +3 -3
- package/types/string/template.d.cts +50 -0
- package/types/string/template.d.ts +4 -1
- package/types/value/clone.d.cts +8 -0
- package/types/value/clone.d.ts +4 -2
- package/types/value/compare.d.cts +8 -0
- package/types/value/diff.d.cts +25 -0
- package/types/value/equal.d.cts +12 -0
- package/types/value/get.d.cts +1319 -0
- package/types/value/get.d.ts +1 -1
- package/types/value/index.d.cts +8 -6
- package/types/value/index.d.ts +2 -2
- package/types/value/merge.d.cts +72 -0
- package/types/value/merge.d.ts +2 -2
- package/types/value/set.d.cts +1011 -0
- package/types/value/set.d.ts +1 -1
- package/types/value/smush.d.cts +1368 -0
- package/types/value/smush.d.ts +2 -2
- package/types/value/unsmush.d.cts +141 -0
- package/types/value/unsmush.d.ts +2 -2
- package/dist/js/array/count.mjs +0 -8
- package/dist/js/array/exists.mjs +0 -8
- package/dist/js/array/filter.mjs +0 -8
- package/dist/js/array/find.mjs +0 -8
- package/dist/js/array/group-by.mjs +0 -33
- package/dist/js/array/index-of.mjs +0 -8
- package/dist/js/array/index.mjs +0 -34
- package/dist/js/array/insert.mjs +0 -22
- package/dist/js/array/models.mjs +0 -0
- package/dist/js/array/splice.mjs +0 -9
- package/dist/js/array/to-map.mjs +0 -27
- package/dist/js/array/to-record.mjs +0 -8
- package/dist/js/array/unique.mjs +0 -8
- package/dist/js/colour/index.mjs +0 -30
- package/dist/js/index.mjs +0 -17
- package/dist/js/internal/array-callbacks.mjs +0 -19
- package/dist/js/internal/array-find.mjs +0 -51
- package/dist/js/logger.mjs +0 -69
- package/dist/js/models.mjs +0 -0
- package/dist/js/string/index.mjs +0 -44
- package/dist/js/value/index.mjs +0 -23
- package/src/js/internal/array-callbacks.ts +0 -28
- package/types/internal/array-callbacks.d.ts +0 -2
- package/types/internal/array-find.d.ts +0 -4
package/src/js/value/merge.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {isArrayOrPlainObject} from '
|
|
2
|
-
import type {ArrayOrPlainObject, PlainObject} from '
|
|
1
|
+
import {isArrayOrPlainObject} from '~/is';
|
|
2
|
+
import type {ArrayOrPlainObject, PlainObject} from '~/models';
|
|
3
3
|
|
|
4
4
|
type MergeOptions = {
|
|
5
5
|
/**
|
|
@@ -10,7 +10,7 @@ type MergeOptions = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Merge multiple arrays or objects into a single one
|
|
14
14
|
*/
|
|
15
15
|
export function merge<Model extends ArrayOrPlainObject>(
|
|
16
16
|
values: Model[],
|
package/src/js/value/set.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {handleValue} from '
|
|
2
|
-
import type {Paths, PlainObject} from '
|
|
1
|
+
import {handleValue} from '~/internal/value/handle';
|
|
2
|
+
import type {Paths, PlainObject} from '~/models';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* - Set the value in an object using a known path
|
|
@@ -38,8 +38,7 @@ export function setValue<Data extends PlainObject>(
|
|
|
38
38
|
const {length} = parts;
|
|
39
39
|
const lastIndex = length - 1;
|
|
40
40
|
|
|
41
|
-
let target: PlainObject =
|
|
42
|
-
typeof data === 'object' && data !== null ? data : {};
|
|
41
|
+
let target: PlainObject = data;
|
|
43
42
|
|
|
44
43
|
for (let index = 0; index < length; index += 1) {
|
|
45
44
|
const part = parts[index];
|
package/src/js/value/smush.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type {Get, Paths, Simplify} from 'type-fest';
|
|
2
2
|
import type {ToString} from 'type-fest/source/internal/string';
|
|
3
|
-
import {isArrayOrPlainObject} from '
|
|
4
|
-
import type {ArrayOrPlainObject, PlainObject} from '
|
|
5
|
-
import {join} from '
|
|
3
|
+
import {isArrayOrPlainObject} from '~/is';
|
|
4
|
+
import type {ArrayOrPlainObject, PlainObject} from '~/models';
|
|
5
|
+
import {join} from '~/string/index';
|
|
6
6
|
|
|
7
7
|
type Smushed<Value> = Simplify<{
|
|
8
8
|
[Key in Paths<Value>]: Get<Value, ToString<Key>>;
|
|
@@ -31,7 +31,7 @@ function flatten(value: ArrayOrPlainObject, prefix?: string): PlainObject {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Smush an object into a flat object that uses dot notation keys
|
|
35
35
|
*/
|
|
36
36
|
export function smush<Value extends PlainObject>(value: Value): Smushed<Value> {
|
|
37
37
|
return flatten(value) as never;
|
package/src/js/value/unsmush.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {KeysOfUnion, Simplify} from 'type-fest';
|
|
2
|
-
import {isArrayOrPlainObject} from '
|
|
3
|
-
import type {PlainObject} from '
|
|
4
|
-
import {setValue} from '
|
|
2
|
+
import {isArrayOrPlainObject} from '~/is';
|
|
3
|
+
import type {PlainObject} from '~/models';
|
|
4
|
+
import {setValue} from '~/value/set';
|
|
5
5
|
|
|
6
6
|
type Unsmushed<Value extends PlainObject> = Simplify<
|
|
7
7
|
Omit<
|
|
@@ -32,7 +32,7 @@ function getKeyGroups(value: PlainObject): string[][] {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Unsmush a smushed object _(turning dot notation keys into nested keys)_
|
|
36
36
|
*/
|
|
37
37
|
export function unsmush<Value extends PlainObject>(
|
|
38
38
|
value: Value,
|
package/types/array/chunk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Chunk an array _(into smaller arrays of a specified size)_
|
|
3
3
|
*/
|
|
4
|
-
export declare function chunk<
|
|
4
|
+
export declare function chunk<Item>(array: Item[], size?: number): Item[][];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Compact an array _(removing all `null` and `undefined` values)_
|
|
5
|
+
*/
|
|
6
|
+
export declare function compact<Item>(array: Item[]): Exclude<Item, null | undefined>[];
|
|
7
|
+
/**
|
|
8
|
+
* Compact an array _(removing all falsey values)_
|
|
9
|
+
*/
|
|
10
|
+
export declare function compact<Item>(array: Item[], strict: true): Exclude<Item, 0 | "" | false | null | undefined>[];
|
|
11
|
+
|
|
12
|
+
export {};
|
package/types/array/compact.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Compact an array _(removing all `null` and `undefined` values)_
|
|
3
3
|
*/
|
|
4
|
-
export declare function compact<
|
|
4
|
+
export declare function compact<Item>(array: Item[]): Exclude<Item, null | undefined>[];
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Compact an array _(removing all falsey values)_
|
|
7
7
|
*/
|
|
8
|
-
export declare function compact<
|
|
8
|
+
export declare function compact<Item>(array: Item[], strict: true): Exclude<Item, 0 | '' | false | null | undefined>[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export type Key = number | string;
|
|
4
|
+
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
5
|
+
export type BooleanCallback<Item> = ArrayCallback<Item, boolean>;
|
|
6
|
+
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
7
|
+
/**
|
|
8
|
+
* Get the number of items _(count)_ that match the given value
|
|
9
|
+
*/
|
|
10
|
+
export declare function count<Item>(array: Item[], value: Item): number;
|
|
11
|
+
/**
|
|
12
|
+
* Get the number of items _(count)_ that match the given value
|
|
13
|
+
*/
|
|
14
|
+
export declare function count<Item>(array: Item[], matches: BooleanCallback<Item>): number;
|
|
15
|
+
/**
|
|
16
|
+
* Get the number of items _(count)_ that match the given value
|
|
17
|
+
*/
|
|
18
|
+
export declare function count<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): number;
|
|
19
|
+
/**
|
|
20
|
+
* Get the number of items _(count)_ that match the given value
|
|
21
|
+
*/
|
|
22
|
+
export declare function count<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): number;
|
|
23
|
+
|
|
24
|
+
export {};
|
package/types/array/count.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BooleanCallback, KeyCallback } from './models';
|
|
1
|
+
import type { BooleanCallback, KeyCallback } from '~/array/models';
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* Get the number of items _(count)_ that match the given value
|
|
5
4
|
*/
|
|
6
|
-
export declare function count<
|
|
5
|
+
export declare function count<Item>(array: Item[], value: Item): number;
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
9
|
-
* - Use `key` to find a comparison value to match with `value`
|
|
7
|
+
* Get the number of items _(count)_ that match the given value
|
|
10
8
|
*/
|
|
11
|
-
export declare function count<
|
|
9
|
+
export declare function count<Item>(array: Item[], matches: BooleanCallback<Item>): number;
|
|
10
|
+
/**
|
|
11
|
+
* Get the number of items _(count)_ that match the given value
|
|
12
|
+
*/
|
|
13
|
+
export declare function count<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): number;
|
|
14
|
+
/**
|
|
15
|
+
* Get the number of items _(count)_ that match the given value
|
|
16
|
+
*/
|
|
17
|
+
export declare function count<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): number;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export type Key = number | string;
|
|
4
|
+
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
5
|
+
export type BooleanCallback<Item> = ArrayCallback<Item, boolean>;
|
|
6
|
+
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
7
|
+
/**
|
|
8
|
+
* Does the value exist in array?
|
|
9
|
+
*/
|
|
10
|
+
export declare function exists<Item>(array: Item[], value: Item): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Does the value exist in array?
|
|
13
|
+
*/
|
|
14
|
+
export declare function exists<Item>(array: Item[], matches: BooleanCallback<Item>): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* - Does the value exist in array?
|
|
17
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
18
|
+
*/
|
|
19
|
+
export declare function exists<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* - Does the value exist in array?
|
|
22
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
23
|
+
*/
|
|
24
|
+
export declare function exists<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): boolean;
|
|
25
|
+
|
|
26
|
+
export {};
|
package/types/array/exists.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import type { Key } from '../models';
|
|
2
1
|
import type { BooleanCallback, KeyCallback } from './models';
|
|
3
2
|
/**
|
|
4
3
|
* Does the value exist in array?
|
|
5
4
|
*/
|
|
6
|
-
export declare function exists<
|
|
5
|
+
export declare function exists<Item>(array: Item[], value: Item): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Does the value exist in array?
|
|
8
|
+
*/
|
|
9
|
+
export declare function exists<Item>(array: Item[], matches: BooleanCallback<Item>): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* - Does the value exist in array?
|
|
12
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
13
|
+
*/
|
|
14
|
+
export declare function exists<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): boolean;
|
|
7
15
|
/**
|
|
8
16
|
* - Does the value exist in array?
|
|
9
17
|
* - Use `key` to find a comparison value to match with `value`
|
|
10
18
|
*/
|
|
11
|
-
export declare function exists<
|
|
19
|
+
export declare function exists<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export type Key = number | string;
|
|
4
|
+
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
5
|
+
export type BooleanCallback<Item> = ArrayCallback<Item, boolean>;
|
|
6
|
+
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
7
|
+
/**
|
|
8
|
+
* Get a filtered array of items matching `value`
|
|
9
|
+
*/
|
|
10
|
+
export declare function filter<Item>(array: Item[], value: Item): Item[];
|
|
11
|
+
/**
|
|
12
|
+
* Get a filtered array of items matching `value`
|
|
13
|
+
*/
|
|
14
|
+
export declare function filter<Item>(array: Item[], matches: BooleanCallback<Item>): Item[];
|
|
15
|
+
/**
|
|
16
|
+
* - Get a filtered array of items
|
|
17
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
18
|
+
*/
|
|
19
|
+
export declare function filter<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item[];
|
|
20
|
+
/**
|
|
21
|
+
* - Get a filtered array of items
|
|
22
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
23
|
+
*/
|
|
24
|
+
export declare function filter<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): Item[];
|
|
25
|
+
|
|
26
|
+
export {};
|
package/types/array/filter.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BooleanCallback, KeyCallback } from './models';
|
|
1
|
+
import type { BooleanCallback, KeyCallback } from '~/array/models';
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* Get a filtered array of items matching `value`
|
|
5
4
|
*/
|
|
6
|
-
export declare function filter<
|
|
5
|
+
export declare function filter<Item>(array: Item[], value: Item): Item[];
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Get a filtered array of items matching `value`
|
|
8
|
+
*/
|
|
9
|
+
export declare function filter<Item>(array: Item[], matches: BooleanCallback<Item>): Item[];
|
|
10
|
+
/**
|
|
11
|
+
* - Get a filtered array of items
|
|
12
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
13
|
+
*/
|
|
14
|
+
export declare function filter<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item[];
|
|
15
|
+
/**
|
|
16
|
+
* - Get a filtered array of items
|
|
9
17
|
* - Use `key` to find a comparison value to match with `value`
|
|
10
18
|
*/
|
|
11
|
-
export declare function filter<
|
|
19
|
+
export declare function filter<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): Item[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export type Key = number | string;
|
|
4
|
+
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
5
|
+
export type BooleanCallback<Item> = ArrayCallback<Item, boolean>;
|
|
6
|
+
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
7
|
+
/**
|
|
8
|
+
* Get the first item matching `value` _(or `undefined` if no match is found)_
|
|
9
|
+
*/
|
|
10
|
+
export declare function find<Item>(array: Item[], value: Item): Item | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Get the first item matching `value` _(or `undefined` if no match is found)_
|
|
13
|
+
*/
|
|
14
|
+
export declare function find<Item>(array: Item[], matches: BooleanCallback<Item>): Item | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* - Get the first matching item _(or `undefined` if no match is found)_
|
|
17
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
18
|
+
*/
|
|
19
|
+
export declare function find<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* - Get the first matching item _(or `undefined` if no match is found)_
|
|
22
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
23
|
+
*/
|
|
24
|
+
export declare function find<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): Item | undefined;
|
|
25
|
+
|
|
26
|
+
export {};
|
package/types/array/find.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BooleanCallback, KeyCallback } from './models';
|
|
1
|
+
import type { BooleanCallback, KeyCallback } from '~/array/models';
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* Get the first item matching `value` _(or `undefined` if no match is found)_
|
|
5
4
|
*/
|
|
6
|
-
export declare function find<
|
|
5
|
+
export declare function find<Item>(array: Item[], value: Item): Item | undefined;
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Get the first item matching `value` _(or `undefined` if no match is found)_
|
|
8
|
+
*/
|
|
9
|
+
export declare function find<Item>(array: Item[], matches: BooleanCallback<Item>): Item | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* - Get the first matching item _(or `undefined` if no match is found)_
|
|
12
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
13
|
+
*/
|
|
14
|
+
export declare function find<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* - Get the first matching item _(or `undefined` if no match is found)_
|
|
9
17
|
* - Use `key` to find a comparison value to match with `value`
|
|
10
18
|
*/
|
|
11
|
-
export declare function find<
|
|
19
|
+
export declare function find<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): Item | undefined;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export type KeyedValue<Item, Key extends keyof Item> = Item[Key] extends PropertyKey ? Item[Key] : never;
|
|
4
|
+
export type Key = number | string;
|
|
5
|
+
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
6
|
+
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
7
|
+
export type ValueCallback<Item> = ArrayCallback<Item, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Create a record from an array of items using a specific key
|
|
10
|
+
*/
|
|
11
|
+
export declare function groupBy<Item, Key extends keyof Item>(array: Item[], key: Key): Record<KeyedValue<Item, Key>, Item>;
|
|
12
|
+
/**
|
|
13
|
+
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
14
|
+
*/
|
|
15
|
+
export declare function groupBy<Item, Key extends keyof Item>(array: Item[], key: Key, arrays: true): Record<KeyedValue<Item, Key>, Item[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Create a record from an array of items using a specific key
|
|
18
|
+
*/
|
|
19
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
|
|
20
|
+
/**
|
|
21
|
+
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
22
|
+
*/
|
|
23
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Create a record from an array of items using a specific key and value
|
|
26
|
+
*/
|
|
27
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, KeyedValue<Item, Value>>;
|
|
28
|
+
/**
|
|
29
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
30
|
+
*/
|
|
31
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<KeyedValue<Item, Value>>>;
|
|
32
|
+
/**
|
|
33
|
+
* Create a record from an array of items using a specific key and value
|
|
34
|
+
*/
|
|
35
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, ReturnType<Value>>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
38
|
+
*/
|
|
39
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
|
|
40
|
+
/**
|
|
41
|
+
* Create a record from an array of items using a specific key and value
|
|
42
|
+
*/
|
|
43
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, KeyedValue<Item, Value>>;
|
|
44
|
+
/**
|
|
45
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
46
|
+
*/
|
|
47
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
|
|
48
|
+
/**
|
|
49
|
+
* Create a record from an array of items using a specific key and value
|
|
50
|
+
*/
|
|
51
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, ReturnType<Value>>;
|
|
52
|
+
/**
|
|
53
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
54
|
+
*/
|
|
55
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<ReturnType<Value>>>;
|
|
56
|
+
export declare function groupValues(array: unknown[], key: unknown, value: unknown, arrays: boolean): Record<Key, unknown>;
|
|
57
|
+
|
|
58
|
+
export {};
|
|
@@ -1,7 +1,51 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { KeyCallback, ValueCallback } from '~/array/models';
|
|
2
|
+
import type { Key, KeyedValue } from '~/models';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Create a record from an array of items using a specific key
|
|
5
5
|
*/
|
|
6
|
-
export declare function groupBy<
|
|
7
|
-
|
|
6
|
+
export declare function groupBy<Item, Key extends keyof Item>(array: Item[], key: Key): Record<KeyedValue<Item, Key>, Item>;
|
|
7
|
+
/**
|
|
8
|
+
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
9
|
+
*/
|
|
10
|
+
export declare function groupBy<Item, Key extends keyof Item>(array: Item[], key: Key, arrays: true): Record<KeyedValue<Item, Key>, Item[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Create a record from an array of items using a specific key
|
|
13
|
+
*/
|
|
14
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
|
|
15
|
+
/**
|
|
16
|
+
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
17
|
+
*/
|
|
18
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Create a record from an array of items using a specific key and value
|
|
21
|
+
*/
|
|
22
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, KeyedValue<Item, Value>>;
|
|
23
|
+
/**
|
|
24
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
25
|
+
*/
|
|
26
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<KeyedValue<Item, Value>>>;
|
|
27
|
+
/**
|
|
28
|
+
* Create a record from an array of items using a specific key and value
|
|
29
|
+
*/
|
|
30
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, ReturnType<Value>>;
|
|
31
|
+
/**
|
|
32
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
33
|
+
*/
|
|
34
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
|
|
35
|
+
/**
|
|
36
|
+
* Create a record from an array of items using a specific key and value
|
|
37
|
+
*/
|
|
38
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, KeyedValue<Item, Value>>;
|
|
39
|
+
/**
|
|
40
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
41
|
+
*/
|
|
42
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
|
|
43
|
+
/**
|
|
44
|
+
* Create a record from an array of items using a specific key and value
|
|
45
|
+
*/
|
|
46
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, ReturnType<Value>>;
|
|
47
|
+
/**
|
|
48
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
49
|
+
*/
|
|
50
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<ReturnType<Value>>>;
|
|
51
|
+
export declare function groupValues(array: unknown[], key: unknown, value: unknown, arrays: boolean): Record<Key, unknown>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export type Key = number | string;
|
|
4
|
+
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
5
|
+
export type BooleanCallback<Item> = ArrayCallback<Item, boolean>;
|
|
6
|
+
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
7
|
+
/**
|
|
8
|
+
* Get the index for the first item matching `value` _(or `-1` if no match is found)_
|
|
9
|
+
*/
|
|
10
|
+
export declare function indexOf<Item>(array: Item[], value: Item): number;
|
|
11
|
+
/**
|
|
12
|
+
* Get the index for the first item matching `value` _(or `-1` if no match is found)_
|
|
13
|
+
*/
|
|
14
|
+
export declare function indexOf<Item>(array: Item[], matches: BooleanCallback<Item>): number;
|
|
15
|
+
/**
|
|
16
|
+
* - Get the index for the first matching item _(or `-1` if no match is found)_
|
|
17
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
18
|
+
*/
|
|
19
|
+
export declare function indexOf<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): number;
|
|
20
|
+
/**
|
|
21
|
+
* - Get the index for the first matching item _(or `-1` if no match is found)_
|
|
22
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
23
|
+
*/
|
|
24
|
+
export declare function indexOf<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): number;
|
|
25
|
+
|
|
26
|
+
export {};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BooleanCallback, KeyCallback } from './models';
|
|
1
|
+
import type { BooleanCallback, KeyCallback } from '~/array/models';
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* Get the index for the first item matching `value` _(or `-1` if no match is found)_
|
|
5
4
|
*/
|
|
6
|
-
export declare function indexOf<
|
|
5
|
+
export declare function indexOf<Item>(array: Item[], value: Item): number;
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Get the index for the first item matching `value` _(or `-1` if no match is found)_
|
|
8
|
+
*/
|
|
9
|
+
export declare function indexOf<Item>(array: Item[], matches: BooleanCallback<Item>): number;
|
|
10
|
+
/**
|
|
11
|
+
* - Get the index for the first matching item _(or `-1` if no match is found)_
|
|
12
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
13
|
+
*/
|
|
14
|
+
export declare function indexOf<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): number;
|
|
15
|
+
/**
|
|
16
|
+
* - Get the index for the first matching item _(or `-1` if no match is found)_
|
|
9
17
|
* - Use `key` to find a comparison value to match with `value`
|
|
10
18
|
*/
|
|
11
|
-
export declare function indexOf<
|
|
19
|
+
export declare function indexOf<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): number;
|