ts-data-forge 6.2.2 → 6.3.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 (34) hide show
  1. package/dist/entry-point.mjs +1 -0
  2. package/dist/entry-point.mjs.map +1 -1
  3. package/dist/functional/optional/impl/optional-expect-to-be.d.mts +5 -1
  4. package/dist/functional/optional/impl/optional-expect-to-be.d.mts.map +1 -1
  5. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  6. package/dist/functional/result/impl/result-expect-to-be.d.mts +5 -1
  7. package/dist/functional/result/impl/result-expect-to-be.d.mts.map +1 -1
  8. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  9. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts +5 -4
  10. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts.map +1 -1
  11. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  12. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts +5 -4
  13. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -1
  14. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +5 -4
  15. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  16. package/dist/index.mjs +1 -0
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/others/debounce-function.d.mts +11 -0
  19. package/dist/others/debounce-function.d.mts.map +1 -0
  20. package/dist/others/debounce-function.mjs +21 -0
  21. package/dist/others/debounce-function.mjs.map +1 -0
  22. package/dist/others/index.d.mts +1 -0
  23. package/dist/others/index.d.mts.map +1 -1
  24. package/dist/others/index.mjs +1 -0
  25. package/dist/others/index.mjs.map +1 -1
  26. package/package.json +15 -15
  27. package/src/array/impl/array-utils-creation.test.mts +4 -2
  28. package/src/functional/optional/impl/optional-expect-to-be.mts +5 -1
  29. package/src/functional/result/impl/result-expect-to-be.mts +5 -1
  30. package/src/functional/ternary-result/impl/ternary-result-expect-to-be.mts +5 -4
  31. package/src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts +5 -4
  32. package/src/others/debounce-function.mts +23 -0
  33. package/src/others/debounce-function.test.mts +81 -0
  34. package/src/others/index.mts +1 -0
@@ -57,6 +57,7 @@ export { TsDataForgeInternals } from './number/refined-number-utils.mjs';
57
57
  export { Obj } from './object/object.mjs';
58
58
  export { castDeepMutable, castMutable } from './others/cast-mutable.mjs';
59
59
  export { castDeepReadonly, castReadonly } from './others/cast-readonly.mjs';
60
+ export { debounce } from './others/debounce-function.mjs';
60
61
  export { ifThen } from './others/if-then.mjs';
61
62
  export { mapNullable } from './others/map-nullable.mjs';
62
63
  export { memoizeFunction } from './others/memoize-function.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"entry-point.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"entry-point.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -14,7 +14,11 @@ import { type Unwrap } from './types.mjs';
14
14
  *
15
15
  * const expectValue = Optional.expectToBe<string>('missing optional');
16
16
  *
17
- * assert.throws(() => expectValue(Optional.none), /missing optional/u);
17
+ * const throwTest = (): void => {
18
+ * expectValue(Optional.none);
19
+ * };
20
+ *
21
+ * assert.throws(throwTest, /missing optional/u);
18
22
  *
19
23
  * assert.isTrue(expectValue(Optional.some('present')) === 'present');
