@webdeveric/utils 0.10.0 → 0.13.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/cjs/clamp.js +10 -0
- package/dist/cjs/clamp.js.map +1 -0
- package/dist/cjs/convert.js +19 -0
- package/dist/cjs/convert.js.map +1 -0
- package/dist/cjs/getMaxValue.js +16 -0
- package/dist/cjs/getMaxValue.js.map +1 -0
- package/dist/cjs/getMinValue.js +16 -0
- package/dist/cjs/getMinValue.js.map +1 -0
- package/dist/cjs/getOwnKeys.js +1 -4
- package/dist/cjs/getOwnKeys.js.map +1 -1
- package/dist/cjs/getOwnProperties.js +11 -0
- package/dist/cjs/getOwnProperties.js.map +1 -0
- package/dist/cjs/index.js +14 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/isEmpty.js +17 -0
- package/dist/cjs/isEmpty.js.map +1 -0
- package/dist/cjs/isObject.js +8 -0
- package/dist/cjs/isObject.js.map +1 -0
- package/dist/cjs/node/index.js +5 -1
- package/dist/cjs/node/index.js.map +1 -1
- package/dist/cjs/normalize.js +14 -15
- package/dist/cjs/normalize.js.map +1 -1
- package/dist/cjs/toPascalCase.js +2 -2
- package/dist/cjs/toPascalCase.js.map +1 -1
- package/dist/cjs/type-assertion.js +23 -0
- package/dist/cjs/type-assertion.js.map +1 -0
- package/dist/cjs/type-predicate.js +28 -0
- package/dist/cjs/type-predicate.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/until.js.map +1 -1
- package/dist/mjs/clamp.js +6 -0
- package/dist/mjs/clamp.js.map +1 -0
- package/dist/mjs/compose.js +1 -2
- package/dist/mjs/compose.js.map +1 -1
- package/dist/mjs/convert.js +15 -0
- package/dist/mjs/convert.js.map +1 -0
- package/dist/mjs/getMaxValue.js +12 -0
- package/dist/mjs/getMaxValue.js.map +1 -0
- package/dist/mjs/getMinValue.js +12 -0
- package/dist/mjs/getMinValue.js.map +1 -0
- package/dist/mjs/getOwnKeys.js +1 -4
- package/dist/mjs/getOwnKeys.js.map +1 -1
- package/dist/mjs/getOwnProperties.js +7 -0
- package/dist/mjs/getOwnProperties.js.map +1 -0
- package/dist/mjs/index.js +9 -0
- package/dist/mjs/index.js.map +1 -1
- package/dist/mjs/isEmpty.js +13 -0
- package/dist/mjs/isEmpty.js.map +1 -0
- package/dist/mjs/isObject.js +4 -0
- package/dist/mjs/isObject.js.map +1 -0
- package/dist/mjs/normalize.js +14 -15
- package/dist/mjs/normalize.js.map +1 -1
- package/dist/mjs/toPascalCase.js +2 -2
- package/dist/mjs/toPascalCase.js.map +1 -1
- package/dist/mjs/type-assertion.js +17 -0
- package/dist/mjs/type-assertion.js.map +1 -0
- package/dist/mjs/type-predicate.js +13 -0
- package/dist/mjs/type-predicate.js.map +1 -0
- package/dist/mjs/types.js +2 -0
- package/dist/mjs/types.js.map +1 -0
- package/dist/mjs/until.js.map +1 -1
- package/dist/types/clamp.d.ts +3 -0
- package/dist/types/clamp.d.ts.map +1 -0
- package/dist/types/convert.d.ts +8 -0
- package/dist/types/convert.d.ts.map +1 -0
- package/dist/types/getMaxValue.d.ts +3 -0
- package/dist/types/getMaxValue.d.ts.map +1 -0
- package/dist/types/getMinValue.d.ts +3 -0
- package/dist/types/getMinValue.d.ts.map +1 -0
- package/dist/types/getOwnKeys.d.ts +1 -1
- package/dist/types/getOwnKeys.d.ts.map +1 -1
- package/dist/types/getOwnProperties.d.ts +2 -0
- package/dist/types/getOwnProperties.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/isEmpty.d.ts +2 -0
- package/dist/types/isEmpty.d.ts.map +1 -0
- package/dist/types/isObject.d.ts +2 -0
- package/dist/types/isObject.d.ts.map +1 -0
- package/dist/types/normalize.d.ts +8 -6
- package/dist/types/normalize.d.ts.map +1 -1
- package/dist/types/type-assertion.d.ts +5 -0
- package/dist/types/type-assertion.d.ts.map +1 -0
- package/dist/types/type-predicate.d.ts +14 -0
- package/dist/types/type-predicate.d.ts.map +1 -0
- package/dist/types/types.d.ts +7 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/until.d.ts +2 -1
- package/dist/types/until.d.ts.map +1 -1
- package/package.json +20 -9
- package/src/clamp.ts +7 -0
- package/src/convert.ts +30 -0
- package/src/getMaxValue.ts +18 -0
- package/src/getMinValue.ts +18 -0
- package/src/getOwnKeys.ts +2 -5
- package/src/getOwnProperties.ts +6 -0
- package/src/index.ts +9 -0
- package/src/isEmpty.ts +15 -0
- package/src/isObject.ts +3 -0
- package/src/normalize.ts +36 -29
- package/src/toPascalCase.ts +2 -2
- package/src/type-assertion.ts +20 -0
- package/src/type-predicate.ts +32 -0
- package/src/types.ts +12 -0
- package/src/until.ts +2 -2
package/dist/mjs/normalize.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cloneDeep from 'lodash.clonedeep';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { getOwnProperties } from './getOwnProperties.js';
|
|
3
|
+
import { isObject } from './isObject.js';
|
|
4
4
|
/**
|
|
5
5
|
* @example
|
|
6
6
|
*
|
|
@@ -16,33 +16,32 @@ import { getType } from './getType.js';
|
|
|
16
16
|
* normalize(true, () => false );
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export function normalize(input, normalizers) {
|
|
20
|
-
const
|
|
19
|
+
export function normalize(input, normalizers, initContextData = () => ({})) {
|
|
20
|
+
const current = cloneDeep(input);
|
|
21
21
|
const context = Object.seal({
|
|
22
22
|
original: input,
|
|
23
|
-
current
|
|
24
|
-
data:
|
|
23
|
+
current,
|
|
24
|
+
data: initContextData(input, normalizers),
|
|
25
25
|
});
|
|
26
26
|
const walk = (currentRecord, currentNormalizers) => {
|
|
27
|
-
if (typeof currentNormalizers === 'undefined') {
|
|
28
|
-
return currentRecord;
|
|
29
|
-
}
|
|
30
27
|
if (typeof currentNormalizers === 'function') {
|
|
31
28
|
return currentNormalizers(currentRecord, context);
|
|
32
29
|
}
|
|
33
30
|
if (typeof currentNormalizers === 'object' && currentNormalizers !== null) {
|
|
34
31
|
if (typeof currentRecord === 'object' && currentRecord !== null) {
|
|
35
|
-
return
|
|
36
|
-
|
|
32
|
+
return getOwnProperties(currentNormalizers).reduce((data, key) => {
|
|
33
|
+
const normalizers = currentNormalizers[key];
|
|
34
|
+
// If the value is undefined but there is a normalizer record, set value to empty object.
|
|
35
|
+
const value = typeof data[key] === 'undefined' && isObject(normalizers)
|
|
36
|
+
? {}
|
|
37
|
+
: data[key];
|
|
38
|
+
data[key] = walk(value, normalizers);
|
|
37
39
|
return data;
|
|
38
40
|
}, currentRecord);
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
|
-
else {
|
|
42
|
-
throw new TypeError(`normalizers must be function or object. ${getType(currentNormalizers)} was received.`);
|
|
43
|
-
}
|
|
44
43
|
return currentRecord;
|
|
45
44
|
};
|
|
46
|
-
return walk(
|
|
45
|
+
return walk(current, normalizers);
|
|
47
46
|
}
|
|
48
47
|
//# sourceMappingURL=normalize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAyBzC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CACvB,KAAqB,EACrB,WAAoD,EACpD,kBAA4F,GAAc,EAAE,CAAC,CAAC,EAAE,CAAC;IAEjH,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAEjC,MAAM,OAAO,GAAwC,MAAM,CAAC,IAAI,CAAC;QAC/D,QAAQ,EAAE,KAAK;QACf,OAAO;QACP,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC;KAC1C,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,CACX,aAA4B,EAC5B,kBAAoE,EACrD,EAAE;QACjB,IAAI,OAAO,kBAAkB,KAAK,UAAU,EAAE;YAC5C,OAAO,kBAAkB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;SACnD;QAED,IAAI,OAAO,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,KAAK,IAAI,EAAE;YACzE,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,KAAK,IAAI,EAAE;gBAC/D,OAAO,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;oBAC/D,MAAM,WAAW,GAAG,kBAAkB,CAAE,GAAG,CAAE,CAAC;oBAC9C,yFAAyF;oBACzF,MAAM,KAAK,GAAG,OAAO,IAAI,CAAE,GAAG,CAAE,KAAK,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC;wBACvE,CAAC,CAAC,EAAwC;wBAC1C,CAAC,CAAC,IAAI,CAAE,GAAG,CAAE,CAAC;oBAEhB,IAAI,CAAE,GAAG,CAAE,GAAG,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;oBAEvC,OAAO,IAAI,CAAC;gBACd,CAAC,EAAE,aAAa,CAAC,CAAC;aACnB;SACF;QAED,OAAO,aAAa,CAAC;IACvB,CAAC,CAAC;IAEF,OAAO,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACpC,CAAC"}
|
package/dist/mjs/toPascalCase.js
CHANGED
|
@@ -7,7 +7,7 @@ export function toPascalCase(text, customWords) {
|
|
|
7
7
|
// Remove apostrophes then uppercase the first letter of each word.
|
|
8
8
|
words = words.map(word => {
|
|
9
9
|
const fixedWord = word.replace(/'/g, '');
|
|
10
|
-
return fixedWord
|
|
10
|
+
return fixedWord.substring(0, 1).toUpperCase() + fixedWord.substring(1);
|
|
11
11
|
});
|
|
12
12
|
if (customWords && getType(customWords) === 'Object') {
|
|
13
13
|
const replacements = Object.entries(customWords).map(([key, value]) => [
|
|
@@ -19,7 +19,7 @@ export function toPascalCase(text, customWords) {
|
|
|
19
19
|
const replaceCustomWords = (word) => {
|
|
20
20
|
const lowerWord = word.toLowerCase();
|
|
21
21
|
for (const [key, value] of replacements) {
|
|
22
|
-
if (key === lowerWord) {
|
|
22
|
+
if (key === lowerWord && typeof value === 'string') {
|
|
23
23
|
return value;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toPascalCase.js","sourceRoot":"","sources":["../../src/toPascalCase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,WAAoC;IAE7E,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAE,2BAA2B,CAAE,CAAC;IAE9D,IAAK,CAAE,KAAK,EAAG;QACb,OAAO,EAAE,CAAC;KACX;IAED,mEAAmE;IACnE,KAAK,GAAG,KAAK,CAAC,GAAG,CAAE,IAAI,CAAC,EAAE;QACxB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAEzC,OAAO,SAAS,
|
|
1
|
+
{"version":3,"file":"toPascalCase.js","sourceRoot":"","sources":["../../src/toPascalCase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,WAAoC;IAE7E,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,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
|
+
export function assertIsInteger(input) {
|
|
3
|
+
if (!Number.isInteger(input)) {
|
|
4
|
+
throw new TypeError('input is not an integer');
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export function assertIsFiniteNumber(input) {
|
|
8
|
+
if (!Number.isFinite(input)) {
|
|
9
|
+
throw new TypeError('input is not a finite number');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function assertIsNumericValueArray(input) {
|
|
13
|
+
if (!isNumericValueArray(input)) {
|
|
14
|
+
throw new TypeError('all items must be a NumericValue');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=type-assertion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-assertion.js","sourceRoot":"","sources":["../../src/type-assertion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,CAAE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QAC7B,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC,CAAC;KAChD;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,IAAI,CAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC5B,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;KACrD;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACtD,IAAI,CAAE,mBAAmB,CAAC,KAAK,CAAC,EAAE;QAChC,MAAM,IAAI,SAAS,CAAC,kCAAkC,CAAC,CAAC;KACzD;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const isOptionalString = (input) => typeof input === 'string' || typeof input === 'undefined';
|
|
2
|
+
export const isOptionalNumber = (input) => (typeof input === 'number' && !Number.isNaN(input)) || typeof input === 'undefined';
|
|
3
|
+
export const isStringMatching = (input, pattern) => typeof input === 'string' && pattern.test(input);
|
|
4
|
+
export const isPropertyKey = (input) => typeof input === 'string' || typeof input === 'number' || typeof input === 'symbol';
|
|
5
|
+
export const isNumericString = (input) => isStringMatching(input, /^[-+]?\d+(\.\d+)?$/);
|
|
6
|
+
export const isNumericValue = (input) => typeof input === 'number' || typeof input === 'bigint' || isNumericString(input);
|
|
7
|
+
export const isNumericValueArray = (input) => Array.isArray(input) && input.every(isNumericValue);
|
|
8
|
+
export const isIntString = (input) => isStringMatching(input, /^[-+]?\d+$/);
|
|
9
|
+
export const isFiniteNumber = (input) => typeof input === 'number' && Number.isFinite(input);
|
|
10
|
+
export const isInteger = (input) => Number.isInteger(input);
|
|
11
|
+
export const isPositiveInteger = (input) => isInteger(input) && input >= 0;
|
|
12
|
+
export const isPositiveFiniteNumber = (input) => isFiniteNumber(input) && input >= 0;
|
|
13
|
+
//# sourceMappingURL=type-predicate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-predicate.js","sourceRoot":"","sources":["../../src/type-predicate.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAA+B,EAAE,CAC9E,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC;AAE5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAA+B,EAAE,CAC9E,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC;AAEvF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAAE,OAAe,EAAmB,EAAE,CACnF,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,EAAE,CACpE,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"mappings":""}
|
package/dist/mjs/until.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"until.js","sourceRoot":"","sources":["../../src/until.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"until.js","sourceRoot":"","sources":["../../src/until.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AA2BvC,MAAM,cAAc,GAA2B;IAC7C,KAAK,EAAE,EAAE;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,KAAK,CAAK,EAAoB,EAAE,UAAwB,cAAc;IAEpF,IAAK,OAAO,EAAE,KAAK,UAAU,EAAG;QAC9B,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC;KAC3D;IAED,IAAK,CAAE,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAG;QAC9C,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,8BAA8B,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;KAC9F;IAED,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IAEjF,MAAM,OAAO,GAAG,CAAE,KAAc,EAAoB,EAAE,CAAC,MAAM,CAAC,SAAS,CAAE,KAAK,CAAE,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC;IAEhH,MAAM,QAAQ,GAAG,CAAE,KAAY,EAAE,OAAqB,EAAY,EAAE,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAE,OAAO,CAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAE5H,IAAK,CAAE,OAAO,CAAE,KAAK,CAAE,EAAG;QACxB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,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,SAAS,CAAC;AAE5C,wBAAgB,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,GAAG,YAAY,CAE7F"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Builtin } from 'ts-essentials';
|
|
2
|
+
export declare type ConvertFn<SourceType, ReturnType> = (source: Readonly<SourceType>) => ReturnType;
|
|
3
|
+
export declare type ConvertRecord<Input, Output> = {
|
|
4
|
+
[Property in keyof Output]: Output[Property] extends Builtin ? ConvertFn<Input, Output[Property]> : AnyConverter<Input, Output[Property]>;
|
|
5
|
+
};
|
|
6
|
+
export declare type AnyConverter<Input, Output> = ConvertRecord<Input, Output> | ConvertFn<Input, Output>;
|
|
7
|
+
export declare const convert: <Input, Output>(input: Readonly<Input>, converter: AnyConverter<Input, Output>) => Output;
|
|
8
|
+
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/convert.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,oBAAY,SAAS,CAAC,UAAU,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,UAAU,CAAC;AAE7F,oBAAY,aAAa,CAAC,KAAK,EAAE,MAAM,IAAI;KACxC,QAAQ,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,OAAO,GACxD,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,GAClC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;CAC1C,CAAC;AAEF,oBAAY,YAAY,CAAC,KAAK,EAAE,MAAM,IAAI,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAElG,eAAO,MAAM,OAAO,2FAcnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMaxValue.d.ts","sourceRoot":"","sources":["../../src/getMaxValue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAgB,WAAW,CAAC,GAAG,MAAM,EAAE,CAAC,YAAY,EAAE,GAAG,YAAY,EAAE,CAAC,GAAG,YAAY,CActF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMinValue.d.ts","sourceRoot":"","sources":["../../src/getMinValue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAgB,WAAW,CAAC,GAAG,MAAM,EAAE,CAAC,YAAY,EAAE,GAAG,YAAY,EAAE,CAAC,GAAG,YAAY,CActF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function getOwnKeys<T, K extends keyof T>(data: T): K[];
|
|
1
|
+
export declare function getOwnKeys<T extends Parameters<typeof Object.keys>[0], K extends keyof T>(data: T): K[];
|
|
2
2
|
//# sourceMappingURL=getOwnKeys.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOwnKeys.d.ts","sourceRoot":"","sources":["../../src/getOwnKeys.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"getOwnKeys.d.ts","sourceRoot":"","sources":["../../src/getOwnKeys.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAEvG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOwnProperties.d.ts","sourceRoot":"","sources":["../../src/getOwnProperties.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAKnE"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
export * from './asArray.js';
|
|
2
|
+
export * from './clamp.js';
|
|
2
3
|
export * from './compose.js';
|
|
4
|
+
export * from './convert.js';
|
|
3
5
|
export * from './delay.js';
|
|
4
6
|
export * from './delayAnimationFrame.js';
|
|
7
|
+
export * from './getMaxValue.js';
|
|
8
|
+
export * from './getMinValue.js';
|
|
5
9
|
export * from './getOwnKeys.js';
|
|
10
|
+
export * from './getOwnProperties.js';
|
|
6
11
|
export * from './getType.js';
|
|
12
|
+
export * from './isEmpty.js';
|
|
13
|
+
export * from './isObject.js';
|
|
7
14
|
export * from './joinStrings.js';
|
|
8
15
|
export * from './normalize.js';
|
|
9
16
|
export * from './secToString.js';
|
|
10
17
|
export * from './toPascalCase.js';
|
|
11
18
|
export * from './trimEnd.js';
|
|
12
19
|
export * from './trimStart.js';
|
|
20
|
+
export * from './type-assertion.js';
|
|
21
|
+
export * from './types.js';
|
|
13
22
|
export * from './uniqueItems.js';
|
|
14
23
|
export * from './until.js';
|
|
15
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEmpty.d.ts","sourceRoot":"","sources":["../../src/isEmpty.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAc/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isObject.d.ts","sourceRoot":"","sources":["../../src/isObject.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhD"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { Builtin } from 'ts-essentials';
|
|
2
|
-
|
|
2
|
+
import type { AnyRecord } from './types';
|
|
3
|
+
export declare type NormalizeContext<OwnerRecordType, ContextData extends AnyRecord> = {
|
|
3
4
|
original: Readonly<OwnerRecordType>;
|
|
4
5
|
current: OwnerRecordType;
|
|
5
|
-
data:
|
|
6
|
+
data: ContextData;
|
|
6
7
|
};
|
|
7
|
-
export declare type NormalizerFn<
|
|
8
|
-
export declare type NormalizersRecord<RecordType, OwnerRecordType =
|
|
9
|
-
[Property in keyof RecordType]?: RecordType[Property] extends Builtin ? NormalizerFn<RecordType[Property], OwnerRecordType> :
|
|
8
|
+
export declare type NormalizerFn<PropertyType, OwnerRecordType, ContextData extends AnyRecord = AnyRecord> = (input: PropertyType, context: NormalizeContext<OwnerRecordType, ContextData>) => PropertyType;
|
|
9
|
+
export declare type NormalizersRecord<RecordType, OwnerRecordType, ContextData extends AnyRecord = AnyRecord> = {
|
|
10
|
+
readonly [Property in keyof RecordType]?: RecordType[Property] extends Builtin ? NormalizerFn<RecordType[Property], OwnerRecordType, ContextData> : AnyNormalizer<RecordType[Property], OwnerRecordType, ContextData>;
|
|
10
11
|
};
|
|
12
|
+
export declare type AnyNormalizer<RecordType, OwnerRecordType, ContextData extends AnyRecord = AnyRecord> = NormalizerFn<RecordType, OwnerRecordType, ContextData> | NormalizersRecord<RecordType, OwnerRecordType, ContextData>;
|
|
11
13
|
/**
|
|
12
14
|
* @example
|
|
13
15
|
*
|
|
@@ -23,5 +25,5 @@ export declare type NormalizersRecord<RecordType, OwnerRecordType = RecordType>
|
|
|
23
25
|
* normalize(true, () => false );
|
|
24
26
|
* ```
|
|
25
27
|
*/
|
|
26
|
-
export declare function normalize<Data>(input: Data
|
|
28
|
+
export declare function normalize<Data, ContextData extends AnyRecord = AnyRecord>(input: Readonly<Data>, normalizers?: AnyNormalizer<Data, Data, ContextData>, initContextData?: (data: typeof input, dataNormalizers: typeof normalizers) => ContextData): Data;
|
|
27
29
|
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/normalize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAK7C,oBAAY,gBAAgB,CAAC,eAAe,IAAI;
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/normalize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAK7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,oBAAY,gBAAgB,CAAC,eAAe,EAAE,WAAW,SAAS,SAAS,IAAI;IAC7E,QAAQ,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IACpC,OAAO,EAAE,eAAe,CAAC;IACzB,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF,oBAAY,YAAY,CAAC,YAAY,EAAE,eAAe,EAAE,WAAW,SAAS,SAAS,GAAG,SAAS,IAAI,CACnG,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,gBAAgB,CAAC,eAAe,EAAE,WAAW,CAAC,KACpD,YAAY,CAAC;AAElB,oBAAY,iBAAiB,CAAC,UAAU,EAAE,eAAe,EAAE,WAAW,SAAS,SAAS,GAAG,SAAS,IAAI;IACtG,QAAQ,EAAE,QAAQ,IAAI,MAAM,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,SAAS,OAAO,GAC1E,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,WAAW,CAAC,GAChE,aAAa,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,WAAW,CAAC;CACtE,CAAC;AAEF,oBAAY,aAAa,CAAC,UAAU,EAAE,eAAe,EAAE,WAAW,SAAS,SAAS,GAAG,SAAS,IAC5F,YAAY,CAAC,UAAU,EAAE,eAAe,EAAE,WAAW,CAAC,GACtD,iBAAiB,CAAC,UAAU,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;AAEhE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,SAAS,SAAS,GAAG,SAAS,EACvE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EACrB,WAAW,CAAC,EAAE,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,EACpD,eAAe,GAAE,CAAC,IAAI,EAAE,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,WAAW,KAAK,WAAmC,GAChH,IAAI,CAqCN"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NumericValue } from './types';
|
|
2
|
+
export declare function assertIsInteger(input: unknown): asserts input is number;
|
|
3
|
+
export declare function assertIsFiniteNumber(input: unknown): asserts input is number;
|
|
4
|
+
export declare function assertIsNumericValueArray(input: unknown): asserts input is NumericValue[];
|
|
5
|
+
//# sourceMappingURL=type-assertion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-assertion.d.ts","sourceRoot":"","sources":["../../src/type-assertion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAIvE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAI5E;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,EAAE,CAIzF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NumericValue } from './types';
|
|
2
|
+
export declare const isOptionalString: (input: unknown) => input is string | undefined;
|
|
3
|
+
export declare const isOptionalNumber: (input: unknown) => input is number | undefined;
|
|
4
|
+
export declare const isStringMatching: (input: unknown, pattern: RegExp) => input is string;
|
|
5
|
+
export declare const isPropertyKey: (input: unknown) => input is PropertyKey;
|
|
6
|
+
export declare const isNumericString: (input: unknown) => input is `${number}`;
|
|
7
|
+
export declare const isNumericValue: (input: unknown) => input is NumericValue;
|
|
8
|
+
export declare const isNumericValueArray: (input: unknown) => input is NumericValue[];
|
|
9
|
+
export declare const isIntString: (input: unknown) => input is `${number}`;
|
|
10
|
+
export declare const isFiniteNumber: (input: unknown) => input is number;
|
|
11
|
+
export declare const isInteger: (input: unknown) => input is number;
|
|
12
|
+
export declare const isPositiveInteger: (input: unknown) => input is number;
|
|
13
|
+
export declare const isPositiveFiniteNumber: (input: unknown) => input is number;
|
|
14
|
+
//# sourceMappingURL=type-predicate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-predicate.d.ts","sourceRoot":"","sources":["../../src/type-predicate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,gBAAgB,UAAW,OAAO,gCACY,CAAC;AAE5D,eAAO,MAAM,gBAAgB,UAAW,OAAO,gCACuC,CAAC;AAEvF,eAAO,MAAM,gBAAgB,UAAW,OAAO,WAAW,MAAM,oBACd,CAAC;AAEnD,eAAO,MAAM,aAAa,UAAW,OAAO,yBACyC,CAAC;AAEtF,eAAO,MAAM,eAAe,UAAW,OAAO,yBACC,CAAC;AAEhD,eAAO,MAAM,cAAc,UAAW,OAAO,0BACqC,CAAC;AAEnF,eAAO,MAAM,mBAAmB,UAAW,OAAO,4BACG,CAAC;AAEtD,eAAO,MAAM,WAAW,UAAW,OAAO,yBAAkE,CAAC;AAE7G,eAAO,MAAM,cAAc,UAAW,OAAO,oBAAyE,CAAC;AAEvH,eAAO,MAAM,SAAS,UAAW,OAAO,oBAA6C,CAAC;AAEtF,eAAO,MAAM,iBAAiB,UAAW,OAAO,oBAAoD,CAAC;AAErG,eAAO,MAAM,sBAAsB,UAAW,OAAO,oBAAyD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare type AnyRecord = Record<PropertyKey, any>;
|
|
2
|
+
export declare type UnknownRecord = Record<PropertyKey, unknown>;
|
|
3
|
+
export declare type NumericString<T extends string | number = number> = `${T}` extends `${number}` ? `${T}` : never;
|
|
4
|
+
export declare type NumericValue = number | bigint | NumericString;
|
|
5
|
+
export declare type MaybePlural<T extends string> = T | `${T}s`;
|
|
6
|
+
export declare type StringKeys<T> = keyof T & string;
|
|
7
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AACA,oBAAY,SAAS,GAAG,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;AAEjD,oBAAY,aAAa,GAAG,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAEzD,oBAAY,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,IAAI,GAAG,CAAC,EAAE,SAAS,GAAG,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC;AAE5G,oBAAY,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC;AAE3D,oBAAY,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC;AAExD,oBAAY,UAAU,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,CAAC"}
|
package/dist/types/until.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { AnyRecord } from './types';
|
|
1
2
|
export interface UntilContext {
|
|
2
3
|
callCount: number;
|
|
3
4
|
lastCall?: number;
|
|
4
|
-
data:
|
|
5
|
+
data: AnyRecord;
|
|
5
6
|
options: UntilOptions;
|
|
6
7
|
}
|
|
7
8
|
export declare type DelayFn = (context: Readonly<UntilContext>) => number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"until.d.ts","sourceRoot":"","sources":["../../src/until.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"until.d.ts","sourceRoot":"","sources":["../../src/until.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,oBAAY,OAAO,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,KAAK,MAAM,CAAC;AAElE,oBAAY,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAErC,oBAAY,YAAY,GAAG;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,oBAAY,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAElD,oBAAY,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAE7D,oBAAY,QAAQ,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;AAE/C,oBAAY,aAAa,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;AAMlH;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAG,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,GAAE,YAA6B,GAAK,OAAO,CAAC,CAAC,CAAC,CAiGpG"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webdeveric/utils",
|
|
3
3
|
"description": "Just another collection of utilities.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.13.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -9,18 +9,27 @@
|
|
|
9
9
|
"keywords": [
|
|
10
10
|
"utilities",
|
|
11
11
|
"asArray",
|
|
12
|
+
"clamp",
|
|
12
13
|
"compose",
|
|
14
|
+
"convert",
|
|
13
15
|
"delay",
|
|
14
16
|
"delayAnimationFrame",
|
|
15
17
|
"fcrdns",
|
|
18
|
+
"getMaxValue",
|
|
19
|
+
"getMinValue",
|
|
16
20
|
"getOwnKeys",
|
|
21
|
+
"getOwnProperties",
|
|
17
22
|
"getType",
|
|
23
|
+
"isEmpty",
|
|
24
|
+
"isObject",
|
|
18
25
|
"joinStrings",
|
|
19
26
|
"normalize",
|
|
20
27
|
"secToString",
|
|
21
28
|
"toPascalCase",
|
|
22
29
|
"trimEnd",
|
|
23
30
|
"trimStart",
|
|
31
|
+
"type-assertion",
|
|
32
|
+
"types",
|
|
24
33
|
"uniqueItems",
|
|
25
34
|
"until"
|
|
26
35
|
],
|
|
@@ -43,7 +52,8 @@
|
|
|
43
52
|
"./*": {
|
|
44
53
|
"require": "./dist/cjs/*",
|
|
45
54
|
"import": "./dist/mjs/*"
|
|
46
|
-
}
|
|
55
|
+
},
|
|
56
|
+
"./package.json": "./package.json"
|
|
47
57
|
},
|
|
48
58
|
"files": [
|
|
49
59
|
"dist",
|
|
@@ -70,12 +80,14 @@
|
|
|
70
80
|
"lint": "eslint ./*.js ./src/ ./test/ --ext .ts --fix",
|
|
71
81
|
"test": "NODE_ENV=test jest",
|
|
72
82
|
"validate": "./bin/validate.cjs",
|
|
73
|
-
"
|
|
83
|
+
"update-keywords": "./bin/update-keywords.mjs",
|
|
84
|
+
"spellcheck": "cspell './{.github,src,test}/**/*.{ts,json}' './*.{md,js}' './package.json' --no-progress",
|
|
74
85
|
"prepublishOnly": "npm run typecheck && npm run spellcheck && npm run lint && npm test && npm run build"
|
|
75
86
|
},
|
|
76
87
|
"dependencies": {
|
|
77
88
|
"lodash.clonedeep": "^4.5.0",
|
|
78
|
-
"lodash.escaperegexp": "^4.1.2"
|
|
89
|
+
"lodash.escaperegexp": "^4.1.2",
|
|
90
|
+
"ts-essentials": "^9.0.0"
|
|
79
91
|
},
|
|
80
92
|
"devDependencies": {
|
|
81
93
|
"@types/jest": "^27.4.0",
|
|
@@ -85,16 +97,15 @@
|
|
|
85
97
|
"@webdeveric/eslint-config-ts": "^0.4.1",
|
|
86
98
|
"core-js": "^3.11.1",
|
|
87
99
|
"cspell": "^5.3.12",
|
|
88
|
-
"eslint": "^8.
|
|
100
|
+
"eslint": "^8.10.0",
|
|
89
101
|
"eslint-import-resolver-typescript": "^2.5.0",
|
|
90
102
|
"eslint-plugin-import": "^2.25.4",
|
|
91
|
-
"eslint-plugin-jest": "^
|
|
103
|
+
"eslint-plugin-jest": "^26.0.0",
|
|
92
104
|
"jest": "^27.3.0",
|
|
93
105
|
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
94
106
|
"rimraf": "^3.0.2",
|
|
95
|
-
"ts-essentials": "^9.0.0",
|
|
96
107
|
"ts-jest": "^27.0.7",
|
|
97
|
-
"ts-node": "^10.
|
|
98
|
-
"typescript": "^4.
|
|
108
|
+
"ts-node": "^10.6.0",
|
|
109
|
+
"typescript": "^4.6.2"
|
|
99
110
|
}
|
|
100
111
|
}
|
package/src/clamp.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getMaxValue } from './getMaxValue.js';
|
|
2
|
+
import { getMinValue } from './getMinValue.js';
|
|
3
|
+
import type { NumericValue } from './types';
|
|
4
|
+
|
|
5
|
+
export function clamp(min: NumericValue, value: NumericValue, max: NumericValue): NumericValue {
|
|
6
|
+
return getMaxValue(min, getMinValue(value, max));
|
|
7
|
+
}
|
package/src/convert.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getOwnProperties } from './getOwnProperties.js';
|
|
2
|
+
import { getType } from './getType.js';
|
|
3
|
+
|
|
4
|
+
import type { Builtin } from 'ts-essentials';
|
|
5
|
+
|
|
6
|
+
export type ConvertFn<SourceType, ReturnType> = (source: Readonly<SourceType>) => ReturnType;
|
|
7
|
+
|
|
8
|
+
export type ConvertRecord<Input, Output> = {
|
|
9
|
+
[Property in keyof Output]: Output[Property] extends Builtin
|
|
10
|
+
? ConvertFn<Input, Output[Property]>
|
|
11
|
+
: AnyConverter<Input, Output[Property]>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type AnyConverter<Input, Output> = ConvertRecord<Input, Output> | ConvertFn<Input, Output>;
|
|
15
|
+
|
|
16
|
+
export const convert = <Input, Output>(input: Readonly<Input>, converter: AnyConverter<Input, Output>): Output => {
|
|
17
|
+
if (typeof converter === 'function') {
|
|
18
|
+
return converter(input);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof converter === 'object' && converter !== null) {
|
|
22
|
+
return getOwnProperties(converter).reduce<Partial<Output>>((data, key) => {
|
|
23
|
+
data[ key ] = convert(input, converter[ key ]);
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}, {}) as Output;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
throw new TypeError(`${getType(converter)} is not a valid converter`);
|
|
30
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { assertIsNumericValueArray } from './type-assertion.js';
|
|
2
|
+
import type { NumericValue } from './types';
|
|
3
|
+
|
|
4
|
+
export function getMaxValue(...values: [NumericValue, ...NumericValue[]]): NumericValue {
|
|
5
|
+
if (values.length === 0) {
|
|
6
|
+
throw new Error('Expected at least one numeric value');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
assertIsNumericValueArray(values);
|
|
10
|
+
|
|
11
|
+
return values.reduce(
|
|
12
|
+
(high, current) => {
|
|
13
|
+
const value = typeof current === 'string' ? Number(current) : current;
|
|
14
|
+
|
|
15
|
+
return value > high ? current : high;
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { assertIsNumericValueArray } from './type-assertion.js';
|
|
2
|
+
import type { NumericValue } from './types';
|
|
3
|
+
|
|
4
|
+
export function getMinValue(...values: [NumericValue, ...NumericValue[]]): NumericValue {
|
|
5
|
+
if (values.length === 0) {
|
|
6
|
+
throw new Error('Expected at least one numeric value');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
assertIsNumericValueArray(values);
|
|
10
|
+
|
|
11
|
+
return values.reduce(
|
|
12
|
+
(low, current) => {
|
|
13
|
+
const value = typeof current === 'string' ? Number(current) : current;
|
|
14
|
+
|
|
15
|
+
return value < low ? current : low;
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
}
|
package/src/getOwnKeys.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export function getOwnKeys<T, K extends keyof T>(data: T): K[] {
|
|
2
|
-
return [
|
|
3
|
-
...Object.getOwnPropertyNames(data),
|
|
4
|
-
...Object.getOwnPropertySymbols(data),
|
|
5
|
-
] as K[];
|
|
1
|
+
export function getOwnKeys<T extends Parameters<typeof Object.keys>[0], K extends keyof T>(data: T): K[] {
|
|
2
|
+
return Object.keys(data) as K[];
|
|
6
3
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
export * from './asArray.js';
|
|
2
|
+
export * from './clamp.js';
|
|
2
3
|
export * from './compose.js';
|
|
4
|
+
export * from './convert.js';
|
|
3
5
|
export * from './delay.js';
|
|
4
6
|
export * from './delayAnimationFrame.js';
|
|
7
|
+
export * from './getMaxValue.js';
|
|
8
|
+
export * from './getMinValue.js';
|
|
5
9
|
export * from './getOwnKeys.js';
|
|
10
|
+
export * from './getOwnProperties.js';
|
|
6
11
|
export * from './getType.js';
|
|
12
|
+
export * from './isEmpty.js';
|
|
13
|
+
export * from './isObject.js';
|
|
7
14
|
export * from './joinStrings.js';
|
|
8
15
|
export * from './normalize.js';
|
|
9
16
|
export * from './secToString.js';
|
|
10
17
|
export * from './toPascalCase.js';
|
|
11
18
|
export * from './trimEnd.js';
|
|
12
19
|
export * from './trimStart.js';
|
|
20
|
+
export * from './type-assertion.js';
|
|
21
|
+
export * from './types.js';
|
|
13
22
|
export * from './uniqueItems.js';
|
|
14
23
|
export * from './until.js';
|
package/src/isEmpty.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function isEmpty(input: unknown): boolean {
|
|
2
|
+
if (typeof input === 'undefined' || input === null || (typeof input === 'string' && ! input.length)) {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
if (Array.isArray(input)) {
|
|
7
|
+
return input.length === 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (typeof input === 'object') {
|
|
11
|
+
return Object.keys(input).length === 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return false;
|
|
15
|
+
}
|
package/src/isObject.ts
ADDED