@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.
Files changed (96) hide show
  1. package/dist/cjs/clamp.js +10 -0
  2. package/dist/cjs/clamp.js.map +1 -0
  3. package/dist/cjs/convert.js +19 -0
  4. package/dist/cjs/convert.js.map +1 -0
  5. package/dist/cjs/getMaxValue.js +14 -0
  6. package/dist/cjs/getMaxValue.js.map +1 -0
  7. package/dist/cjs/getMinValue.js +14 -0
  8. package/dist/cjs/getMinValue.js.map +1 -0
  9. package/dist/cjs/getOwnKeys.js +1 -4
  10. package/dist/cjs/getOwnKeys.js.map +1 -1
  11. package/dist/cjs/getOwnProperties.js +11 -0
  12. package/dist/cjs/getOwnProperties.js.map +1 -0
  13. package/dist/cjs/index.js +14 -1
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/isEmpty.js +17 -0
  16. package/dist/cjs/isEmpty.js.map +1 -0
  17. package/dist/cjs/isObject.js +8 -0
  18. package/dist/cjs/isObject.js.map +1 -0
  19. package/dist/cjs/node/index.js +5 -1
  20. package/dist/cjs/node/index.js.map +1 -1
  21. package/dist/cjs/normalize.js +14 -15
  22. package/dist/cjs/normalize.js.map +1 -1
  23. package/dist/cjs/type-assertion.js +16 -0
  24. package/dist/cjs/type-assertion.js.map +1 -0
  25. package/dist/cjs/types.js +3 -0
  26. package/dist/cjs/types.js.map +1 -0
  27. package/dist/cjs/until.js +10 -13
  28. package/dist/cjs/until.js.map +1 -1
  29. package/dist/mjs/clamp.js +6 -0
  30. package/dist/mjs/clamp.js.map +1 -0
  31. package/dist/mjs/compose.js +1 -2
  32. package/dist/mjs/compose.js.map +1 -1
  33. package/dist/mjs/convert.js +15 -0
  34. package/dist/mjs/convert.js.map +1 -0
  35. package/dist/mjs/getMaxValue.js +10 -0
  36. package/dist/mjs/getMaxValue.js.map +1 -0
  37. package/dist/mjs/getMinValue.js +10 -0
  38. package/dist/mjs/getMinValue.js.map +1 -0
  39. package/dist/mjs/getOwnKeys.js +1 -4
  40. package/dist/mjs/getOwnKeys.js.map +1 -1
  41. package/dist/mjs/getOwnProperties.js +7 -0
  42. package/dist/mjs/getOwnProperties.js.map +1 -0
  43. package/dist/mjs/index.js +9 -0
  44. package/dist/mjs/index.js.map +1 -1
  45. package/dist/mjs/isEmpty.js +13 -0
  46. package/dist/mjs/isEmpty.js.map +1 -0
  47. package/dist/mjs/isObject.js +4 -0
  48. package/dist/mjs/isObject.js.map +1 -0
  49. package/dist/mjs/normalize.js +14 -15
  50. package/dist/mjs/normalize.js.map +1 -1
  51. package/dist/mjs/type-assertion.js +11 -0
  52. package/dist/mjs/type-assertion.js.map +1 -0
  53. package/dist/mjs/types.js +2 -0
  54. package/dist/mjs/types.js.map +1 -0
  55. package/dist/mjs/until.js +10 -13
  56. package/dist/mjs/until.js.map +1 -1
  57. package/dist/types/clamp.d.ts +3 -0
  58. package/dist/types/clamp.d.ts.map +1 -0
  59. package/dist/types/convert.d.ts +8 -0
  60. package/dist/types/convert.d.ts.map +1 -0
  61. package/dist/types/getMaxValue.d.ts +3 -0
  62. package/dist/types/getMaxValue.d.ts.map +1 -0
  63. package/dist/types/getMinValue.d.ts +3 -0
  64. package/dist/types/getMinValue.d.ts.map +1 -0
  65. package/dist/types/getOwnKeys.d.ts +1 -1
  66. package/dist/types/getOwnKeys.d.ts.map +1 -1
  67. package/dist/types/getOwnProperties.d.ts +2 -0
  68. package/dist/types/getOwnProperties.d.ts.map +1 -0
  69. package/dist/types/index.d.ts +9 -0
  70. package/dist/types/index.d.ts.map +1 -1
  71. package/dist/types/isEmpty.d.ts +2 -0
  72. package/dist/types/isEmpty.d.ts.map +1 -0
  73. package/dist/types/isObject.d.ts +2 -0
  74. package/dist/types/isObject.d.ts.map +1 -0
  75. package/dist/types/normalize.d.ts +8 -6
  76. package/dist/types/normalize.d.ts.map +1 -1
  77. package/dist/types/type-assertion.d.ts +3 -0
  78. package/dist/types/type-assertion.d.ts.map +1 -0
  79. package/dist/types/types.d.ts +7 -0
  80. package/dist/types/types.d.ts.map +1 -0
  81. package/dist/types/until.d.ts +8 -10
  82. package/dist/types/until.d.ts.map +1 -1
  83. package/package.json +27 -12
  84. package/src/clamp.ts +7 -0
  85. package/src/convert.ts +30 -0
  86. package/src/getMaxValue.ts +16 -0
  87. package/src/getMinValue.ts +16 -0
  88. package/src/getOwnKeys.ts +2 -5
  89. package/src/getOwnProperties.ts +6 -0
  90. package/src/index.ts +9 -0
  91. package/src/isEmpty.ts +15 -0
  92. package/src/isObject.ts +3 -0
  93. package/src/normalize.ts +36 -29
  94. package/src/type-assertion.ts +11 -0
  95. package/src/types.ts +12 -0
  96. 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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -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
