@webdeveric/utils 0.9.0 → 0.12.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 +14 -0
- package/dist/cjs/getMaxValue.js.map +1 -0
- package/dist/cjs/getMinValue.js +14 -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/type-assertion.js +16 -0
- package/dist/cjs/type-assertion.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/until.js +10 -13
- 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 +10 -0
- package/dist/mjs/getMaxValue.js.map +1 -0
- package/dist/mjs/getMinValue.js +10 -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/type-assertion.js +11 -0
- package/dist/mjs/type-assertion.js.map +1 -0
- package/dist/mjs/types.js +2 -0
- package/dist/mjs/types.js.map +1 -0
- package/dist/mjs/until.js +10 -13
- 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 +3 -0
- package/dist/types/type-assertion.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 +8 -10
- package/dist/types/until.d.ts.map +1 -1
- package/package.json +27 -12
- package/src/clamp.ts +7 -0
- package/src/convert.ts +30 -0
- package/src/getMaxValue.ts +16 -0
- package/src/getMinValue.ts +16 -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/type-assertion.ts +11 -0
- package/src/types.ts +12 -0
- package/src/until.ts +22 -29
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function assertsIsInteger(input) {
|
|
2
|
+
if (!Number.isInteger(input)) {
|
|
3
|
+
throw new TypeError('input is not an integer');
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export function assertsIsFiniteNumber(input) {
|
|
7
|
+
if (!Number.isFinite(input)) {
|
|
8
|
+
throw new TypeError('input is not a finite number');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=type-assertion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-assertion.js","sourceRoot":"","sources":["../../src/type-assertion.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,CAAE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QAC7B,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC,CAAC;KAChD;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,IAAI,CAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC5B,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;KACrD;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/dist/mjs/until.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
return Number.isInteger(delay) || typeof delay === 'function';
|
|
3
|
-
}
|
|
4
|
-
function getDelay(delay, context) {
|
|
5
|
-
return typeof delay === 'function' ? delay(context) : delay;
|
|
6
|
-
}
|
|
1
|
+
import { getType } from './getType.js';
|
|
7
2
|
const defaultOptions = {
|
|
8
3
|
delay: 10,
|
|
9
4
|
};
|
|
@@ -12,20 +7,22 @@ const defaultOptions = {
|
|
|
12
7
|
*/
|
|
13
8
|
export function until(fn, options = defaultOptions) {
|
|
14
9
|
if (typeof fn !== 'function') {
|
|
15
|
-
|
|
10
|
+
return Promise.reject(new Error('fn must be a function'));
|
|
16
11
|
}
|
|
17
12
|
if (!options || typeof options !== 'object') {
|
|
18
|
-
|
|
13
|
+
return Promise.reject(new Error(`options must be an object. ${getType(options)} provided.`));
|
|
19
14
|
}
|
|
20
15
|
const { delay, timeout, callLimit } = Object.assign({}, defaultOptions, options);
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
const isDelay = (input) => Number.isInteger(input) || typeof input === 'function';
|
|
17
|
+
const getDelay = (delay, context) => typeof delay === 'function' ? delay(context) : delay;
|
|
18
|
+
if (!isDelay(delay)) {
|
|
19
|
+
return Promise.reject(new Error('invalid delay value'));
|
|
23
20
|
}
|
|
24
|
-
if (timeout !== undefined && !
|
|
25
|
-
|
|
21
|
+
if (timeout !== undefined && !isDelay(timeout)) {
|
|
22
|
+
return Promise.reject(new Error('invalid timeout value'));
|
|
26
23
|
}
|
|
27
24
|
if (callLimit !== undefined && !Number.isInteger(callLimit)) {
|
|
28
|
-
|
|
25
|
+
return Promise.reject(new Error('invalid callLimit value'));
|
|
29
26
|
}
|
|
30
27
|
return new Promise((resolutionFn, rejectionFn) => {
|
|
31
28
|
let callCount = 0;
|
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,GA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AEZ,EAAE,CAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAE,CAAC;gBAE/B,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBAEtB,IAAK,CAAE,IAAI,EAAG;oBACZ,KAAK,GAAG,UAAU,CAAE,aAAa,EAAE,QAAQ,CAAE,KAAK,EAAE,OAAO,CAAE,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAE,CAAC;iBAC7F;aACF;YAAC,OAAQ,KAAK,EAAG;gBAChB,MAAM,CAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAE,CAAC;aAClE;QACH,CAAC,CAAC;QAEF,aAAa,CAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAE,CAAC;QAE5C,IAAK,CAAE,IAAI,IAAI,OAAO,KAAK,SAAS,EAAG;YACrC,YAAY,GAAG,UAAU,CACvB,GAAG,EAAE;gBACH,MAAM,CAAE,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAE,CAAC;YAC1C,CAAC,EACD,QAAQ,CAAE,OAAO,EAAE,OAAO,CAAE,CAC7B,CAAC;SACH;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clamp.d.ts","sourceRoot":"","sources":["../../src/clamp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,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":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAgB,WAAW,CAAC,GAAG,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAanE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMinValue.d.ts","sourceRoot":"","sources":["../../src/getMinValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAgB,WAAW,CAAC,GAAG,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAanE"}
|
|
@@ -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,E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IAAI,EAAE,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,WAAW,KAAK,WAAmC,GAChH,IAAI,CAqCN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-assertion.d.ts","sourceRoot":"","sources":["../../src/type-assertion.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAIxE;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAI7E"}
|
|
@@ -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,25 +1,23 @@
|
|
|
1
|
+
import type { AnyRecord } from './types';
|
|
1
2
|
export interface UntilContext {
|
|
2
3
|
callCount: number;
|
|
3
4
|
lastCall?: number;
|
|
4
|
-
data:
|
|
5
|
+
data: AnyRecord;
|
|
6
|
+
options: UntilOptions;
|
|
5
7
|
}
|
|
6
|
-
declare type DelayFn = (context: Readonly<UntilContext>) => number;
|
|
7
|
-
declare type Delay = DelayFn | number;
|
|
8
|
+
export declare type DelayFn = (context: Readonly<UntilContext>) => number;
|
|
9
|
+
export declare type Delay = DelayFn | number;
|
|
8
10
|
export declare type UntilOptions = {
|
|
9
11
|
delay: Delay;
|
|
10
12
|
timeout?: Delay;
|
|
11
13
|
callLimit?: number;
|
|
12
14
|
};
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
declare type ResolverValue<T> = T | PromiseLike<T>;
|
|
17
|
-
declare type ResolveFn<T> = (value: ResolverValue<T>) => void;
|
|
18
|
-
declare type RejectFn = (error?: Error) => void;
|
|
15
|
+
export declare type ResolverValue<T> = T | PromiseLike<T>;
|
|
16
|
+
export declare type ResolveFn<T> = (value: ResolverValue<T>) => void;
|
|
17
|
+
export declare type RejectFn = (error?: Error) => void;
|
|
19
18
|
export declare type UntilCallback<T> = (resolve: ResolveFn<T>, reject: RejectFn, context: Readonly<UntilContext>) => void;
|
|
20
19
|
/**
|
|
21
20
|
* Return a Promise that delegates resolving/rejecting to the passed in function.
|
|
22
21
|
*/
|
|
23
22
|
export declare function until<T>(fn: UntilCallback<T>, options?: UntilOptions): Promise<T>;
|
|
24
|
-
export {};
|
|
25
23
|
//# sourceMappingURL=until.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"until.d.ts","sourceRoot":"","sources":["../../src/until.ts"],"names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GpG"}
|
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.12.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",
|
|
@@ -65,32 +75,37 @@
|
|
|
65
75
|
"postbuild:cjs": "echo '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json",
|
|
66
76
|
"postbuild:mjs": "echo '{\"type\":\"module\"}' > ./dist/mjs/package.json",
|
|
67
77
|
"build": "npm run build:cjs && npm run build:mjs",
|
|
78
|
+
"postbuild": "npm run validate",
|
|
68
79
|
"typecheck": "tsc --noEmit",
|
|
69
80
|
"lint": "eslint ./*.js ./src/ ./test/ --ext .ts --fix",
|
|
70
81
|
"test": "NODE_ENV=test jest",
|
|
71
|
-
"
|
|
82
|
+
"validate": "./bin/validate.cjs",
|
|
83
|
+
"update-keywords": "./bin/update-keywords.mjs",
|
|
84
|
+
"spellcheck": "cspell './{.github,src,test}/**/*.{ts,json}' './*.{md,js}' './package.json' --no-progress",
|
|
72
85
|
"prepublishOnly": "npm run typecheck && npm run spellcheck && npm run lint && npm test && npm run build"
|
|
73
86
|
},
|
|
74
87
|
"dependencies": {
|
|
75
88
|
"lodash.clonedeep": "^4.5.0",
|
|
76
|
-
"lodash.escaperegexp": "^4.1.2"
|
|
89
|
+
"lodash.escaperegexp": "^4.1.2",
|
|
90
|
+
"ts-essentials": "^9.0.0"
|
|
77
91
|
},
|
|
78
92
|
"devDependencies": {
|
|
79
|
-
"@types/jest": "^27.0
|
|
93
|
+
"@types/jest": "^27.4.0",
|
|
80
94
|
"@types/lodash.clonedeep": "^4.5.6",
|
|
81
95
|
"@types/lodash.escaperegexp": "^4.1.6",
|
|
82
|
-
"@types/node": "^17.0.
|
|
83
|
-
"@webdeveric/eslint-config-ts": "^0.4.
|
|
96
|
+
"@types/node": "^17.0.10",
|
|
97
|
+
"@webdeveric/eslint-config-ts": "^0.4.1",
|
|
84
98
|
"core-js": "^3.11.1",
|
|
85
99
|
"cspell": "^5.3.12",
|
|
86
|
-
"eslint": "^8.
|
|
87
|
-
"eslint-
|
|
100
|
+
"eslint": "^8.10.0",
|
|
101
|
+
"eslint-import-resolver-typescript": "^2.5.0",
|
|
102
|
+
"eslint-plugin-import": "^2.25.4",
|
|
103
|
+
"eslint-plugin-jest": "^26.0.0",
|
|
88
104
|
"jest": "^27.3.0",
|
|
89
105
|
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
90
106
|
"rimraf": "^3.0.2",
|
|
91
|
-
"ts-essentials": "^9.0.0",
|
|
92
107
|
"ts-jest": "^27.0.7",
|
|
93
|
-
"ts-node": "^10.
|
|
94
|
-
"typescript": "^4.
|
|
108
|
+
"ts-node": "^10.6.0",
|
|
109
|
+
"typescript": "^4.6.2"
|
|
95
110
|
}
|
|
96
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,16 @@
|
|
|
1
|
+
import type { NumericValue } from './types';
|
|
2
|
+
|
|
3
|
+
export function getMaxValue(...values: NumericValue[]): NumericValue {
|
|
4
|
+
if (values.length === 0) {
|
|
5
|
+
throw new Error('Expected at least one numeric value');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return values.reduce(
|
|
9
|
+
(high: NumericValue, current: NumericValue) => {
|
|
10
|
+
const value = typeof current === 'string' ? Number(current) : current;
|
|
11
|
+
|
|
12
|
+
return value > high ? current : high;
|
|
13
|
+
},
|
|
14
|
+
values[ 0 ],
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { NumericValue } from './types';
|
|
2
|
+
|
|
3
|
+
export function getMinValue(...values: NumericValue[]): NumericValue {
|
|
4
|
+
if (values.length === 0) {
|
|
5
|
+
throw new Error('Expected at least one numeric value');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return values.reduce(
|
|
9
|
+
(low: NumericValue, current: NumericValue) => {
|
|
10
|
+
const value = typeof current === 'string' ? Number(current) : current;
|
|
11
|
+
|
|
12
|
+
return value < low ? current : low;
|
|
13
|
+
},
|
|
14
|
+
values[ 0 ],
|
|
15
|
+
);
|
|
16
|
+
}
|
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