@webdeveric/utils 0.12.0 → 0.14.1
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/asArray.js.map +1 -1
- package/dist/cjs/convert.js.map +1 -1
- package/dist/cjs/delay.js.map +1 -1
- package/dist/cjs/delayAnimationFrame.js.map +1 -1
- package/dist/cjs/getMaxValue.js +3 -1
- package/dist/cjs/getMaxValue.js.map +1 -1
- package/dist/cjs/getMinValue.js +3 -1
- package/dist/cjs/getMinValue.js.map +1 -1
- package/dist/cjs/getOwnProperties.js +1 -4
- package/dist/cjs/getOwnProperties.js.map +1 -1
- package/dist/cjs/isEmpty.js +5 -1
- package/dist/cjs/isEmpty.js.map +1 -1
- package/dist/cjs/node/fcrdns.js.map +1 -1
- package/dist/cjs/normalize.js +0 -15
- package/dist/cjs/normalize.js.map +1 -1
- package/dist/cjs/secToString.js.map +1 -1
- package/dist/cjs/toPascalCase.js +3 -6
- package/dist/cjs/toPascalCase.js.map +1 -1
- package/dist/cjs/type-assertion.js +12 -5
- package/dist/cjs/type-assertion.js.map +1 -1
- package/dist/cjs/type-predicate.js +32 -0
- package/dist/cjs/type-predicate.js.map +1 -0
- package/dist/cjs/uniqueItems.js.map +1 -1
- package/dist/cjs/until.js +9 -8
- package/dist/cjs/until.js.map +1 -1
- package/dist/mjs/asArray.js.map +1 -1
- package/dist/mjs/convert.js.map +1 -1
- package/dist/mjs/delay.js.map +1 -1
- package/dist/mjs/delayAnimationFrame.js.map +1 -1
- package/dist/mjs/getMaxValue.js +3 -1
- package/dist/mjs/getMaxValue.js.map +1 -1
- package/dist/mjs/getMinValue.js +3 -1
- package/dist/mjs/getMinValue.js.map +1 -1
- package/dist/mjs/getOwnProperties.js +1 -4
- package/dist/mjs/getOwnProperties.js.map +1 -1
- package/dist/mjs/isEmpty.js +5 -1
- package/dist/mjs/isEmpty.js.map +1 -1
- package/dist/mjs/node/fcrdns.js.map +1 -1
- package/dist/mjs/normalize.js +0 -15
- package/dist/mjs/normalize.js.map +1 -1
- package/dist/mjs/secToString.js.map +1 -1
- package/dist/mjs/toPascalCase.js +3 -6
- package/dist/mjs/toPascalCase.js.map +1 -1
- package/dist/mjs/type-assertion.js +8 -2
- package/dist/mjs/type-assertion.js.map +1 -1
- package/dist/mjs/type-predicate.js +16 -0
- package/dist/mjs/type-predicate.js.map +1 -0
- package/dist/mjs/uniqueItems.js.map +1 -1
- package/dist/mjs/until.js +5 -5
- package/dist/mjs/until.js.map +1 -1
- package/dist/types/asArray.d.ts.map +1 -1
- package/dist/types/delay.d.ts.map +1 -1
- package/dist/types/delayAnimationFrame.d.ts.map +1 -1
- package/dist/types/getMaxValue.d.ts +1 -1
- package/dist/types/getMaxValue.d.ts.map +1 -1
- package/dist/types/getMinValue.d.ts +1 -1
- package/dist/types/getMinValue.d.ts.map +1 -1
- package/dist/types/getOwnProperties.d.ts.map +1 -1
- package/dist/types/isEmpty.d.ts.map +1 -1
- package/dist/types/node/fcrdns.d.ts.map +1 -1
- package/dist/types/normalize.d.ts +4 -2
- package/dist/types/normalize.d.ts.map +1 -1
- package/dist/types/secToString.d.ts.map +1 -1
- package/dist/types/toPascalCase.d.ts.map +1 -1
- package/dist/types/type-assertion.d.ts +4 -2
- package/dist/types/type-assertion.d.ts.map +1 -1
- package/dist/types/type-predicate.d.ts +17 -0
- package/dist/types/type-predicate.d.ts.map +1 -0
- package/dist/types/types.d.ts +3 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/uniqueItems.d.ts.map +1 -1
- package/dist/types/until.d.ts +2 -1
- package/dist/types/until.d.ts.map +1 -1
- package/package.json +27 -10
- package/readme.md +1 -1
- package/src/asArray.ts +2 -3
- package/src/convert.ts +1 -1
- package/src/delay.ts +6 -7
- package/src/delayAnimationFrame.ts +6 -8
- package/src/getMaxValue.ts +8 -8
- package/src/getMinValue.ts +8 -8
- package/src/getOwnProperties.ts +1 -4
- package/src/isEmpty.ts +8 -2
- package/src/node/fcrdns.ts +10 -16
- package/src/normalize.ts +27 -10
- package/src/secToString.ts +19 -22
- package/src/toPascalCase.ts +11 -15
- package/src/type-assertion.ts +13 -4
- package/src/type-predicate.ts +36 -0
- package/src/types.ts +7 -0
- package/src/uniqueItems.ts +2 -3
- package/src/until.ts +35 -38
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export const isLengthAware = (input) =>
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
typeof input === 'object' && input !== null && 'length' in input && typeof input.length === 'number';
|
|
16
|
+
//# 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,CA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AAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAEvH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAEtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAErG,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAE/G,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAA+B,EAAE;AAC3E,8DAA8D;AAC9D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK,IAAI,OAAQ,KAAa,CAAC,MAAM,KAAK,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniqueItems.js","sourceRoot":"","sources":["../../src/uniqueItems.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,
|
|
1
|
+
{"version":3,"file":"uniqueItems.js","sourceRoot":"","sources":["../../src/uniqueItems.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAI,IAAS;IACtC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAI,IAAI,CAAC,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/mjs/until.js
CHANGED
|
@@ -2,6 +2,7 @@ import { getType } from './getType.js';
|
|
|
2
2
|
const defaultOptions = {
|
|
3
3
|
delay: 10,
|
|
4
4
|
};
|
|
5
|
+
export const isDelay = (input) => Number.isInteger(input) || typeof input === 'function';
|
|
5
6
|
/**
|
|
6
7
|
* Return a Promise that delegates resolving/rejecting to the passed in function.
|
|
7
8
|
*/
|
|
@@ -10,19 +11,18 @@ export function until(fn, options = defaultOptions) {
|
|
|
10
11
|
return Promise.reject(new Error('fn must be a function'));
|
|
11
12
|
}
|
|
12
13
|
if (!options || typeof options !== 'object') {
|
|
13
|
-
return Promise.reject(new
|
|
14
|
+
return Promise.reject(new TypeError(`options must be an object. ${getType(options)} provided.`));
|
|
14
15
|
}
|
|
15
16
|
const { delay, timeout, callLimit } = Object.assign({}, defaultOptions, options);
|
|
16
|
-
const isDelay = (input) => Number.isInteger(input) || typeof input === 'function';
|
|
17
17
|
const getDelay = (delay, context) => typeof delay === 'function' ? delay(context) : delay;
|
|
18
18
|
if (!isDelay(delay)) {
|
|
19
|
-
return Promise.reject(new
|
|
19
|
+
return Promise.reject(new TypeError('invalid delay value'));
|
|
20
20
|
}
|
|
21
21
|
if (timeout !== undefined && !isDelay(timeout)) {
|
|
22
|
-
return Promise.reject(new
|
|
22
|
+
return Promise.reject(new TypeError('invalid timeout value'));
|
|
23
23
|
}
|
|
24
24
|
if (callLimit !== undefined && !Number.isInteger(callLimit)) {
|
|
25
|
-
return Promise.reject(new
|
|
25
|
+
return Promise.reject(new TypeError('invalid callLimit value'));
|
|
26
26
|
}
|
|
27
27
|
return new Promise((resolutionFn, rejectionFn) => {
|
|
28
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":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AA2BvC,MAAM,cAAc,GAA2B;IAC7C,KAAK,EAAE,EAAE;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,KAAK,
|
|
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,MAAM,CAAC,MAAM,OAAO,GAA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C;gBAE7B,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBAEtB,IAAI,CAAC,IAAI,EAAE;oBACT,KAAK,GAAG,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;iBACzF;aACF;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC;aAChE;QACH,CAAC,CAAC;QAEF,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAE1C,IAAI,CAAC,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE;YAClC,YAAY,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC7B,MAAM,CAAC,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;YACxC,CAAC,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;SAChC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asArray.d.ts","sourceRoot":"","sources":["../../src/asArray.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"asArray.d.ts","sourceRoot":"","sources":["../../src/asArray.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAE7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../../src/delay.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../../src/delay.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAUpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delayAnimationFrame.d.ts","sourceRoot":"","sources":["../../src/delayAnimationFrame.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"delayAnimationFrame.d.ts","sourceRoot":"","sources":["../../src/delayAnimationFrame.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,KAAK,CAAC,CAIvE;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,KAAK,CAAC,CAoBxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMaxValue.d.ts","sourceRoot":"","sources":["../../src/getMaxValue.ts"],"names":[],"mappings":"
|
|
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,CAYtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMinValue.d.ts","sourceRoot":"","sources":["../../src/getMinValue.ts"],"names":[],"mappings":"
|
|
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,CAYtF"}
|
|
@@ -1 +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,
|
|
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,CAEnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEmpty.d.ts","sourceRoot":"","sources":["../../src/isEmpty.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isEmpty.d.ts","sourceRoot":"","sources":["../../src/isEmpty.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAkB/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fcrdns.d.ts","sourceRoot":"","sources":["../../../src/node/fcrdns.ts"],"names":[],"mappings":"AAGA,wBAAsB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"fcrdns.d.ts","sourceRoot":"","sources":["../../../src/node/fcrdns.ts"],"names":[],"mappings":"AAGA,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAYzF;AAED;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAc3E"}
|
|
@@ -5,11 +5,12 @@ export declare type NormalizeContext<OwnerRecordType, ContextData extends AnyRec
|
|
|
5
5
|
current: OwnerRecordType;
|
|
6
6
|
data: ContextData;
|
|
7
7
|
};
|
|
8
|
-
export declare type NormalizerFn<PropertyType, OwnerRecordType, ContextData extends AnyRecord = AnyRecord> = (input: PropertyType, context: NormalizeContext<OwnerRecordType, ContextData>) => PropertyType;
|
|
8
|
+
export declare type NormalizerFn<PropertyType, OwnerRecordType = unknown, ContextData extends AnyRecord = AnyRecord> = (input: PropertyType, context: NormalizeContext<OwnerRecordType, ContextData>) => PropertyType;
|
|
9
9
|
export declare type NormalizersRecord<RecordType, OwnerRecordType, ContextData extends AnyRecord = AnyRecord> = {
|
|
10
10
|
readonly [Property in keyof RecordType]?: RecordType[Property] extends Builtin ? NormalizerFn<RecordType[Property], OwnerRecordType, ContextData> : AnyNormalizer<RecordType[Property], OwnerRecordType, ContextData>;
|
|
11
11
|
};
|
|
12
12
|
export declare type AnyNormalizer<RecordType, OwnerRecordType, ContextData extends AnyRecord = AnyRecord> = NormalizerFn<RecordType, OwnerRecordType, ContextData> | NormalizersRecord<RecordType, OwnerRecordType, ContextData>;
|
|
13
|
+
export declare type ContextInitializer<OwnerRecordType, ContextData extends AnyRecord = AnyRecord> = (data: OwnerRecordType, normalizers: AnyNormalizer<OwnerRecordType, OwnerRecordType, ContextData>) => ContextData;
|
|
13
14
|
/**
|
|
14
15
|
* @example
|
|
15
16
|
*
|
|
@@ -25,5 +26,6 @@ export declare type AnyNormalizer<RecordType, OwnerRecordType, ContextData exten
|
|
|
25
26
|
* normalize(true, () => false );
|
|
26
27
|
* ```
|
|
27
28
|
*/
|
|
28
|
-
export declare function normalize<Data, ContextData extends AnyRecord = AnyRecord>(input: Readonly<Data>, normalizers
|
|
29
|
+
export declare function normalize<Data, ContextData extends AnyRecord = AnyRecord>(input: Readonly<Data>, normalizers: AnyNormalizer<Data, Data, Partial<ContextData>>): Data;
|
|
30
|
+
export declare function normalize<Data, ContextData extends AnyRecord = AnyRecord>(input: Readonly<Data>, normalizers: AnyNormalizer<Data, Data, ContextData>, initContextData: ContextInitializer<Data, ContextData>): Data;
|
|
29
31
|
//# 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,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,
|
|
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,GAAG,OAAO,EAAE,WAAW,SAAS,SAA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AC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,EACnD,eAAe,EAAE,kBAAkB,CAAC,IAAI,EAAE,WAAW,CAAC,GACrD,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secToString.d.ts","sourceRoot":"","sources":["../../src/secToString.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO;IACjB,MAAM,IAAI;IACV,MAAM,KAAc;IACpB,IAAI,OAAc;IAClB,GAAG,QAAY;IACf,IAAI,SAAU;IACd,KAAK,UAAsB;IAC3B,IAAI,WAAa;IACjB,MAAM,YAAY;IAClB,OAAO,aAAc;IACrB,UAAU,cAAe;CAC1B;AAID,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,SAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"secToString.d.ts","sourceRoot":"","sources":["../../src/secToString.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO;IACjB,MAAM,IAAI;IACV,MAAM,KAAc;IACpB,IAAI,OAAc;IAClB,GAAG,QAAY;IACf,IAAI,SAAU;IACd,KAAK,UAAsB;IAC3B,IAAI,WAAa;IACjB,MAAM,YAAY;IAClB,OAAO,aAAc;IACrB,UAAU,cAAe;CAC1B;AAID,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,SAAM,GAAG,MAAM,CA6BlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toPascalCase.d.ts","sourceRoot":"","sources":["../../src/toPascalCase.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"toPascalCase.d.ts","sourceRoot":"","sources":["../../src/toPascalCase.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAoCvF"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
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[];
|
|
3
5
|
//# sourceMappingURL=type-assertion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-assertion.d.ts","sourceRoot":"","sources":["../../src/type-assertion.ts"],"names":[],"mappings":"
|
|
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,17 @@
|
|
|
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
|
+
export declare const isLengthAware: (input: unknown) => input is {
|
|
15
|
+
length: number;
|
|
16
|
+
};
|
|
17
|
+
//# 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,gCACsC,CAAC;AAEtF,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;AAE/G,eAAO,MAAM,aAAa,UAAW,OAAO;YAAsB,MAAM;CAEuC,CAAC"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -4,4 +4,7 @@ export declare type NumericString<T extends string | number = number> = `${T}` e
|
|
|
4
4
|
export declare type NumericValue = number | bigint | NumericString;
|
|
5
5
|
export declare type MaybePlural<T extends string> = T | `${T}s`;
|
|
6
6
|
export declare type StringKeys<T> = keyof T & string;
|
|
7
|
+
export declare type IfDefined<T, D, U> = undefined extends T ? U : D;
|
|
8
|
+
export declare type IfNever<T, N, O> = [T] extends [never] ? N : O;
|
|
9
|
+
export declare type ReturnTypeDefault<F, D = undefined> = F extends (...args: any) => infer R ? R : D;
|
|
7
10
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +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"}
|
|
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;AAE7C,oBAAY,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,SAAS,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE7D,oBAAY,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAG3D,oBAAY,iBAAiB,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniqueItems.d.ts","sourceRoot":"","sources":["../../src/uniqueItems.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"uniqueItems.d.ts","sourceRoot":"","sources":["../../src/uniqueItems.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAE7C"}
|
package/dist/types/until.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnyRecord } from './types';
|
|
2
2
|
export interface UntilContext {
|
|
3
3
|
callCount: number;
|
|
4
|
-
lastCall
|
|
4
|
+
lastCall: number | undefined;
|
|
5
5
|
data: AnyRecord;
|
|
6
6
|
options: UntilOptions;
|
|
7
7
|
}
|
|
@@ -16,6 +16,7 @@ export declare type ResolverValue<T> = T | PromiseLike<T>;
|
|
|
16
16
|
export declare type ResolveFn<T> = (value: ResolverValue<T>) => void;
|
|
17
17
|
export declare type RejectFn = (error?: Error) => void;
|
|
18
18
|
export declare type UntilCallback<T> = (resolve: ResolveFn<T>, reject: RejectFn, context: Readonly<UntilContext>) => void;
|
|
19
|
+
export declare const isDelay: (input: unknown) => input is Delay;
|
|
19
20
|
/**
|
|
20
21
|
* Return a Promise that delegates resolving/rejecting to the passed in function.
|
|
21
22
|
*/
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,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,eAAO,MAAM,OAAO,UAAW,OAAO,mBAA2E,CAAC;AAElH;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,GAAE,YAA6B,GAAG,OAAO,CAAC,CAAC,CAAC,CA4FjG"}
|
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.14.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"trimEnd",
|
|
30
30
|
"trimStart",
|
|
31
31
|
"type-assertion",
|
|
32
|
-
"
|
|
32
|
+
"type-predicate",
|
|
33
33
|
"uniqueItems",
|
|
34
34
|
"until"
|
|
35
35
|
],
|
|
@@ -77,12 +77,22 @@
|
|
|
77
77
|
"build": "npm run build:cjs && npm run build:mjs",
|
|
78
78
|
"postbuild": "npm run validate",
|
|
79
79
|
"typecheck": "tsc --noEmit",
|
|
80
|
-
"lint": "eslint ./*.js ./src/ ./test/ --ext .ts
|
|
80
|
+
"lint": "eslint ./*.js ./bin/ ./src/ ./test/ --ext .ts,.mjs,.cjs",
|
|
81
81
|
"test": "NODE_ENV=test jest",
|
|
82
82
|
"validate": "./bin/validate.cjs",
|
|
83
83
|
"update-keywords": "./bin/update-keywords.mjs",
|
|
84
84
|
"spellcheck": "cspell './{.github,src,test}/**/*.{ts,json}' './*.{md,js}' './package.json' --no-progress",
|
|
85
|
-
"prepublishOnly": "npm run typecheck && npm run spellcheck && npm run lint && npm test && npm run build"
|
|
85
|
+
"prepublishOnly": "npm run typecheck && npm run spellcheck && npm run lint && npm test && npm run build",
|
|
86
|
+
"format": "prettier --write ./*.{js,json,md} ./bin/ ./src/ ./test/",
|
|
87
|
+
"prepare": "husky install"
|
|
88
|
+
},
|
|
89
|
+
"prettier": "@webdeveric/prettier-config",
|
|
90
|
+
"lint-staged": {
|
|
91
|
+
"*.{js,ts}": "eslint --fix",
|
|
92
|
+
"*.{ts,js,json,md}": [
|
|
93
|
+
"cspell lint --no-progress --no-summary --no-must-find-files",
|
|
94
|
+
"prettier --write"
|
|
95
|
+
]
|
|
86
96
|
},
|
|
87
97
|
"dependencies": {
|
|
88
98
|
"lodash.clonedeep": "^4.5.0",
|
|
@@ -90,22 +100,29 @@
|
|
|
90
100
|
"ts-essentials": "^9.0.0"
|
|
91
101
|
},
|
|
92
102
|
"devDependencies": {
|
|
93
|
-
"@types/jest": "^
|
|
103
|
+
"@types/jest": "^28.1.1",
|
|
94
104
|
"@types/lodash.clonedeep": "^4.5.6",
|
|
95
105
|
"@types/lodash.escaperegexp": "^4.1.6",
|
|
96
106
|
"@types/node": "^17.0.10",
|
|
97
|
-
"@webdeveric/eslint-config-ts": "^0.
|
|
107
|
+
"@webdeveric/eslint-config-ts": "^0.5.2",
|
|
108
|
+
"@webdeveric/prettier-config": "^0.2.0",
|
|
98
109
|
"core-js": "^3.11.1",
|
|
99
|
-
"cspell": "^
|
|
110
|
+
"cspell": "^6.1.0",
|
|
100
111
|
"eslint": "^8.10.0",
|
|
112
|
+
"eslint-config-prettier": "^8.5.0",
|
|
101
113
|
"eslint-import-resolver-typescript": "^2.5.0",
|
|
102
114
|
"eslint-plugin-import": "^2.25.4",
|
|
103
115
|
"eslint-plugin-jest": "^26.0.0",
|
|
104
|
-
"
|
|
116
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
117
|
+
"husky": "^8.0.1",
|
|
118
|
+
"jest": "^28.1.0",
|
|
119
|
+
"jest-environment-jsdom": "^28.1.0",
|
|
105
120
|
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
121
|
+
"lint-staged": "^13.0.0",
|
|
122
|
+
"prettier": "^2.6.2",
|
|
106
123
|
"rimraf": "^3.0.2",
|
|
107
|
-
"ts-jest": "^
|
|
124
|
+
"ts-jest": "^28.0.3",
|
|
108
125
|
"ts-node": "^10.6.0",
|
|
109
|
-
"typescript": "^4.
|
|
126
|
+
"typescript": "^4.7.3"
|
|
110
127
|
}
|
|
111
128
|
}
|
package/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @webdeveric/utils
|
|
2
2
|
|
|
3
|
-
[](https://github.com/webdeveric/utils/actions/workflows/node.js.yml) [](https://github.com/webdeveric/utils/actions/workflows/codeql-analysis.yml)
|
|
4
4
|
|
|
5
5
|
```shell
|
|
6
6
|
npm i @webdeveric/utils --save
|
package/src/asArray.ts
CHANGED
package/src/convert.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const convert = <Input, Output>(input: Readonly<Input>, converter: AnyCon
|
|
|
20
20
|
|
|
21
21
|
if (typeof converter === 'object' && converter !== null) {
|
|
22
22
|
return getOwnProperties(converter).reduce<Partial<Output>>((data, key) => {
|
|
23
|
-
data[
|
|
23
|
+
data[key] = convert(input, converter[key]);
|
|
24
24
|
|
|
25
25
|
return data;
|
|
26
26
|
}, {}) as Output;
|
package/src/delay.ts
CHANGED
|
@@ -6,15 +6,14 @@ import { getType } from './getType.js';
|
|
|
6
6
|
*
|
|
7
7
|
* {@link https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value}
|
|
8
8
|
*/
|
|
9
|
-
export function delay<T>(milliseconds: number, value?: T)
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
reject( new TypeError(`milliseconds must be a number. ${getType(milliseconds)} was provided.`) );
|
|
9
|
+
export function delay<T>(milliseconds: number, value?: T): Promise<T> {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
if (typeof milliseconds !== 'number') {
|
|
12
|
+
reject(new TypeError(`milliseconds must be a number. ${getType(milliseconds)} was provided.`));
|
|
14
13
|
|
|
15
14
|
return;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
setTimeout(
|
|
19
|
-
}
|
|
17
|
+
setTimeout(resolve, Math.max(0, Math.min(milliseconds, 2_147_483_647)), value);
|
|
18
|
+
});
|
|
20
19
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
export function delayAnimationFrame<T>(value?: T)
|
|
2
|
-
{
|
|
1
|
+
export function delayAnimationFrame<T>(value?: T): Promise<typeof value> {
|
|
3
2
|
return new Promise(resolve => {
|
|
4
|
-
window.requestAnimationFrame(
|
|
3
|
+
window.requestAnimationFrame(() => resolve(value));
|
|
5
4
|
});
|
|
6
5
|
}
|
|
7
6
|
|
|
8
|
-
export function delayAnimationFrames<T>(frames: number, value?: T): Promise<typeof value>
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
reject( new TypeError('frames must be a positive integer') );
|
|
7
|
+
export function delayAnimationFrames<T>(frames: number, value?: T): Promise<typeof value> {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
if (!Number.isInteger(frames) || frames < 1) {
|
|
10
|
+
reject(new TypeError('frames must be a positive integer'));
|
|
13
11
|
|
|
14
12
|
return;
|
|
15
13
|
}
|
package/src/getMaxValue.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { assertIsNumericValueArray } from './type-assertion.js';
|
|
1
2
|
import type { NumericValue } from './types';
|
|
2
3
|
|
|
3
|
-
export function getMaxValue(...values: NumericValue[]): NumericValue {
|
|
4
|
+
export function getMaxValue(...values: [NumericValue, ...NumericValue[]]): NumericValue {
|
|
4
5
|
if (values.length === 0) {
|
|
5
6
|
throw new Error('Expected at least one numeric value');
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
(high: NumericValue, current: NumericValue) => {
|
|
10
|
-
const value = typeof current === 'string' ? Number(current) : current;
|
|
9
|
+
assertIsNumericValueArray(values);
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
return values.reduce((high, current) => {
|
|
12
|
+
const value = typeof current === 'string' ? Number(current) : current;
|
|
13
|
+
|
|
14
|
+
return value > high ? current : high;
|
|
15
|
+
});
|
|
16
16
|
}
|
package/src/getMinValue.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { assertIsNumericValueArray } from './type-assertion.js';
|
|
1
2
|
import type { NumericValue } from './types';
|
|
2
3
|
|
|
3
|
-
export function getMinValue(...values: NumericValue[]): NumericValue {
|
|
4
|
+
export function getMinValue(...values: [NumericValue, ...NumericValue[]]): NumericValue {
|
|
4
5
|
if (values.length === 0) {
|
|
5
6
|
throw new Error('Expected at least one numeric value');
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
(low: NumericValue, current: NumericValue) => {
|
|
10
|
-
const value = typeof current === 'string' ? Number(current) : current;
|
|
9
|
+
assertIsNumericValueArray(values);
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
return values.reduce((low, current) => {
|
|
12
|
+
const value = typeof current === 'string' ? Number(current) : current;
|
|
13
|
+
|
|
14
|
+
return value < low ? current : low;
|
|
15
|
+
});
|
|
16
16
|
}
|
package/src/getOwnProperties.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
export function getOwnProperties<T, K extends keyof T>(data: T): K[] {
|
|
2
|
-
return [
|
|
3
|
-
...Object.getOwnPropertyNames(data),
|
|
4
|
-
...Object.getOwnPropertySymbols(data),
|
|
5
|
-
] as K[];
|
|
2
|
+
return [...Object.getOwnPropertyNames(data), ...Object.getOwnPropertySymbols(data)] as K[];
|
|
6
3
|
}
|
package/src/isEmpty.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { isLengthAware } from './type-predicate.js';
|
|
2
|
+
|
|
1
3
|
export function isEmpty(input: unknown): boolean {
|
|
2
|
-
if (typeof input === 'undefined' || input === null || (typeof input === 'string' && !
|
|
4
|
+
if (typeof input === 'undefined' || input === null || (typeof input === 'string' && !input.length)) {
|
|
3
5
|
return true;
|
|
4
6
|
}
|
|
5
7
|
|
|
@@ -7,8 +9,12 @@ export function isEmpty(input: unknown): boolean {
|
|
|
7
9
|
return input.length === 0;
|
|
8
10
|
}
|
|
9
11
|
|
|
12
|
+
if (input instanceof Set || input instanceof Map) {
|
|
13
|
+
return input.size === 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
if (typeof input === 'object') {
|
|
11
|
-
return Object.keys(input).length === 0;
|
|
17
|
+
return isLengthAware(input) ? input.length === 0 : Object.keys(input).length === 0;
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
return false;
|
package/src/node/fcrdns.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { promises as dns } from 'node:dns';
|
|
2
2
|
import { isIP } from 'node:net';
|
|
3
3
|
|
|
4
|
-
export async function hostnameResolvesToIp(
|
|
5
|
-
|
|
6
|
-
const ipVersion = isIP( ip );
|
|
4
|
+
export async function hostnameResolvesToIp(hostname: string, ip: string): Promise<boolean> {
|
|
5
|
+
const ipVersion = isIP(ip);
|
|
7
6
|
|
|
8
|
-
if (
|
|
7
|
+
if (!ipVersion) {
|
|
9
8
|
throw new Error(`Invalid IP: ${ip}`);
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
const resolve = ipVersion === 4 ? dns.resolve4 : dns.resolve6;
|
|
13
12
|
|
|
14
|
-
const resolved = await resolve(
|
|
13
|
+
const resolved = await resolve(hostname);
|
|
15
14
|
|
|
16
|
-
return resolved.some(
|
|
15
|
+
return resolved.some(addr => addr === ip);
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
/**
|
|
@@ -21,23 +20,18 @@ export async function hostnameResolvesToIp( hostname: string, ip: string ) : Pro
|
|
|
21
20
|
*
|
|
22
21
|
* @see https://en.wikipedia.org/wiki/Forward-confirmed_reverse_DNS
|
|
23
22
|
*/
|
|
24
|
-
export async function fcrdns(
|
|
25
|
-
{
|
|
23
|
+
export async function fcrdns(hostname: string, ip: string): Promise<boolean> {
|
|
26
24
|
const hostnames = await dns.reverse(ip);
|
|
27
25
|
|
|
28
|
-
if (
|
|
26
|
+
if (!hostnames.length) {
|
|
29
27
|
throw new Error(`Unable to get hostnames for ${ip}`);
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
if (
|
|
30
|
+
if (!hostnames.every(name => name.endsWith(hostname))) {
|
|
33
31
|
throw new Error(`${ip} does not belong to ${hostname}`);
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
const results = await Promise.all(
|
|
37
|
-
hostnames.map(
|
|
38
|
-
name => hostnameResolvesToIp( name, ip ),
|
|
39
|
-
),
|
|
40
|
-
);
|
|
34
|
+
const results = await Promise.all(hostnames.map(name => hostnameResolvesToIp(name, ip)));
|
|
41
35
|
|
|
42
|
-
return results.some(
|
|
36
|
+
return results.some(val => val);
|
|
43
37
|
}
|