@valkyriestudios/utils 11.0.0 → 11.2.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/array/dedupe.d.ts +8 -0
- package/array/is.d.ts +8 -0
- package/array/isNotEmpty.d.ts +8 -0
- package/array/join.d.ts +36 -0
- package/array/mapFn.d.ts +40 -0
- package/array/mapKey.d.ts +38 -0
- package/array/mapPrimitive.d.ts +40 -0
- package/array/shuffle.d.ts +9 -0
- package/array/sort.d.ts +58 -0
- package/boolean/is.d.ts +8 -0
- package/caching/memoize.d.ts +10 -0
- package/date/addUTC.d.ts +10 -0
- package/date/diff.d.ts +10 -0
- package/{dist/date → date}/endOfUTC.d.ts +8 -0
- package/date/is.d.ts +8 -0
- package/date/nowUnix.d.ts +6 -0
- package/date/nowUnixMs.d.ts +6 -0
- package/{dist/date → date}/startOfUTC.d.ts +8 -0
- package/date/toUTC.d.ts +8 -0
- package/date/toUnix.d.ts +8 -0
- package/{dist/deep → deep}/freeze.d.ts +7 -0
- package/deep/get.d.ts +27 -0
- package/{dist/deep → deep}/seal.d.ts +7 -0
- package/deep/set.d.ts +42 -0
- package/equal.d.ts +10 -0
- package/function/is.d.ts +8 -0
- package/function/noop.d.ts +6 -0
- package/function/noopresolve.d.ts +9 -0
- package/function/noopreturn.d.ts +8 -0
- package/function/sleep.d.ts +9 -0
- package/hash/fnv1A.d.ts +10 -0
- package/hash/guid.d.ts +6 -0
- package/index.d.ts +358 -0
- package/number/is.d.ts +8 -0
- package/number/isAbove.d.ts +9 -0
- package/number/isAboveOrEqual.d.ts +9 -0
- package/number/isBelow.d.ts +9 -0
- package/number/isBelowOrEqual.d.ts +10 -0
- package/number/isBetween.d.ts +12 -0
- package/number/isInteger.d.ts +8 -0
- package/number/isIntegerAbove.d.ts +9 -0
- package/number/isIntegerAboveOrEqual.d.ts +10 -0
- package/number/isIntegerBelow.d.ts +9 -0
- package/number/isIntegerBelowOrEqual.d.ts +10 -0
- package/number/isIntegerBetween.d.ts +12 -0
- package/number/isNumericalNaN.d.ts +8 -0
- package/number/randomBetween.d.ts +9 -0
- package/number/randomIntBetween.d.ts +10 -0
- package/number/round.d.ts +9 -0
- package/number/toPercentage.d.ts +11 -0
- package/object/define.d.ts +15 -0
- package/object/is.d.ts +8 -0
- package/object/isNotEmpty.d.ts +8 -0
- package/object/merge.d.ts +18 -0
- package/object/pick.d.ts +13 -0
- package/package.json +1 -305
- package/regexp/is.d.ts +8 -0
- package/regexp/sanitize.d.ts +11 -0
- package/string/humanizeBytes.d.ts +40 -0
- package/string/humanizeNumber.d.ts +52 -0
- package/string/is.d.ts +8 -0
- package/string/isBetween.d.ts +13 -0
- package/string/isNotEmpty.d.ts +9 -0
- package/string/shorten.d.ts +10 -0
- package/dist/array/dedupe.d.ts +0 -1
- package/dist/array/is.d.ts +0 -1
- package/dist/array/isNotEmpty.d.ts +0 -1
- package/dist/array/join.d.ts +0 -8
- package/dist/array/mapFn.d.ts +0 -14
- package/dist/array/mapKey.d.ts +0 -12
- package/dist/array/mapPrimitive.d.ts +0 -10
- package/dist/array/shuffle.d.ts +0 -1
- package/dist/array/sort.d.ts +0 -11
- package/dist/boolean/is.d.ts +0 -1
- package/dist/caching/memoize.d.ts +0 -1
- package/dist/date/addUTC.d.ts +0 -1
- package/dist/date/diff.d.ts +0 -1
- package/dist/date/is.d.ts +0 -1
- package/dist/date/nowUnix.d.ts +0 -1
- package/dist/date/nowUnixMs.d.ts +0 -1
- package/dist/date/toUTC.d.ts +0 -1
- package/dist/date/toUnix.d.ts +0 -1
- package/dist/deep/get.d.ts +0 -5
- package/dist/deep/set.d.ts +0 -5
- package/dist/equal.d.ts +0 -2
- package/dist/function/is.d.ts +0 -1
- package/dist/function/noop.d.ts +0 -1
- package/dist/function/noopresolve.d.ts +0 -1
- package/dist/function/noopreturn.d.ts +0 -1
- package/dist/function/sleep.d.ts +0 -1
- package/dist/hash/fnv1A.d.ts +0 -1
- package/dist/hash/guid.d.ts +0 -1
- package/dist/number/is.d.ts +0 -1
- package/dist/number/isAbove.d.ts +0 -1
- package/dist/number/isAboveOrEqual.d.ts +0 -1
- package/dist/number/isBelow.d.ts +0 -1
- package/dist/number/isBelowOrEqual.d.ts +0 -1
- package/dist/number/isBetween.d.ts +0 -1
- package/dist/number/isInteger.d.ts +0 -1
- package/dist/number/isIntegerAbove.d.ts +0 -1
- package/dist/number/isIntegerAboveOrEqual.d.ts +0 -1
- package/dist/number/isIntegerBelow.d.ts +0 -1
- package/dist/number/isIntegerBelowOrEqual.d.ts +0 -1
- package/dist/number/isIntegerBetween.d.ts +0 -1
- package/dist/number/isNumericalNaN.d.ts +0 -1
- package/dist/number/randomBetween.d.ts +0 -1
- package/dist/number/randomIntBetween.d.ts +0 -1
- package/dist/number/round.d.ts +0 -1
- package/dist/number/toPercentage.d.ts +0 -1
- package/dist/object/define.d.ts +0 -7
- package/dist/object/is.d.ts +0 -1
- package/dist/object/isNotEmpty.d.ts +0 -1
- package/dist/object/merge.d.ts +0 -8
- package/dist/object/pick.d.ts +0 -5
- package/dist/regexp/is.d.ts +0 -1
- package/dist/regexp/sanitize.d.ts +0 -1
- package/dist/string/humanizeBytes.d.ts +0 -8
- package/dist/string/humanizeNumber.d.ts +0 -10
- package/dist/string/is.d.ts +0 -1
- package/dist/string/isBetween.d.ts +0 -1
- package/dist/string/isNotEmpty.d.ts +0 -1
- package/dist/string/shorten.d.ts +0 -1
- /package/{dist/array → array}/dedupe.js +0 -0
- /package/{dist/array → array}/is.js +0 -0
- /package/{dist/array → array}/isNotEmpty.js +0 -0
- /package/{dist/array → array}/join.js +0 -0
- /package/{dist/array → array}/mapFn.js +0 -0
- /package/{dist/array → array}/mapKey.js +0 -0
- /package/{dist/array → array}/mapPrimitive.js +0 -0
- /package/{dist/array → array}/shuffle.js +0 -0
- /package/{dist/array → array}/sort.js +0 -0
- /package/{dist/boolean → boolean}/is.js +0 -0
- /package/{dist/caching → caching}/memoize.js +0 -0
- /package/{dist/date → date}/addUTC.js +0 -0
- /package/{dist/date → date}/diff.js +0 -0
- /package/{dist/date → date}/endOfUTC.js +0 -0
- /package/{dist/date → date}/is.js +0 -0
- /package/{dist/date → date}/nowUnix.js +0 -0
- /package/{dist/date → date}/nowUnixMs.js +0 -0
- /package/{dist/date → date}/startOfUTC.js +0 -0
- /package/{dist/date → date}/toUTC.js +0 -0
- /package/{dist/date → date}/toUnix.js +0 -0
- /package/{dist/deep → deep}/freeze.js +0 -0
- /package/{dist/deep → deep}/get.js +0 -0
- /package/{dist/deep → deep}/seal.js +0 -0
- /package/{dist/deep → deep}/set.js +0 -0
- /package/{dist/equal.js → equal.js} +0 -0
- /package/{dist/function → function}/is.js +0 -0
- /package/{dist/function → function}/noop.js +0 -0
- /package/{dist/function → function}/noopresolve.js +0 -0
- /package/{dist/function → function}/noopreturn.js +0 -0
- /package/{dist/function → function}/sleep.js +0 -0
- /package/{dist/hash → hash}/fnv1A.js +0 -0
- /package/{dist/hash → hash}/guid.js +0 -0
- /package/{dist/is.d.ts → is.d.ts} +0 -0
- /package/{dist/is.js → is.js} +0 -0
- /package/{dist/number → number}/is.js +0 -0
- /package/{dist/number → number}/isAbove.js +0 -0
- /package/{dist/number → number}/isAboveOrEqual.js +0 -0
- /package/{dist/number → number}/isBelow.js +0 -0
- /package/{dist/number → number}/isBelowOrEqual.js +0 -0
- /package/{dist/number → number}/isBetween.js +0 -0
- /package/{dist/number → number}/isInteger.js +0 -0
- /package/{dist/number → number}/isIntegerAbove.js +0 -0
- /package/{dist/number → number}/isIntegerAboveOrEqual.js +0 -0
- /package/{dist/number → number}/isIntegerBelow.js +0 -0
- /package/{dist/number → number}/isIntegerBelowOrEqual.js +0 -0
- /package/{dist/number → number}/isIntegerBetween.js +0 -0
- /package/{dist/number → number}/isNumericalNaN.js +0 -0
- /package/{dist/number → number}/randomBetween.js +0 -0
- /package/{dist/number → number}/randomIntBetween.js +0 -0
- /package/{dist/number → number}/round.js +0 -0
- /package/{dist/number → number}/toPercentage.js +0 -0
- /package/{dist/object → object}/define.js +0 -0
- /package/{dist/object → object}/is.js +0 -0
- /package/{dist/object → object}/isNotEmpty.js +0 -0
- /package/{dist/object → object}/merge.js +0 -0
- /package/{dist/object → object}/pick.js +0 -0
- /package/{dist/regexp → regexp}/is.js +0 -0
- /package/{dist/regexp → regexp}/sanitize.js +0 -0
- /package/{dist/string → string}/humanizeBytes.js +0 -0
- /package/{dist/string → string}/humanizeNumber.js +0 -0
- /package/{dist/string → string}/is.js +0 -0
- /package/{dist/string → string}/isBetween.js +0 -0
- /package/{dist/string → string}/isNotEmpty.js +0 -0
- /package/{dist/string → string}/shorten.js +0 -0
package/array/is.d.ts
ADDED
package/array/join.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
interface joinOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Delimiter to join with
|
|
4
|
+
* (default=' ')
|
|
5
|
+
* eg: join(['hello', 'world', {delim: '_'}]) -> 'hello_world'
|
|
6
|
+
*/
|
|
7
|
+
delim?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Trim after joining or not
|
|
10
|
+
* (default=true)
|
|
11
|
+
* eg: join([' hello', 'world '], {trim: true}) -> 'hello world'
|
|
12
|
+
*/
|
|
13
|
+
trim?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Automatically trim all string values
|
|
16
|
+
* (default=true)
|
|
17
|
+
* eg: join([' hello ', ' world '], {valtrim: true}) -> 'hello world'
|
|
18
|
+
*/
|
|
19
|
+
valtrim?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Automatically round all numeric values
|
|
22
|
+
* (default=false)
|
|
23
|
+
* eg: join([5.432, 'world', 1.2], {valround: 1}) -> '5.4 world 1.2'
|
|
24
|
+
*/
|
|
25
|
+
valround?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Join an array of values while autofiltering any non-string/non-number elements
|
|
29
|
+
*
|
|
30
|
+
* @param val - Array of values to join
|
|
31
|
+
* @param opts - Join options
|
|
32
|
+
*
|
|
33
|
+
* @returns Joined array as string
|
|
34
|
+
*/
|
|
35
|
+
export default function join(val: any[], opts?: joinOptions): string;
|
|
36
|
+
export {};
|
package/array/mapFn.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
interface mapOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Allow merging existing keys or not, if not keys will be overriden if they exist
|
|
4
|
+
* (default=false)
|
|
5
|
+
*
|
|
6
|
+
* Example:
|
|
7
|
+
* mapFn([{uid: 12, a: 'hi'}, {uid: 12, b: 'ho'}], el => el.uid, {merge: true})
|
|
8
|
+
* Output:
|
|
9
|
+
* {12: {uid: 12, a: 'hi', b: 'ho'}}
|
|
10
|
+
* Output if merge is false
|
|
11
|
+
* {12: {uid: 12, b: 'ho'}}
|
|
12
|
+
*/
|
|
13
|
+
merge?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface kvMap {
|
|
16
|
+
[key: string]: {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Map an object array into a kv-object through a function that generates a key. Returning a non-string,
|
|
22
|
+
* non-numeric value from the function (eg: false) will filter out the object.
|
|
23
|
+
*
|
|
24
|
+
* Example:
|
|
25
|
+
* mapFn([{uid: 12, name: 'Peter'}, {uid: 15, name: 'Jonas'}], el => el.uid);
|
|
26
|
+
* Output:
|
|
27
|
+
* {12: {uid: 12, name: 'Peter'}, 15: {uid: 15, name: 'Jonas'}}
|
|
28
|
+
*
|
|
29
|
+
* @param val - Array to map
|
|
30
|
+
* @param fn - Handler function which is run for each of the objects and should return a string or number
|
|
31
|
+
* @param opts - Options object to override built-in defaults
|
|
32
|
+
*
|
|
33
|
+
* @returns KV-Map object
|
|
34
|
+
*/
|
|
35
|
+
export default function mapFn(arr: {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
}[], fn: (entry: {
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}) => (string | number | boolean), opts?: mapOptions): kvMap;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface mapOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Allow merging existing keys or not, if not keys will be overriden if they exist
|
|
4
|
+
* (default=false)
|
|
5
|
+
*
|
|
6
|
+
* Example:
|
|
7
|
+
* mapKey([{uid: 12, a: 'hi'}, {uid: 12, b: 'ho'}], 'uid', {merge: true})
|
|
8
|
+
* Output:
|
|
9
|
+
* {12: {uid: 12, a: 'hi', b: 'ho'}}
|
|
10
|
+
* Output if merge is false
|
|
11
|
+
* {12: {uid: 12, b: 'ho'}}
|
|
12
|
+
*/
|
|
13
|
+
merge?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface kvMap {
|
|
16
|
+
[key: string]: {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Map an object array into a kv-object by passing a common key that exists on the objects. Objects for
|
|
22
|
+
* which the key doesn't exist will be filtered out automatically
|
|
23
|
+
*
|
|
24
|
+
* Example:
|
|
25
|
+
* mapKey([{uid: 12, name: 'Peter'}, {uid: 15, name: 'Jonas'}], 'uid');
|
|
26
|
+
* Output:
|
|
27
|
+
* {12: {uid: 12, name: 'Peter'}, 15: {uid: 15, name: 'Jonas'}}
|
|
28
|
+
*
|
|
29
|
+
* @param val - Array to map
|
|
30
|
+
* @param key - Key to map by
|
|
31
|
+
* @param opts - Options object to override built-in defaults
|
|
32
|
+
*
|
|
33
|
+
* @returns KV-Map object
|
|
34
|
+
*/
|
|
35
|
+
export default function mapKey(arr: {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
}[], key: string, opts?: mapOptions): kvMap;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
interface mapOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Automatically trim all string values
|
|
4
|
+
* (default=false)
|
|
5
|
+
* eg: join([' hello ', ' world '], {valtrim: true}) -> 'hello world'
|
|
6
|
+
*/
|
|
7
|
+
valtrim?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Automatically round all numeric values
|
|
10
|
+
* (default=false)
|
|
11
|
+
* eg: mapPrimitive([5.432, 5.4, 5.43, 4.2, 4.1], {valround: true}) -> {'5.432': 5, '5.4': 5, '5.43': 5, '4.2': 4, '4.1': 4}
|
|
12
|
+
* eg: mapPrimitive([5.432, 5.43, 4.21, 4.1], {valround: 1}) -> {'5.432': 5.4, '5.43': 5.4, '4.21': 4.2, '4.1': 4.1}
|
|
13
|
+
*/
|
|
14
|
+
valround?: boolean | number;
|
|
15
|
+
/**
|
|
16
|
+
* Automaticaly round all keys from numeric values
|
|
17
|
+
* (default=false)
|
|
18
|
+
* eg: mapPrimitive([5.432, 5.4, 5.43, 4.2, 4.1], {keyround: true}) -> {5: 5.43, 4: 4.1}
|
|
19
|
+
*/
|
|
20
|
+
keyround?: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface mapReturn {
|
|
23
|
+
[key: string]: string | number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Map an array of primitive values (numbers/strings) into a kv-object
|
|
27
|
+
* non-numeric and non-string values will be filtered out
|
|
28
|
+
*
|
|
29
|
+
* Example:
|
|
30
|
+
* mapPrimitive(['hello', 'hello', 'foo', 'bar']);
|
|
31
|
+
* Output:
|
|
32
|
+
* {hello: 'hello', foo: 'foo', bar: 'bar'}
|
|
33
|
+
*
|
|
34
|
+
* @param val - Array to map
|
|
35
|
+
* @param opts - Options object to override built-in defaults
|
|
36
|
+
*
|
|
37
|
+
* @returns KV-Map object
|
|
38
|
+
*/
|
|
39
|
+
export default function mapPrimitive(arr: any[], opts?: mapOptions): mapReturn;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shuffle an array using a Fisher-Yates shuffle O(n)
|
|
3
|
+
* https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
|
|
4
|
+
*
|
|
5
|
+
* Take Note: The passed array will be changed and edited in place
|
|
6
|
+
*
|
|
7
|
+
* @param val - Array to shuffle
|
|
8
|
+
*/
|
|
9
|
+
export default function shuffle(arr: any[]): void;
|
package/array/sort.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
interface sortOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Filter function to apply to the array before sorting
|
|
4
|
+
* (default=isNotEmptyObject)
|
|
5
|
+
*/
|
|
6
|
+
filter_fn?: (el: any) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Remove objects that don't have the key or where the key is falsy
|
|
9
|
+
* (default=false)
|
|
10
|
+
*/
|
|
11
|
+
nokey_hide?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Move invalid values (eg: non-objects or objects that don't match the key/function passed) to the end of the sorted array
|
|
14
|
+
* (default=true)
|
|
15
|
+
*/
|
|
16
|
+
nokey_atend?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface sortObject {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
21
|
+
type sortByFunction = (el: sortObject) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Sort an array of objects, uses an implementation of Tony Hoare's quicksort
|
|
24
|
+
* (https://cs.stanford.edu/people/eroberts/courses/soco/projects/2008-09/tony-hoare/quicksort.html)
|
|
25
|
+
*
|
|
26
|
+
* Example:
|
|
27
|
+
* sort([
|
|
28
|
+
* {test: 'Peter'},
|
|
29
|
+
* {test: 'Jack'},
|
|
30
|
+
* {test: 'Pony'},
|
|
31
|
+
* {test: 'John'},
|
|
32
|
+
* {test: 'Joe'},
|
|
33
|
+
* {test: 'Bob'},
|
|
34
|
+
* {test: 'Alice'},
|
|
35
|
+
* ], 'test', 'desc');
|
|
36
|
+
* Output:
|
|
37
|
+
* [{test: 'Pony'}, {test: 'Peter'}, {test: 'John'}, {test: 'Joe'}, {test: 'Jack'}, {test: 'Bob'}, {test: 'Alice'}]
|
|
38
|
+
*
|
|
39
|
+
* Example w/ Function:
|
|
40
|
+
* sort([
|
|
41
|
+
* {test: 'Peter'},
|
|
42
|
+
* {test: 'Pony'},
|
|
43
|
+
* {test: 'JOHn'},
|
|
44
|
+
* {test: 'Joe'},
|
|
45
|
+
* ], el => el.test.toLowerCase(), 'desc');
|
|
46
|
+
* Output:
|
|
47
|
+
* [{test: 'Pony'}, {test: 'Peter'}, {test: 'JOHn'}, {test: 'Joe'}]
|
|
48
|
+
*
|
|
49
|
+
* @param val - Array to sort
|
|
50
|
+
* @param by - Either a string (key) or a function
|
|
51
|
+
* @param dir - (default='asc') Direction to sort in (asc or desc)
|
|
52
|
+
* @param opts - Sort options
|
|
53
|
+
*
|
|
54
|
+
* @returns Sorted array
|
|
55
|
+
* @throws {Error}
|
|
56
|
+
*/
|
|
57
|
+
export default function sort(arr: sortObject[], by: string | sortByFunction, dir?: 'asc' | 'desc', opts?: sortOptions): sortObject[];
|
|
58
|
+
export {};
|
package/boolean/is.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn a function into a memoized function. An optional resolver function can be passed which allows custom cache key generation.
|
|
3
|
+
*
|
|
4
|
+
* Example:
|
|
5
|
+
* const memoized_function = memoize((a) => fnv1A(a));
|
|
6
|
+
*
|
|
7
|
+
* @param fn - Function to memoize
|
|
8
|
+
* @param resolver - Optional resolver function to generate cache key. If not passed the first argument is used as map key
|
|
9
|
+
*/
|
|
10
|
+
export default function memoize(fn: Function, resolver?: Function): Function;
|
package/date/addUTC.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds the provided amount of a specific key to the provided date
|
|
3
|
+
*
|
|
4
|
+
* @param val - Date to set to end of
|
|
5
|
+
* @param amount - (default=0) Amount of key to add
|
|
6
|
+
* @param key - (default='millisecond') Key to set
|
|
7
|
+
*
|
|
8
|
+
* @returns New date with provided amount of key added
|
|
9
|
+
*/
|
|
10
|
+
export default function addUTC(val: Date, amount?: number, key?: 'years' | 'year' | 'months' | 'month' | 'days' | 'day' | 'hours' | 'hour' | 'minutes' | 'minute' | 'seconds' | 'second' | 'milliseconds' | 'millisecond'): Date;
|
package/date/diff.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the diff between two dates in the provided key
|
|
3
|
+
*
|
|
4
|
+
* @param val_a - Date to diff against
|
|
5
|
+
* @param val_b - Date to diff with
|
|
6
|
+
* @param key - (default='millisecond') Key to diff in
|
|
7
|
+
*
|
|
8
|
+
* @returns Numerical diff between two dates
|
|
9
|
+
*/
|
|
10
|
+
export default function diff(val_a: Date, val_b: Date, key?: 'week' | 'weeks' | 'day' | 'days' | 'hour' | 'hours' | 'minute' | 'minutes' | 'second' | 'seconds' | 'millisecond' | 'milliseconds'): number;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the provided date to end of UTC of provided key
|
|
3
|
+
*
|
|
4
|
+
* @param val - Date to set to end of
|
|
5
|
+
* @param key - (default='millisecond') Key to set
|
|
6
|
+
*
|
|
7
|
+
* @returns New date set to end of key
|
|
8
|
+
*/
|
|
1
9
|
export default function endOfUTC(val: Date, key?: 'year' | 'quarter' | 'month' | 'week' | 'week_sun' | 'week_mon' | 'week_tue' | 'week_wed' | 'week_thu' | 'week_fri' | 'week_sat' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond'): Date;
|
package/date/is.d.ts
ADDED
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the provided date to start of UTC of provided key
|
|
3
|
+
*
|
|
4
|
+
* @param val - Date to set to start of
|
|
5
|
+
* @param key - (default='millisecond') Key to set
|
|
6
|
+
*
|
|
7
|
+
* @returns New date set to start of key
|
|
8
|
+
*/
|
|
1
9
|
export default function startOfUTC(val: Date, key?: 'year' | 'quarter' | 'month' | 'week' | 'week_sun' | 'week_mon' | 'week_tue' | 'week_wed' | 'week_thu' | 'week_fri' | 'week_sat' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond'): Date;
|
package/date/toUTC.d.ts
ADDED
package/date/toUnix.d.ts
ADDED
|
@@ -3,5 +3,12 @@ type deepInput = {
|
|
|
3
3
|
} | {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
}[] | any[];
|
|
6
|
+
/**
|
|
7
|
+
* Recursively freezes all properties of an object
|
|
8
|
+
*
|
|
9
|
+
* @param obj - Object to deep freeze
|
|
10
|
+
*
|
|
11
|
+
* @returns Deeply frozen object
|
|
12
|
+
*/
|
|
6
13
|
export default function deepFreeze(obj: deepInput): Readonly<deepInput>;
|
|
7
14
|
export {};
|
package/deep/get.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a property's value deep inside the structure of an array/object
|
|
3
|
+
*
|
|
4
|
+
* Example:
|
|
5
|
+
* const myObj = {
|
|
6
|
+
* a: 2,
|
|
7
|
+
* b: [
|
|
8
|
+
* {price : 2},
|
|
9
|
+
* {price : 4},
|
|
10
|
+
* ],
|
|
11
|
+
* };
|
|
12
|
+
* deepGet(myObj, 'b[0].price');
|
|
13
|
+
* Output:
|
|
14
|
+
* 2
|
|
15
|
+
*
|
|
16
|
+
* @param val - Object/Array to get the value from
|
|
17
|
+
* @param path - Path string to deeply get the value at
|
|
18
|
+
* @param get_parent - If passed as true retrieves the parent of where the value lives
|
|
19
|
+
*
|
|
20
|
+
* @returns Value stored at property or undefined
|
|
21
|
+
* @throws {TypeError}
|
|
22
|
+
*/
|
|
23
|
+
export default function deepGet(obj: {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
} | {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}[] | any[], path: string, get_parent?: boolean): any | undefined;
|
|
@@ -3,5 +3,12 @@ type deepInput = {
|
|
|
3
3
|
} | {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
}[] | any[];
|
|
6
|
+
/**
|
|
7
|
+
* Recursively seals all properties of an object
|
|
8
|
+
*
|
|
9
|
+
* @param obj - Object to deep seal
|
|
10
|
+
*
|
|
11
|
+
* @returns Deeply sealed object
|
|
12
|
+
*/
|
|
6
13
|
export default function deepSeal(obj: deepInput): deepInput;
|
|
7
14
|
export {};
|
package/deep/set.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets a property and its value deep in the structure of an object
|
|
3
|
+
*
|
|
4
|
+
* Example:
|
|
5
|
+
* const myObj = {a: 2};
|
|
6
|
+
* deepSet(myObj, 'b.c.d.e', 4);
|
|
7
|
+
* Output:
|
|
8
|
+
* {
|
|
9
|
+
* a: 2,
|
|
10
|
+
* b: {
|
|
11
|
+
* c: {
|
|
12
|
+
* d: {
|
|
13
|
+
* e: 4
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* Example:
|
|
20
|
+
* const myObj = {a: 2, b: [{price: 2}]};
|
|
21
|
+
* deepSet(myObj, 'b[0].price', 4);
|
|
22
|
+
* Output:
|
|
23
|
+
* {
|
|
24
|
+
* a: 2,
|
|
25
|
+
* b: [
|
|
26
|
+
* {price: 4}
|
|
27
|
+
* ]
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* @param val - Object to set the value on
|
|
31
|
+
* @param path - Path string to deeply set the value at
|
|
32
|
+
* @param value - Value to set (if using defineProperty can be an accessor object)
|
|
33
|
+
* @param define - Whether or not the property should be directly assigned or set using Object.defineProperty
|
|
34
|
+
*
|
|
35
|
+
* @returns True or false depending on whether or not the property was set correctly
|
|
36
|
+
* @throws {TypeError}
|
|
37
|
+
*/
|
|
38
|
+
export default function deepSet(obj: {
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
} | {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}[] | any[], path: string, value: any, define?: boolean): boolean;
|
package/equal.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute whether or not two provided values are deeply equal
|
|
3
|
+
*
|
|
4
|
+
* @param a - Value to compare against
|
|
5
|
+
* @param b - Value to compare with
|
|
6
|
+
*
|
|
7
|
+
* @returns Whether or not they are equal
|
|
8
|
+
*/
|
|
9
|
+
declare function equal(a: any, b: any): boolean;
|
|
10
|
+
export default equal;
|
package/function/is.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No-Operation (noop) resolver that simply returns a promise
|
|
3
|
+
* that resolves with the value that was passed to it
|
|
4
|
+
*
|
|
5
|
+
* @param val - Value to be resolved with
|
|
6
|
+
*
|
|
7
|
+
* @returns Promise that resolves with passed value
|
|
8
|
+
*/
|
|
9
|
+
export default function noopresolve(val?: any): Promise<any>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a promise that resolves after X milliseconds, useful in
|
|
3
|
+
* async scenarios where we wish to wait for a specific periodic of time
|
|
4
|
+
*
|
|
5
|
+
* @param ms - (default=1000) Amount of milliseconds to wait for
|
|
6
|
+
*
|
|
7
|
+
* @returns Promise that resolves after X milliseconds
|
|
8
|
+
*/
|
|
9
|
+
export default function sleep(ms?: number): Promise<void>;
|
package/hash/fnv1A.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a provided value into a Fowler-Noll-Vo 1A hash
|
|
3
|
+
* For more info: https://tools.ietf.org/html/draft-eastlake-fnv-03
|
|
4
|
+
*
|
|
5
|
+
* @param data - Value to be converted
|
|
6
|
+
* @param offset - (default=2166136261) FNV prime to use
|
|
7
|
+
*
|
|
8
|
+
* @returns FNV1A hash of provided value
|
|
9
|
+
*/
|
|
10
|
+
export default function fnv1A(data: any, offset?: number): number;
|