- function looksLikeDelay(delay) {
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
- throw new Error('fn must be a function');
10
+ return Promise.reject(new Error('fn must be a function'));
16
11
  }
17
12
  if (!options || typeof options !== 'object') {
18
- throw new Error(`invalid options: ${JSON.stringify(options)}`);
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
- if (!looksLikeDelay(delay)) {
22
- throw new Error('invalid delay value');
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 && !looksLikeDelay(timeout)) {
25
- throw new Error('invalid timeout value');
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
- throw new Error('invalid callLimit value');
25
+ return Promise.reject(new Error('invalid callLimit value'));
29
26
  }
30
27
  return new Promise((resolutionFn, rejectionFn) => {
31
28
  let callCount = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"until.js","sourceRoot":"","sources":["../../src/until.ts"],"names":[],"mappings":"AA6BA,SAAS,cAAc,CAAE,KAAc;IAErC,OAAO,MAAM,CAAC,SAAS,CAAE,KAAK,CAAE,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC;AAClE,CAAC;A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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,3 @@
1
+ import type { NumericValue } from './types';
2
+ export declare function clamp(min: NumericValue, value: NumericValue, max: NumericValue): NumericValue;
3
+ //# sourceMappingURL=clamp.d.ts.map
@@ -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,3 @@
1
+ import type { NumericValue } from './types';
2
+ export declare function getMaxValue(...values: NumericValue[]): NumericValue;
3
+ //# sourceMappingURL=getMaxValue.d.ts.map
@@ -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,3 @@
1
+ import type { NumericValue } from './types';
2
+ export declare function getMinValue(...values: NumericValue[]): NumericValue;
3
+ //# sourceMappingURL=getMinValue.d.ts.map
@@ -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,CAK7D"}
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,2 @@
1
+ export declare function getOwnProperties<T, K extends keyof T>(data: T): K[];
2
+ //# sourceMappingURL=getOwnProperties.d.ts.map
@@ -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"}
@@ -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,2 @@
1
+ export declare function isEmpty(input: unknown): boolean;
2
+ //# sourceMappingURL=isEmpty.d.ts.map
@@ -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,2 @@
1
+ export declare function isObject(input: unknown): boolean;
2
+ //# sourceMappingURL=isObject.d.ts.map
@@ -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
- export declare type NormalizeContext<OwnerRecordType> = {
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: Record<PropertyKey, unknown>;
6
+ data: ContextData;
6
7
  };
7
- export declare type NormalizerFn<OutputType, OwnerRecordType> = (input: unknown, context: NormalizeContext<OwnerRecordType>) => OutputType;
8
- export declare type NormalizersRecord<RecordType, OwnerRecordType = RecordType> = {
9
- [Property in keyof RecordType]?: RecordType[Property] extends Builtin ? NormalizerFn<RecordType[Property], OwnerRecordType> : NormalizerFn<RecordType[Property], OwnerRecordType> | NormalizersRecord<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, normalizers?: NormalizerFn<Data, Data> | NormalizersRecord<Data, Data>): 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;IAC9C,QAAQ,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IACpC,OAAO,EAAE,eAAe,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,oBAAY,YAAY,CAAC,UAAU,EAAE,eAAe,IAAI,CACtD,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,gBAAgB,CAAC,eAAe,CAAC,KACvC,UAAU,CAAC;AAEhB,oBAAY,iBAAiB,CAAC,UAAU,EAAE,eAAe,GAAG,UAAU,IAAI;KACvE,QAAQ,IAAI,MAAM,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,SAA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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,3 @@
1
+ export declare function assertsIsInteger(input: unknown): asserts input is number;
2
+ export declare function assertsIsFiniteNumber(input: unknown): asserts input is number;
3
+ //# 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":"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"}
@@ -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: Record<string, any>;
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 interface UntilContext {
14
- options: UntilOptions;
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":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B;AAED,aAAK,OAAO,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,KAAK,MAAM,CAAC;AAE3D,aAAK,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9B,oBAAY,YAAY,GAAG;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,aAAK,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAE3C,aAAK,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAEtD,aAAK,QAAQ,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;AAExC,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,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O,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.9.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
- "spellcheck": "cspell './{.github,src,test}/**/*.{ts,json}' './*.{md,js}' './package.json'",
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.2",
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.9",
83
- "@webdeveric/eslint-config-ts": "^0.4.0",
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.0.0",
87
- "eslint-plugin-jest": "^25.2.1",
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.0.0",
94
- "typescript": "^4.5.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
  }
@@ -0,0 +1,6 @@
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[];
6
+ }
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
+ }
@@ -0,0 +1,3 @@
1
+ export function isObject(input: unknown): boolean {
2
+ return typeof input === 'object' && input !== null;
3
+ }