20
24
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"optional-expect-to-be.d.mts","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-expect-to-be.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,eAAe,EAClD,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,MAAM,GACd,MAAM,CAAC,CAAC,CAAC,CAAC;AAGb,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"optional-expect-to-be.d.mts","sourceRoot":"","sources":["../../../../src/functional/optional/impl/optional-expect-to-be.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,eAAe,EAClD,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,MAAM,GACd,MAAM,CAAC,CAAC,CAAC,CAAC;AAGb,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"optional-expect-to-be.mjs","sources":["../../../../src/functional/optional/impl/optional-expect-to-be.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAwCM,SAAU,UAAU,CACxB,GAAG,IAA0E,EAAA;AAE7E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,IAAI;AAEhC,YAAA,OAAO,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC1C;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI;YAEtB,OAAO,CAAC,QAA6B,KACnC,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC;QACrC;;AAEJ;AAEA,MAAM,cAAc,GAAG,CACrB,QAAW,EACX,OAAe,KACF;AACb,IAAA,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE;AACpB,QAAA,OAAO,MAAM,CAAC,QAAQ,CAAC;IACzB;AAEA,IAAA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC;AAC1B,CAAC;;;;"}
1
+ {"version":3,"file":"optional-expect-to-be.mjs","sources":["../../../../src/functional/optional/impl/optional-expect-to-be.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AA4CM,SAAU,UAAU,CACxB,GAAG,IAA0E,EAAA;AAE7E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,IAAI;AAEhC,YAAA,OAAO,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC1C;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI;YAEtB,OAAO,CAAC,QAA6B,KACnC,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC;QACrC;;AAEJ;AAEA,MAAM,cAAc,GAAG,CACrB,QAAW,EACX,OAAe,KACF;AACb,IAAA,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE;AACpB,QAAA,OAAO,MAAM,CAAC,QAAQ,CAAC;IACzB;AAEA,IAAA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC;AAC1B,CAAC;;;;"}
@@ -12,7 +12,11 @@ import { type UnwrapOk } from './types.mjs';
12
12
  *
13
13
  * const expectResult = Result.expectToBe<string>('missing result');
14
14
  *
15
- * assert.throws(() => expectResult(Result.err('boom')), /missing result/u);
15
+ * const throwTest = (): void => {
16
+ * expectResult(Result.err('boom'));
17
+ * };
18
+ *
19
+ * assert.throws(throwTest, /missing result/u);
16
20
  *
17
21
  * assert.isTrue(expectResult(Result.ok('value')) === 'value');
18
22
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"result-expect-to-be.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-expect-to-be.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,aAAa,EAChD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,MAAM,GACd,QAAQ,CAAC,CAAC,CAAC,CAAC;AAGf,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"result-expect-to-be.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-expect-to-be.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,aAAa,EAChD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,MAAM,GACd,QAAQ,CAAC,CAAC,CAAC,CAAC;AAGf,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"result-expect-to-be.mjs","sources":["../../../../src/functional/result/impl/result-expect-to-be.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAoCM,SAAU,UAAU,CACxB,GAAG,IAAwE,EAAA;AAE3E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;AAE9B,YAAA,OAAO,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC;QACxC;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI;YAEtB,OAAO,CAAC,MAAS,KAAkB,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC;QACpE;;AAEJ;AAEA,MAAM,cAAc,GAAG,CACrB,MAAS,EACT,OAAe,KACA;AACf,IAAA,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE;AAChB,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB;AAEA,IAAA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC;AAC1B,CAAC;;;;"}
1
+ {"version":3,"file":"result-expect-to-be.mjs","sources":["../../../../src/functional/result/impl/result-expect-to-be.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAwCM,SAAU,UAAU,CACxB,GAAG,IAAwE,EAAA;AAE3E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;AAE9B,YAAA,OAAO,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC;QACxC;QAEA,KAAK,CAAC,EAAE;;AAEN,YAAA,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI;YAEtB,OAAO,CAAC,MAAS,KAAkB,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC;QACpE;;AAEJ;AAEA,MAAM,cAAc,GAAG,CACrB,MAAS,EACT,OAAe,KACA;AACf,IAAA,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE;AAChB,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB;AAEA,IAAA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC;AAC1B,CAAC;;;;"}
@@ -11,10 +11,11 @@ import { type UnwrapOk } from './types.mjs';
11
11
  *
12
12
  * const expectResult = TernaryResult.expectToBe<string>('needs value');
13
13
  *
14
- * assert.throws(
15
- * () => expectResult(TernaryResult.err('oops')),
16
- * /needs value/u,
17
- * );
14
+ * const throwTest = (): void => {
15
+ * expectResult(TernaryResult.err('oops'));
16
+ * };
17
+ *
18
+ * assert.throws(throwTest, /needs value/u);
18
19
  * ```
19
20
  */
20
21
  export declare function expectToBe<R extends UnknownTernaryResult>(result: R, message: string): UnwrapOk<R>;
@@ -1 +1 @@
1
- {"version":3,"file":"ternary-result-expect-to-be.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-expect-to-be.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,oBAAoB,EACvD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,MAAM,GACd,QAAQ,CAAC,CAAC,CAAC,CAAC;AAGf,wBAAgB,UAAU,CAAC,CAAC,EAC1B,OAAO,EAAE,MAAM,GACd,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"ternary-result-expect-to-be.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-expect-to-be.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,oBAAoB,EACvD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,MAAM,GACd,QAAQ,CAAC,CAAC,CAAC,CAAC;AAGf,wBAAgB,UAAU,CAAC,CAAC,EAC1B,OAAO,EAAE,MAAM,GACd,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ternary-result-expect-to-be.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-expect-to-be.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAgCM,SAAU,UAAU,CACxB,GAAG,IAAwE,EAAA;AAE3E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;AAE9B,YAAA,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC;QACpC;QAEA,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI;YAEtB,OAAO,CAAC,MAAS,KAAK,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC;QACnD;;AAEJ;AAEA,MAAM,UAAU,GAAG,CACjB,MAAS,EACT,OAAe,KACA;AACf,IAAA,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE;AAChB,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB;AAEA,IAAA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC;AAC1B,CAAC;;;;"}
1
+ {"version":3,"file":"ternary-result-expect-to-be.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-expect-to-be.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAiCM,SAAU,UAAU,CACxB,GAAG,IAAwE,EAAA;AAE3E,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;AAE9B,YAAA,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC;QACpC;QAEA,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI;YAEtB,OAAO,CAAC,MAAS,KAAK,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC;QACnD;;AAEJ;AAEA,MAAM,UAAU,GAAG,CACjB,MAAS,EACT,OAAe,KACA;AACf,IAAA,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE;AAChB,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB;AAEA,IAAA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC;AAC1B,CAAC;;;;"}
@@ -9,10 +9,11 @@ import { type UnwrapErr, type UnwrapOk, type UnwrapWarn } from './types.mjs';
9
9
  *
10
10
  * assert.strictEqual(TernaryResult.unwrapThrow(okValue), 'ready');
11
11
  *
12
- * assert.throws(
13
- * () => TernaryResult.unwrapThrow(TernaryResult.warn('warn', 'warned')),
14
- * /Expected Ok/u,
15
- * );
12
+ * const throwTest = (): void => {
13
+ * TernaryResult.unwrapThrow(TernaryResult.warn('warn', 'warned'));
14
+ * };
15
+ *
16
+ * assert.throws(throwTest, /Expected Ok/u);
16
17
  * ```
17
18
  */
18
19
  export declare const unwrapThrow: <R extends UnknownTernaryResult>(result: R, toStr?: (value: UnwrapWarn<R> | UnwrapErr<R>) => string) => UnwrapOk<R>;
@@ -1 +1 @@
1
- {"version":3,"file":"ternary-result-unwrap-throw.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,oBAAoB,EACxD,QAAQ,CAAC,EACT,QAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,KAAK,MAAwB,KACvE,QAAQ,CAAC,CAAC,CAqBZ,CAAC"}
1
+ {"version":3,"file":"ternary-result-unwrap-throw.d.mts","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7E;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,oBAAoB,EACxD,QAAQ,CAAC,EACT,QAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,KAAK,MAAwB,KACvE,QAAQ,CAAC,CAAC,CAqBZ,CAAC"}
@@ -12,10 +12,11 @@ import { isWarn } from './ternary-result-is-warn.mjs';
12
12
  *
13
13
  * assert.strictEqual(TernaryResult.unwrapThrow(okValue), 'ready');
14
14
  *
15
- * assert.throws(
16
- * () => TernaryResult.unwrapThrow(TernaryResult.warn('warn', 'warned')),
17
- * /Expected Ok/u,
18
- * );
15
+ * const throwTest = (): void => {
16
+ * TernaryResult.unwrapThrow(TernaryResult.warn('warn', 'warned'));
17
+ * };
18
+ *
19
+ * assert.throws(throwTest, /Expected Ok/u);
19
20
  * ```
20
21
  */
21
22
  const unwrapThrow = (result, toStr = unknownToString) => {
@@ -1 +1 @@
1
- {"version":3,"file":"ternary-result-unwrap-throw.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;;;;;;;;;;;;;;;AAeG;AACI,MAAM,WAAW,GAAG,CACzB,MAAS,EACT,KAAA,GAAyD,eAAe,KACzD;AACf,IAAA,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;AACjB,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,yBAAA,EAA4B,KAAK;;AAE/B,QAAA,MAAM,CAAC,KAAqB,CAC7B,CAAA,CAAE,CACJ;IACH;AAEA,IAAA,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE;AAClB,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,0BAAA,EAA6B,KAAK;;AAEhC,QAAA,MAAM,CAAC,OAAwB,CAChC,CAAA,CAAE,CACJ;IACH;;IAGA,OAAO,MAAM,CAAC,KAAoB;AACpC;;;;"}
1
+ {"version":3,"file":"ternary-result-unwrap-throw.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,WAAW,GAAG,CACzB,MAAS,EACT,KAAA,GAAyD,eAAe,KACzD;AACf,IAAA,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;AACjB,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,yBAAA,EAA4B,KAAK;;AAE/B,QAAA,MAAM,CAAC,KAAqB,CAC7B,CAAA,CAAE,CACJ;IACH;AAEA,IAAA,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE;AAClB,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,0BAAA,EAA6B,KAAK;;AAEhC,QAAA,MAAM,CAAC,OAAwB,CAChC,CAAA,CAAE,CACJ;IACH;;IAGA,OAAO,MAAM,CAAC,KAAoB;AACpC;;;;"}
package/dist/index.mjs CHANGED
@@ -47,6 +47,7 @@ export { TsDataForgeInternals } from './number/refined-number-utils.mjs';
47
47
  export { Obj } from './object/object.mjs';
48
48
  export { castDeepMutable, castMutable } from './others/cast-mutable.mjs';
49
49
  export { castDeepReadonly, castReadonly } from './others/cast-readonly.mjs';
50
+ export { debounce } from './others/debounce-function.mjs';
50
51
  export { ifThen } from './others/if-then.mjs';
51
52
  export { mapNullable } from './others/map-nullable.mjs';
52
53
  export { memoizeFunction } from './others/memoize-function.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Creates a debounced function that delays invoking `func` until after `waitMilliseconds`
3
+ * have elapsed since the last time the debounced function was invoked.
4
+ *
5
+ * @template F The type of the function to debounce.
6
+ * @param func The function to debounce.
7
+ * @param waitMilliseconds The number of milliseconds to delay.
8
+ * @returns The new debounced function.
9
+ */
10
+ export declare const debounce: <Args extends readonly unknown[]>(func: (...args: Args) => void, waitMilliseconds: number) => ((...args: Args) => void);
11
+ //# sourceMappingURL=debounce-function.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce-function.d.mts","sourceRoot":"","sources":["../../src/others/debounce-function.mts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,SAAS,SAAS,OAAO,EAAE,EACtD,MAAM,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,EAC7B,kBAAkB,MAAM,KACvB,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,CAU1B,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Creates a debounced function that delays invoking `func` until after `waitMilliseconds`
3
+ * have elapsed since the last time the debounced function was invoked.
4
+ *
5
+ * @template F The type of the function to debounce.
6
+ * @param func The function to debounce.
7
+ * @param waitMilliseconds The number of milliseconds to delay.
8
+ * @returns The new debounced function.
9
+ */
10
+ const debounce = (func, waitMilliseconds) => {
11
+ let mut_timeoutId;
12
+ return (...args) => {
13
+ clearTimeout(mut_timeoutId);
14
+ mut_timeoutId = setTimeout(() => {
15
+ func(...args);
16
+ }, waitMilliseconds);
17
+ };
18
+ };
19
+
20
+ export { debounce };
21
+ //# sourceMappingURL=debounce-function.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce-function.mjs","sources":["../../src/others/debounce-function.mts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;AAQG;MACU,QAAQ,GAAG,CACtB,IAA6B,EAC7B,gBAAwB,KACK;AAC7B,IAAA,IAAI,aAAwD;AAE5D,IAAA,OAAO,CAAC,GAAG,IAAU,KAAU;QAC7B,YAAY,CAAC,aAAa,CAAC;AAE3B,QAAA,aAAa,GAAG,UAAU,CAAC,MAAK;AAC9B,YAAA,IAAI,CAAC,GAAG,IAAI,CAAC;QACf,CAAC,EAAE,gBAAgB,CAAC;AACtB,IAAA,CAAC;AACH;;;;"}
@@ -1,5 +1,6 @@
1
1
  export * from './cast-mutable.mjs';
2
2
  export * from './cast-readonly.mjs';
3
+ export * from './debounce-function.mjs';
3
4
  export * from './if-then.mjs';
4
5
  export * from './map-nullable.mjs';
5
6
  export * from './memoize-function.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/others/index.mts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/others/index.mts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export { castDeepMutable, castMutable } from './cast-mutable.mjs';
2
2
  export { castDeepReadonly, castReadonly } from './cast-readonly.mjs';
3
+ export { debounce } from './debounce-function.mjs';
3
4
  export { ifThen } from './if-then.mjs';
4
5
  export { mapNullable } from './map-nullable.mjs';
5
6
  export { memoizeFunction } from './memoize-function.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-data-forge",
3
- "version": "6.2.2",
3
+ "version": "6.3.0",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "typescript",
@@ -93,36 +93,36 @@
93
93
  "@semantic-release/github": "12.0.2",
94
94
  "@semantic-release/npm": "13.1.3",
95
95
  "@semantic-release/release-notes-generator": "14.1.0",
96
- "@types/node": "25.0.7",
97
- "@types/react": "19.2.8",
98
- "@vitest/browser-playwright": "4.0.16",
99
- "@vitest/coverage-v8": "4.0.16",
100
- "@vitest/ui": "4.0.16",
96
+ "@types/node": "25.0.10",
97
+ "@types/react": "19.2.9",
98
+ "@vitest/browser-playwright": "4.0.17",
99
+ "@vitest/coverage-v8": "4.0.17",
100
+ "@vitest/ui": "4.0.17",
101
101
  "conventional-changelog-conventionalcommits": "9.1.0",
102
- "cspell": "9.4.0",
102
+ "cspell": "9.6.0",
103
103
  "dedent": "^1.7.1",
104
104
  "eslint": "9.39.2",
105
- "eslint-config-typed": "4.4.1",
106
- "github-settings-as-code": "1.0.7",
105
+ "eslint-config-typed": "4.6.0",
106
+ "github-settings-as-code": "1.0.12",
107
107
  "immer": "11.1.3",
108
108
  "jiti": "2.6.1",
109
109
  "markdownlint": "0.40.0",
110
110
  "markdownlint-cli2": "0.20.0",
111
111
  "npm-run-all2": "8.0.4",
112
112
  "playwright": "1.57.0",
113
- "prettier": "3.7.4",
113
+ "prettier": "3.8.0",
114
114
  "prettier-plugin-organize-imports": "4.3.0",
115
- "prettier-plugin-packagejson": "2.5.20",
115
+ "prettier-plugin-packagejson": "2.5.21",
116
116
  "rollup": "4.55.1",
117
117
  "semantic-release": "25.0.2",
118
- "ts-repo-utils": "8.0.2",
118
+ "ts-repo-utils": "8.0.3",
119
119
  "tslib": "2.8.1",
120
120
  "tsx": "4.21.0",
121
- "typedoc": "0.28.15",
121
+ "typedoc": "0.28.16",
122
122
  "typedoc-github-theme": "0.3.1",
123
123
  "typescript": "5.9.3",
124
- "vite": "7.3.0",
125
- "vitest": "4.0.16"
124
+ "vite": "7.3.1",
125
+ "vitest": "4.0.17"
126
126
  },
127
127
  "peerDependencies": {
128
128
  "typescript": ">=4.8"
@@ -760,8 +760,10 @@ describe('Arr creations', () => {
760
760
  const result = await generateAsync<number>(async function* () {
761
761
  // eslint-disable-next-line functional/no-let
762
762
  for (let i = 0; i < 3; i++) {
763
- // eslint-disable-next-line no-promise-executor-return, no-await-in-loop
764
- await new Promise((resolve) => setTimeout(resolve, 0));
763
+ // eslint-disable-next-line no-await-in-loop
764
+ await new Promise<void>((resolve) => {
765
+ setTimeout(resolve, 0);
766
+ });
765
767
 
766
768
  yield i;
767
769
  }
@@ -17,7 +17,11 @@ import { type Unwrap } from './types.mjs';
17
17
  *
18
18
  * const expectValue = Optional.expectToBe<string>('missing optional');
19
19
  *
20
- * assert.throws(() => expectValue(Optional.none), /missing optional/u);
20
+ * const throwTest = (): void => {
21
+ * expectValue(Optional.none);
22
+ * };
23
+ *
24
+ * assert.throws(throwTest, /missing optional/u);
21
25
  *
22
26
  * assert.isTrue(expectValue(Optional.some('present')) === 'present');
23
27
  * ```
@@ -15,7 +15,11 @@ import { type UnwrapOk } from './types.mjs';
15
15
  *
16
16
  * const expectResult = Result.expectToBe<string>('missing result');
17
17
  *
18
- * assert.throws(() => expectResult(Result.err('boom')), /missing result/u);
18
+ * const throwTest = (): void => {
19
+ * expectResult(Result.err('boom'));
20
+ * };
21
+ *
22
+ * assert.throws(throwTest, /missing result/u);
19
23
  *
20
24
  * assert.isTrue(expectResult(Result.ok('value')) === 'value');
21
25
  * ```
@@ -14,10 +14,11 @@ import { type UnwrapOk } from './types.mjs';
14
14
  *
15
15
  * const expectResult = TernaryResult.expectToBe<string>('needs value');
16
16
  *
17
- * assert.throws(
18
- * () => expectResult(TernaryResult.err('oops')),
19
- * /needs value/u,
20
- * );
17
+ * const throwTest = (): void => {
18
+ * expectResult(TernaryResult.err('oops'));
19
+ * };
20
+ *
21
+ * assert.throws(throwTest, /needs value/u);
21
22
  * ```
22
23
  */
23
24
  export function expectToBe<R extends UnknownTernaryResult>(
@@ -13,10 +13,11 @@ import { type UnwrapErr, type UnwrapOk, type UnwrapWarn } from './types.mjs';
13
13
  *
14
14
  * assert.strictEqual(TernaryResult.unwrapThrow(okValue), 'ready');
15
15
  *
16
- * assert.throws(
17
- * () => TernaryResult.unwrapThrow(TernaryResult.warn('warn', 'warned')),
18
- * /Expected Ok/u,
19
- * );
16
+ * const throwTest = (): void => {
17
+ * TernaryResult.unwrapThrow(TernaryResult.warn('warn', 'warned'));
18
+ * };
19
+ *
20
+ * assert.throws(throwTest, /Expected Ok/u);
20
21
  * ```
21
22
  */
22
23
  export const unwrapThrow = <R extends UnknownTernaryResult>(
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Creates a debounced function that delays invoking `func` until after `waitMilliseconds`
3
+ * have elapsed since the last time the debounced function was invoked.
4
+ *
5
+ * @template F The type of the function to debounce.
6
+ * @param func The function to debounce.
7
+ * @param waitMilliseconds The number of milliseconds to delay.
8
+ * @returns The new debounced function.
9
+ */
10
+ export const debounce = <Args extends readonly unknown[]>(
11
+ func: (...args: Args) => void,
12
+ waitMilliseconds: number,
13
+ ): ((...args: Args) => void) => {
14
+ let mut_timeoutId: ReturnType<typeof setTimeout> | undefined;
15
+
16
+ return (...args: Args): void => {
17
+ clearTimeout(mut_timeoutId);
18
+
19
+ mut_timeoutId = setTimeout(() => {
20
+ func(...args);
21
+ }, waitMilliseconds);
22
+ };
23
+ };
@@ -0,0 +1,81 @@
1
+ /* eslint-disable vitest/no-restricted-vi-methods */
2
+
3
+ import { debounce } from './debounce-function.mjs';
4
+
5
+ describe(debounce, () => {
6
+ // eslint-disable-next-line vitest/no-hooks
7
+ beforeEach(() => {
8
+ vi.useFakeTimers();
9
+ });
10
+
11
+ // eslint-disable-next-line vitest/no-hooks
12
+ afterEach(() => {
13
+ vi.restoreAllMocks();
14
+ });
15
+
16
+ test('should delay the execution of the function', () => {
17
+ const func = vi.fn();
18
+
19
+ // eslint-disable-next-line @typescript-eslint/strict-void-return
20
+ const debouncedFunc = debounce(func, 100);
21
+
22
+ debouncedFunc();
23
+
24
+ expect(func).not.toHaveBeenCalled();
25
+
26
+ vi.advanceTimersByTime(50);
27
+
28
+ expect(func).not.toHaveBeenCalled();
29
+
30
+ vi.advanceTimersByTime(50);
31
+
32
+ expect(func).toHaveBeenCalledOnce();
33
+ });
34
+
35
+ test('should only execute the function once after multiple rapid calls', () => {
36
+ const func = vi.fn();
37
+
38
+ // eslint-disable-next-line @typescript-eslint/strict-void-return
39
+ const debouncedFunc = debounce(func, 100);
40
+
41
+ debouncedFunc();
42
+
43
+ debouncedFunc();
44
+
45
+ debouncedFunc();
46
+
47
+ expect(func).not.toHaveBeenCalled();
48
+
49
+ vi.advanceTimersByTime(100);
50
+
51
+ expect(func).toHaveBeenCalledOnce();
52
+ });
53
+
54
+ test('should pass the arguments to the original function', () => {
55
+ const func = vi.fn((_a: number, _b: string) => {});
56
+
57
+ const debouncedFunc = debounce(func, 100);
58
+
59
+ debouncedFunc(1, 'test');
60
+
61
+ vi.advanceTimersByTime(100);
62
+
63
+ expect(func).toHaveBeenCalledWith(1, 'test');
64
+ });
65
+
66
+ test('should use the latest arguments from the last call', () => {
67
+ const func = vi.fn((_a: number, _b: string) => {});
68
+
69
+ const debouncedFunc = debounce(func, 100);
70
+
71
+ debouncedFunc(1, 'a');
72
+
73
+ debouncedFunc(2, 'b');
74
+
75
+ debouncedFunc(3, 'c');
76
+
77
+ vi.advanceTimersByTime(100);
78
+
79
+ expect(func).toHaveBeenCalledExactlyOnceWith(3, 'c');
80
+ });
81
+ });
@@ -1,5 +1,6 @@
1
1
  export * from './cast-mutable.mjs';
2
2
  export * from './cast-readonly.mjs';
3
+ export * from './debounce-function.mjs';
3
4
  export * from './if-then.mjs';
4
5
  export * from './map-nullable.mjs';
5
6
  export * from './memoize-function.mjs';