ts-data-forge 5.1.0 → 5.1.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.
Files changed (226) hide show
  1. package/README.md +46 -44
  2. package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
  3. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  4. package/dist/array/impl/array-utils-reducing-value.d.mts +8 -8
  5. package/dist/array/impl/array-utils-search.d.mts +4 -4
  6. package/dist/array/impl/array-utils-set-op.d.mts +7 -7
  7. package/dist/array/impl/array-utils-set-op.mjs +7 -7
  8. package/dist/array/impl/array-utils-size.d.mts +2 -2
  9. package/dist/array/impl/array-utils-size.mjs +2 -2
  10. package/dist/array/impl/array-utils-slicing.d.mts +2 -2
  11. package/dist/array/impl/array-utils-slicing.mjs +2 -2
  12. package/dist/array/impl/array-utils-validation.d.mts +18 -18
  13. package/dist/array/impl/array-utils-validation.mjs +14 -14
  14. package/dist/collections/imap.d.mts +15 -15
  15. package/dist/collections/imap.mjs +3 -3
  16. package/dist/collections/iset-mapped.d.mts +19 -19
  17. package/dist/collections/iset-mapped.mjs +2 -2
  18. package/dist/collections/iset.d.mts +19 -19
  19. package/dist/collections/iset.mjs +2 -2
  20. package/dist/collections/queue.d.mts +25 -25
  21. package/dist/collections/queue.mjs +5 -5
  22. package/dist/collections/stack.d.mts +25 -25
  23. package/dist/collections/stack.mjs +5 -5
  24. package/dist/functional/match.d.mts +1 -1
  25. package/dist/functional/optional/impl/optional-expect-to-be.d.mts +2 -2
  26. package/dist/functional/optional/impl/optional-is-none.d.mts +1 -1
  27. package/dist/functional/optional/impl/optional-is-none.mjs +1 -1
  28. package/dist/functional/optional/impl/optional-is-optional.d.mts +2 -2
  29. package/dist/functional/optional/impl/optional-is-optional.mjs +2 -2
  30. package/dist/functional/optional/impl/optional-is-some.d.mts +1 -1
  31. package/dist/functional/optional/impl/optional-is-some.mjs +1 -1
  32. package/dist/functional/optional/impl/optional-none.d.mts +2 -2
  33. package/dist/functional/optional/impl/optional-none.mjs +2 -2
  34. package/dist/functional/optional/impl/optional-some.d.mts +2 -2
  35. package/dist/functional/optional/impl/optional-some.mjs +2 -2
  36. package/dist/functional/optional/impl/optional-to-nullable.d.mts +2 -2
  37. package/dist/functional/optional/impl/optional-to-nullable.mjs +2 -2
  38. package/dist/functional/optional/impl/optional-unwrap-or.d.mts +4 -4
  39. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts +1 -1
  40. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +1 -1
  41. package/dist/functional/optional/impl/optional-unwrap.d.mts +2 -2
  42. package/dist/functional/optional/impl/optional-zip.d.mts +1 -1
  43. package/dist/functional/optional/impl/optional-zip.mjs +1 -1
  44. package/dist/functional/pipe.d.mts +2 -2
  45. package/dist/functional/result/impl/result-err.d.mts +1 -1
  46. package/dist/functional/result/impl/result-err.mjs +1 -1
  47. package/dist/functional/result/impl/result-expect-to-be.d.mts +2 -2
  48. package/dist/functional/result/impl/result-from-promise.d.mts +1 -1
  49. package/dist/functional/result/impl/result-from-promise.mjs +1 -1
  50. package/dist/functional/result/impl/result-from-throwable.d.mts +1 -1
  51. package/dist/functional/result/impl/result-from-throwable.mjs +1 -1
  52. package/dist/functional/result/impl/result-is-err.d.mts +2 -2
  53. package/dist/functional/result/impl/result-is-err.mjs +2 -2
  54. package/dist/functional/result/impl/result-is-ok.d.mts +2 -2
  55. package/dist/functional/result/impl/result-is-ok.mjs +2 -2
  56. package/dist/functional/result/impl/result-is-result.d.mts +3 -3
  57. package/dist/functional/result/impl/result-is-result.mjs +3 -3
  58. package/dist/functional/result/impl/result-ok.d.mts +1 -1
  59. package/dist/functional/result/impl/result-ok.mjs +1 -1
  60. package/dist/functional/result/impl/result-unwrap-err-or.d.mts +4 -4
  61. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts +1 -1
  62. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +1 -1
  63. package/dist/functional/result/impl/result-unwrap-err.d.mts +2 -2
  64. package/dist/functional/result/impl/result-unwrap-err.mjs +2 -2
  65. package/dist/functional/result/impl/result-unwrap-ok-or.d.mts +4 -4
  66. package/dist/functional/result/impl/result-unwrap-ok.d.mts +2 -2
  67. package/dist/functional/result/impl/result-unwrap-throw.d.mts +1 -1
  68. package/dist/functional/result/impl/result-unwrap-throw.mjs +1 -1
  69. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +1 -1
  70. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +1 -1
  71. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts +1 -1
  72. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +1 -1
  73. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts +1 -1
  74. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +1 -1
  75. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +3 -3
  76. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +3 -3
  77. package/dist/globals.d.mts +2 -1
  78. package/dist/guard/has-key.d.mts +6 -3
  79. package/dist/guard/has-key.d.mts.map +1 -1
  80. package/dist/guard/has-key.mjs +2 -2
  81. package/dist/guard/key-is-in.d.mts +2 -2
  82. package/dist/guard/key-is-in.mjs +2 -2
  83. package/dist/json/json.d.mts +21 -21
  84. package/dist/json/json.mjs +21 -21
  85. package/dist/number/branded-types/int.d.mts +19 -19
  86. package/dist/number/branded-types/int.mjs +19 -19
  87. package/dist/number/branded-types/positive-int.d.mts +20 -20
  88. package/dist/number/branded-types/positive-int.mjs +20 -20
  89. package/dist/number/branded-types/positive-safe-int.d.mts +26 -26
  90. package/dist/number/branded-types/positive-safe-int.mjs +26 -26
  91. package/dist/number/branded-types/safe-int.d.mts +27 -27
  92. package/dist/number/branded-types/safe-int.mjs +27 -27
  93. package/dist/number/branded-types/uint.d.mts +19 -19
  94. package/dist/number/branded-types/uint.mjs +19 -19
  95. package/dist/number/num.d.mts +20 -20
  96. package/dist/number/num.mjs +16 -16
  97. package/dist/number/refined-number-utils.d.mts +11 -11
  98. package/dist/number/refined-number-utils.d.mts.map +1 -1
  99. package/dist/number/refined-number-utils.mjs +11 -11
  100. package/dist/object/object.d.mts +3 -3
  101. package/dist/object/object.d.mts.map +1 -1
  102. package/dist/object/object.mjs +3 -3
  103. package/dist/object/object.mjs.map +1 -1
  104. package/dist/others/tuple.d.mts +3 -3
  105. package/dist/others/tuple.mjs +3 -3
  106. package/dist/promise/promise.d.mts +4 -4
  107. package/dist/promise/promise.mjs +4 -4
  108. package/package.json +15 -13
  109. package/src/array/impl/array-utils-creation.test.mts +1 -1
  110. package/src/array/impl/array-utils-element-access.test.mts +16 -16
  111. package/src/array/impl/array-utils-modification.mts +38 -19
  112. package/src/array/impl/array-utils-reducing-value.mts +8 -8
  113. package/src/array/impl/array-utils-reducing-value.test.mts +23 -31
  114. package/src/array/impl/array-utils-search.mts +4 -4
  115. package/src/array/impl/array-utils-search.test.mts +10 -10
  116. package/src/array/impl/array-utils-set-op.mts +7 -7
  117. package/src/array/impl/array-utils-set-op.test.mts +13 -13
  118. package/src/array/impl/array-utils-size.mts +2 -2
  119. package/src/array/impl/array-utils-slicing.mts +2 -2
  120. package/src/array/impl/array-utils-transformation.test.mts +2 -2
  121. package/src/array/impl/array-utils-validation.mts +18 -18
  122. package/src/array/impl/array-utils-validation.test.mts +80 -78
  123. package/src/array/impl/array.test.mts +6 -6
  124. package/src/collections/imap-mapped.test.mts +16 -18
  125. package/src/collections/imap.mts +15 -15
  126. package/src/collections/imap.test.mts +31 -31
  127. package/src/collections/iset-mapped.mts +19 -19
  128. package/src/collections/iset-mapped.test.mts +52 -52
  129. package/src/collections/iset.mts +19 -19
  130. package/src/collections/iset.test.mts +130 -130
  131. package/src/collections/queue.mts +25 -25
  132. package/src/collections/queue.test.mts +33 -35
  133. package/src/collections/stack.mts +25 -25
  134. package/src/collections/stack.test.mts +15 -15
  135. package/src/functional/match.mts +1 -1
  136. package/src/functional/optional/impl/optional-expect-to-be.mts +2 -2
  137. package/src/functional/optional/impl/optional-is-none.mts +1 -1
  138. package/src/functional/optional/impl/optional-is-optional.mts +2 -2
  139. package/src/functional/optional/impl/optional-is-some.mts +1 -1
  140. package/src/functional/optional/impl/optional-none.mts +2 -2
  141. package/src/functional/optional/impl/optional-some.mts +2 -2
  142. package/src/functional/optional/impl/optional-to-nullable.mts +2 -2
  143. package/src/functional/optional/impl/optional-unwrap-or.mts +4 -4
  144. package/src/functional/optional/impl/optional-unwrap-throw.mts +1 -1
  145. package/src/functional/optional/impl/optional-unwrap.mts +2 -2
  146. package/src/functional/optional/impl/optional-zip.mts +1 -1
  147. package/src/functional/optional.test.mts +53 -54
  148. package/src/functional/pipe.mts +2 -2
  149. package/src/functional/pipe.test.mts +4 -4
  150. package/src/functional/result/impl/result-err.mts +1 -1
  151. package/src/functional/result/impl/result-expect-to-be.mts +2 -2
  152. package/src/functional/result/impl/result-from-promise.mts +1 -1
  153. package/src/functional/result/impl/result-from-throwable.mts +1 -1
  154. package/src/functional/result/impl/result-is-err.mts +2 -2
  155. package/src/functional/result/impl/result-is-ok.mts +2 -2
  156. package/src/functional/result/impl/result-is-result.mts +3 -3
  157. package/src/functional/result/impl/result-ok.mts +1 -1
  158. package/src/functional/result/impl/result-unwrap-err-or.mts +4 -4
  159. package/src/functional/result/impl/result-unwrap-err-throw.mts +1 -1
  160. package/src/functional/result/impl/result-unwrap-err.mts +2 -2
  161. package/src/functional/result/impl/result-unwrap-ok-or.mts +4 -4
  162. package/src/functional/result/impl/result-unwrap-ok.mts +2 -2
  163. package/src/functional/result/impl/result-unwrap-throw.mts +1 -1
  164. package/src/functional/result.test.mts +94 -152
  165. package/src/functional/ternary-result/impl/ternary-result-err.mts +1 -1
  166. package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +1 -1
  167. package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +1 -1
  168. package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +3 -3
  169. package/src/functional/ternary-result.test.mts +8 -8
  170. package/src/globals.d.mts +2 -1
  171. package/src/guard/has-key.mts +8 -5
  172. package/src/guard/has-key.test.mts +0 -5
  173. package/src/guard/is-error.test.mts +143 -0
  174. package/src/guard/is-non-empty-string.test.mts +24 -24
  175. package/src/guard/is-non-null-object.test.mts +26 -26
  176. package/src/guard/is-primitive.test.mts +28 -28
  177. package/src/guard/is-record.test.mts +7 -7
  178. package/src/guard/is-type.test.mts +151 -155
  179. package/src/guard/key-is-in.mts +2 -2
  180. package/src/guard/key-is-in.test.mts +2 -2
  181. package/src/json/json.mts +21 -21
  182. package/src/json/json.test.mts +135 -174
  183. package/src/number/branded-types/finite-number.test.mts +13 -11
  184. package/src/number/branded-types/int.mts +19 -19
  185. package/src/number/branded-types/int.test.mts +14 -14
  186. package/src/number/branded-types/int16.test.mts +16 -16
  187. package/src/number/branded-types/int32.test.mts +16 -16
  188. package/src/number/branded-types/non-negative-finite-number.test.mts +12 -12
  189. package/src/number/branded-types/non-negative-int16.test.mts +16 -16
  190. package/src/number/branded-types/non-negative-int32.test.mts +16 -16
  191. package/src/number/branded-types/non-zero-finite-number.test.mts +14 -14
  192. package/src/number/branded-types/non-zero-int.test.mts +19 -19
  193. package/src/number/branded-types/non-zero-int16.test.mts +16 -16
  194. package/src/number/branded-types/non-zero-int32.test.mts +16 -16
  195. package/src/number/branded-types/non-zero-safe-int.test.mts +23 -23
  196. package/src/number/branded-types/non-zero-uint16.test.mts +16 -16
  197. package/src/number/branded-types/non-zero-uint32.test.mts +16 -16
  198. package/src/number/branded-types/positive-finite-number.test.mts +14 -14
  199. package/src/number/branded-types/positive-int.mts +20 -20
  200. package/src/number/branded-types/positive-int.test.mts +17 -17
  201. package/src/number/branded-types/positive-int16.test.mts +15 -15
  202. package/src/number/branded-types/positive-int32.test.mts +15 -15
  203. package/src/number/branded-types/positive-safe-int.mts +26 -26
  204. package/src/number/branded-types/positive-safe-int.test.mts +19 -19
  205. package/src/number/branded-types/positive-uint16.test.mts +16 -16
  206. package/src/number/branded-types/positive-uint32.test.mts +16 -16
  207. package/src/number/branded-types/safe-int.mts +27 -27
  208. package/src/number/branded-types/safe-int.test.mts +18 -18
  209. package/src/number/branded-types/safe-uint.test.mts +17 -17
  210. package/src/number/branded-types/uint.mts +19 -19
  211. package/src/number/branded-types/uint.test.mts +15 -15
  212. package/src/number/branded-types/uint16.test.mts +15 -15
  213. package/src/number/branded-types/uint32.test.mts +15 -15
  214. package/src/number/enum/int8.test.mts +1 -1
  215. package/src/number/enum/uint8.test.mts +1 -1
  216. package/src/number/num.mts +20 -20
  217. package/src/number/num.test.mts +26 -26
  218. package/src/number/refined-number-utils.mts +13 -13
  219. package/src/object/object.mts +4 -3
  220. package/src/object/object.test.mts +6 -6
  221. package/src/others/cast-mutable.test.mts +1 -1
  222. package/src/others/cast-readonly.test.mts +4 -4
  223. package/src/others/if-then.test.mts +24 -24
  224. package/src/others/tuple.mts +3 -3
  225. package/src/promise/promise.mts +4 -4
  226. package/src/promise/promise.test.mts +7 -13
@@ -10,15 +10,15 @@ import { type UnwrapErr } from './types.mjs';
10
10
  *
11
11
  * const errResult = Result.err('failure');
12
12
  *
13
- * assert(Result.unwrapErrOr(okResult, 'default') === 'default');
13
+ * assert.isTrue(Result.unwrapErrOr(okResult, 'default') === 'default');
14
14
  *
15
- * assert(Result.unwrapErrOr(errResult, 'default') === 'failure');
15
+ * assert.isTrue(Result.unwrapErrOr(errResult, 'default') === 'failure');
16
16
  *
17
17
  * const unwrapError = Result.unwrapErrOr('fallback error');
18
18
  *
19
- * assert(unwrapError(Result.err('boom')) === 'boom');
19
+ * assert.isTrue(unwrapError(Result.err('boom')) === 'boom');
20
20
  *
21
- * assert(unwrapError(Result.ok('no error')) === 'fallback error');
21
+ * assert.isTrue(unwrapError(Result.ok('no error')) === 'fallback error');
22
22
  * ```
23
23
  *
24
24
  * @template R The `UnknownResult` type to unwrap.
@@ -14,7 +14,7 @@ import { type UnwrapErr, type UnwrapOk } from './types.mjs';
14
14
  *
15
15
  * const okResult = Result.ok('value');
16
16
  *
17
- * assert(Result.unwrapErrThrow(errResult).message === 'broken');
17
+ * assert.isTrue(Result.unwrapErrThrow(errResult).message === 'broken');
18
18
  *
19
19
  * assert.throws(() => Result.unwrapErrThrow(okResult), /Expected Err/u);
20
20
  * ```
@@ -17,7 +17,7 @@ import { isErr } from './result-is-err.mjs';
17
17
  *
18
18
  * const okResult = Result.ok('value');
19
19
  *
20
- * assert(Result.unwrapErrThrow(errResult).message === 'broken');
20
+ * assert.isTrue(Result.unwrapErrThrow(errResult).message === 'broken');
21
21
  *
22
22
  * assert.throws(() => Result.unwrapErrThrow(okResult), /Expected Err/u);
23
23
  * ```
@@ -17,11 +17,11 @@ import { type UnwrapErr } from './types.mjs';
17
17
  * // Result.unwrapErr returns undefined for Ok results
18
18
  *
19
19
  * // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
20
- * assert(Result.unwrapErr(okResult) === undefined);
20
+ * assert.isTrue(Result.unwrapErr(okResult) === undefined);
21
21
  *
22
22
  * // Result.unwrapErr returns the error value for Err results
23
23
  *
24
- * assert(Result.unwrapErr(errResult) === 'problem');
24
+ * assert.isTrue(Result.unwrapErr(errResult) === 'problem');
25
25
  * ```
26
26
  *
27
27
  * @template R The `UnknownResult` type to unwrap.
@@ -18,11 +18,11 @@ import { isErr } from './result-is-err.mjs';
18
18
  * // Result.unwrapErr returns undefined for Ok results
19
19
  *
20
20
  * // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
21
- * assert(Result.unwrapErr(okResult) === undefined);
21
+ * assert.isTrue(Result.unwrapErr(okResult) === undefined);
22
22
  *
23
23
  * // Result.unwrapErr returns the error value for Err results
24
24
  *
25
- * assert(Result.unwrapErr(errResult) === 'problem');
25
+ * assert.isTrue(Result.unwrapErr(errResult) === 'problem');
26
26
  * ```
27
27
  *
28
28
  * @template R The `UnknownResult` type to unwrap.
@@ -10,15 +10,15 @@ import { type UnwrapOk } from './types.mjs';
10
10
  *
11
11
  * const errValue = Result.err('fail');
12
12
  *
13
- * assert(Result.unwrapOkOr(okValue, 0) === 10);
13
+ * assert.isTrue(Result.unwrapOkOr(okValue, 0) === 10);
14
14
  *
15
- * assert(Result.unwrapOkOr(errValue, 0) === 0);
15
+ * assert.isTrue(Result.unwrapOkOr(errValue, 0) === 0);
16
16
  *
17
17
  * const unwrapWithDefault = Result.unwrapOkOr(5);
18
18
  *
19
- * assert(unwrapWithDefault(Result.ok(3)) === 3);
19
+ * assert.isTrue(unwrapWithDefault(Result.ok(3)) === 3);
20
20
  *
21
- * assert(unwrapWithDefault(Result.err('no data')) === 5);
21
+ * assert.isTrue(unwrapWithDefault(Result.err('no data')) === 5);
22
22
  * ```
23
23
  *
24
24
  * @template R The `UnknownResult` type to unwrap.
@@ -11,12 +11,12 @@ import { type UnwrapOk } from './types.mjs';
11
11
  *
12
12
  * // Result.unwrapOk returns the value for Ok results
13
13
  *
14
- * assert(Result.unwrapOk(okResult) === 42);
14
+ * assert.isTrue(Result.unwrapOk(okResult) === 42);
15
15
  *
16
16
  * // Result.unwrapOk returns undefined for Err results
17
17
  *
18
18
  * // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
19
- * assert(Result.unwrapOk(errResult) === undefined);
19
+ * assert.isTrue(Result.unwrapOk(errResult) === undefined);
20
20
  * ```
21
21
  */
22
22
  export declare function unwrapOk<R extends Ok<unknown>>(result: R): UnwrapOk<R>;
@@ -15,7 +15,7 @@ import { type UnwrapErr, type UnwrapOk } from './types.mjs';
15
15
  *
16
16
  * const errResult = Result.err(new Error('fail'));
17
17
  *
18
- * assert(Result.unwrapThrow(okResult) === 'data');
18
+ * assert.isTrue(Result.unwrapThrow(okResult) === 'data');
19
19
  *
20
20
  * assert.throws(() => Result.unwrapThrow(errResult), /fail/u);
21
21
  * ```
@@ -17,7 +17,7 @@ import { isErr } from './result-is-err.mjs';
17
17
  *
18
18
  * const errResult = Result.err(new Error('fail'));
19
19
  *
20
- * assert(Result.unwrapThrow(okResult) === 'data');
20
+ * assert.isTrue(Result.unwrapThrow(okResult) === 'data');
21
21
  *
22
22
  * assert.throws(() => Result.unwrapThrow(errResult), /fail/u);
23
23
  * ```
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * assert.strictEqual(failure.$$tag, 'ts-data-forge::Result.err');
10
10
  *
11
- * assert.ok(TernaryResult.isErr(failure));
11
+ * assert.isTrue(TernaryResult.isErr(failure));
12
12
  * ```
13
13
  */
14
14
  export declare const err: <const E>(value: E) => TernaryErr<E>;
@@ -10,7 +10,7 @@ import { ErrTypeTagName } from './tag.mjs';
10
10
  *
11
11
  * assert.strictEqual(failure.$$tag, 'ts-data-forge::Result.err');
12
12
  *
13
- * assert.ok(TernaryResult.isErr(failure));
13
+ * assert.isTrue(TernaryResult.isErr(failure));
14
14
  * ```
15
15
  */
16
16
  const err = (value) => ({
@@ -14,7 +14,7 @@ type UnwrapPromise<P extends Promise<unknown>> = P extends Promise<infer V> ? V
14
14
  *
15
15
  * assert.deepStrictEqual(resolved, TernaryResult.ok('ok'));
16
16
  *
17
- * assert.ok(TernaryResult.isErr(rejected));
17
+ * assert.isTrue(TernaryResult.isErr(rejected));
18
18
  * ```
19
19
  */
20
20
  export declare const fromPromise: <P extends Promise<unknown>>(promise: P) => Promise<TernaryResult<UnwrapPromise<P>, unknown, never>>;
@@ -15,7 +15,7 @@ import { ok } from './ternary-result-ok.mjs';
15
15
  *
16
16
  * assert.deepStrictEqual(resolved, TernaryResult.ok('ok'));
17
17
  *
18
- * assert.ok(TernaryResult.isErr(rejected));
18
+ * assert.isTrue(TernaryResult.isErr(rejected));
19
19
  * ```
20
20
  */
21
21
  const fromPromise = (promise) =>
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * assert.deepStrictEqual(success, TernaryResult.ok(2));
14
14
  *
15
- * assert.ok(TernaryResult.isErr(failure));
15
+ * assert.isTrue(TernaryResult.isErr(failure));
16
16
  * ```
17
17
  */
18
18
  export declare const fromThrowable: <T>(fn: () => T) => TernaryResult<T, Error, never>;
@@ -17,7 +17,7 @@ import { ok } from './ternary-result-ok.mjs';
17
17
  *
18
18
  * assert.deepStrictEqual(success, TernaryResult.ok(2));
19
19
  *
20
- * assert.ok(TernaryResult.isErr(failure));
20
+ * assert.isTrue(TernaryResult.isErr(failure));
21
21
  * ```
22
22
  */
23
23
  const fromThrowable = (fn) => {
@@ -10,11 +10,11 @@
10
10
  *
11
11
  * const notResult = { $$tag: 'ts-data-forge::Result.ok' };
12
12
  *
13
- * assert.ok(TernaryResult.isTernaryResult(okValue));
13
+ * assert.isTrue(TernaryResult.isTernaryResult(okValue));
14
14
  *
15
- * assert.ok(TernaryResult.isTernaryResult(warnValue));
15
+ * assert.isTrue(TernaryResult.isTernaryResult(warnValue));
16
16
  *
17
- * assert.ok(!TernaryResult.isTernaryResult(notResult));
17
+ * assert.isFalse(TernaryResult.isTernaryResult(notResult));
18
18
  * ```
19
19
  */
20
20
  export declare const isTernaryResult: (maybeResult: unknown) => maybeResult is UnknownTernaryResult;
@@ -14,11 +14,11 @@ import { WarnTypeTagName, OkTypeTagName, ErrTypeTagName } from './tag.mjs';
14
14
  *
15
15
  * const notResult = { $$tag: 'ts-data-forge::Result.ok' };
16
16
  *
17
- * assert.ok(TernaryResult.isTernaryResult(okValue));
17
+ * assert.isTrue(TernaryResult.isTernaryResult(okValue));
18
18
  *
19
- * assert.ok(TernaryResult.isTernaryResult(warnValue));
19
+ * assert.isTrue(TernaryResult.isTernaryResult(warnValue));
20
20
  *
21
- * assert.ok(!TernaryResult.isTernaryResult(notResult));
21
+ * assert.isFalse(TernaryResult.isTernaryResult(notResult));
22
22
  * ```
23
23
  */
24
24
  const isTernaryResult = (maybeResult) => isRecord(maybeResult) &&
@@ -13,7 +13,8 @@ type ArgArrayIndex<Ar extends readonly unknown[]> =
13
13
 
14
14
  type ArgArrayIndexWithNegative<Ar extends readonly unknown[]> =
15
15
  IsFixedLengthList<Ar> extends true
16
- ? IndexOfTuple<[...Ar, 0]> | NegativeIndexOfTuple<Ar>
16
+ ? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
17
+ IndexOfTuple<[...Ar, 0]> | NegativeIndexOfTuple<Ar>
17
18
  : SizeType.ArgArrWithNegative;
18
19
 
19
20
  // https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/length
@@ -21,9 +21,9 @@
21
21
  *
22
22
  * if (hasKey(maybeUser, 'id')) {
23
23
  * // `maybeUser` is now known to have an `id` property.
24
- * assert(maybeUser.id === 42);
24
+ * assert.isTrue(maybeUser.id === 42);
25
25
  * } else {
26
- * assert.fail('Expected the object to contain the id key.');
26
+ * assert.fail();
27
27
  * }
28
28
  * ```
29
29
  *
@@ -45,5 +45,8 @@ export declare const hasKey: <const R extends UnknownRecord, const K extends Pro
45
45
  * If none of the elements in the union contain K as a key, returns `ReadonlyRecord<K, unknown>`.
46
46
  * The result is made readonly.
47
47
  */
48
- export type HasKeyReturnType<R extends UnknownRecord, K extends PropertyKey> = R extends R ? K extends keyof R ? string extends keyof R ? ReadonlyRecord<K, R[keyof R]> & R : number extends keyof R ? ReadonlyRecord<K, R[keyof R]> & R : symbol extends keyof R ? ReadonlyRecord<K, R[keyof R]> & R : R : never : never;
48
+ export type HasKeyReturnType<R extends UnknownRecord, K extends PropertyKey> = R extends R ? K extends keyof R ? string extends keyof R ? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
49
+ ReadonlyRecord<K, R[keyof R]> & R : number extends keyof R ? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
50
+ ReadonlyRecord<K, R[keyof R]> & R : symbol extends keyof R ? // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
51
+ ReadonlyRecord<K, R[keyof R]> & R : R : never : never;
49
52
  //# sourceMappingURL=has-key.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"has-key.d.mts","sourceRoot":"","sources":["../../src/guard/has-key.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,CAAC,CAAC,SAAS,aAAa,EAC7B,KAAK,CAAC,CAAC,SAAS,WAAW,EAE3B,KAAK,CAAC,EACN,KAAK,CAAC,KACL,GAAG,IAAI,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAA4B,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,aAAa,EACvB,CAAC,SAAS,WAAW,IACnB,CAAC,SAAS,CAAC,GACX,CAAC,SAAS,MAAM,CAAC,GACf,MAAM,SAAS,MAAM,CAAC,GACpB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GACjC,MAAM,SAAS,MAAM,CAAC,GACpB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GACjC,MAAM,SAAS,MAAM,CAAC,GACpB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GACjC,CAAC,GACP,KAAK,GACP,KAAK,CAAC"}
1
+ {"version":3,"file":"has-key.d.mts","sourceRoot":"","sources":["../../src/guard/has-key.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,CAAC,CAAC,SAAS,aAAa,EAC7B,KAAK,CAAC,CAAC,SAAS,WAAW,EAE3B,KAAK,CAAC,EACN,KAAK,CAAC,KACL,GAAG,IAAI,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAA4B,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,aAAa,EACvB,CAAC,SAAS,WAAW,IACnB,CAAC,SAAS,CAAC,GACX,CAAC,SAAS,MAAM,CAAC,GACf,MAAM,SAAS,MAAM,CAAC,GAEpB,AADA,6EAA6E;AAC7E,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GACjC,MAAM,SAAS,MAAM,CAAC,GAEpB,AADA,6EAA6E;AAC7E,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GACjC,MAAM,SAAS,MAAM,CAAC,GAEpB,AADA,6EAA6E;AAC7E,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GACjC,CAAC,GACP,KAAK,GACP,KAAK,CAAC"}
@@ -21,9 +21,9 @@
21
21
  *
22
22
  * if (hasKey(maybeUser, 'id')) {
23
23
  * // `maybeUser` is now known to have an `id` property.
24
- * assert(maybeUser.id === 42);
24
+ * assert.isTrue(maybeUser.id === 42);
25
25
  * } else {
26
- * assert.fail('Expected the object to contain the id key.');
26
+ * assert.fail();
27
27
  * }
28
28
  * ```
29
29
  *
@@ -23,9 +23,9 @@
23
23
  * const maybeKey: string = 'name';
24
24
  *
25
25
  * if (keyIsIn(maybeKey, user)) {
26
- * assert(user[maybeKey] === 'Ada');
26
+ * assert.isTrue(user[maybeKey] === 'Ada');
27
27
  * } else {
28
- * assert.fail('Expected a known key.');
28
+ * assert.fail();
29
29
  * }
30
30
  * ```
31
31
  *
@@ -23,9 +23,9 @@
23
23
  * const maybeKey: string = 'name';
24
24
  *
25
25
  * if (keyIsIn(maybeKey, user)) {
26
- * assert(user[maybeKey] === 'Ada');
26
+ * assert.isTrue(user[maybeKey] === 'Ada');
27
27
  * } else {
28
- * assert.fail('Expected a known key.');
28
+ * assert.fail();
29
29
  * }
30
30
  * ```
31
31
  *
@@ -23,13 +23,13 @@ export declare namespace Json {
23
23
  *
24
24
  * const failed = Json.parse(invalidJson);
25
25
  *
26
- * assert.ok(Result.isOk(parsed));
26
+ * assert.isTrue(Result.isOk(parsed));
27
27
  *
28
28
  * if (Result.isOk(parsed)) {
29
29
  * assert.deepStrictEqual(parsed.value, { name: 'Alice', age: 30 });
30
30
  * }
31
31
  *
32
- * assert.ok(Result.isErr(failed));
32
+ * assert.isTrue(Result.isErr(failed));
33
33
  *
34
34
  * // With reviver
35
35
  * const jsonWithDate = '{"created": "2024-01-01T00:00:00.000Z"}';
@@ -42,7 +42,7 @@ export declare namespace Json {
42
42
  * return value;
43
43
  * });
44
44
  *
45
- * assert.ok(Result.isOk(withReviver));
45
+ * assert.isTrue(Result.isOk(withReviver));
46
46
  * ```
47
47
  *
48
48
  * @param text - A valid JSON string to parse. Can contain any valid JSON data
@@ -75,16 +75,16 @@ export declare namespace Json {
75
75
  * // Basic stringify
76
76
  * const basic = Json.stringify(data);
77
77
  *
78
- * assert.ok(Result.isOk(basic));
78
+ * assert.isTrue(Result.isOk(basic));
79
79
  *
80
80
  * if (Result.isOk(basic)) {
81
- * assert(basic.value === '{"name":"Bob","age":25,"active":true}');
81
+ * assert.isTrue(basic.value === '{"name":"Bob","age":25,"active":true}');
82
82
  * }
83
83
  *
84
84
  * // With formatting
85
85
  * const formatted = Json.stringify(data, undefined, 2);
86
86
  *
87
- * assert.ok(Result.isOk(formatted));
87
+ * assert.isTrue(Result.isOk(formatted));
88
88
  *
89
89
  * // With replacer
90
90
  * const filtered = Json.stringify(data, (key, value) => {
@@ -93,12 +93,12 @@ export declare namespace Json {
93
93
  * return value;
94
94
  * });
95
95
  *
96
- * assert.ok(Result.isOk(filtered));
96
+ * assert.isTrue(Result.isOk(filtered));
97
97
  *
98
98
  * if (Result.isOk(filtered)) {
99
- * assert(isString(filtered.value));
99
+ * assert.isTrue(isString(filtered.value));
100
100
  *
101
- * assert.ok(!filtered.value.includes('age'));
101
+ * assert.isFalse(filtered.value.includes('age'));
102
102
  * }
103
103
  * ```
104
104
  *
@@ -146,10 +146,10 @@ export declare namespace Json {
146
146
  * // Select only safe properties to serialize
147
147
  * const safeJson = Json.stringifySelected(user, ['id', 'name', 'role']);
148
148
  *
149
- * assert.ok(Result.isOk(safeJson));
149
+ * assert.isTrue(Result.isOk(safeJson));
150
150
  *
151
151
  * if (Result.isOk(safeJson)) {
152
- * assert(isString(safeJson.value));
152
+ * assert.isTrue(isString(safeJson.value));
153
153
  *
154
154
  * const parsed: unknown = JSON.parse(safeJson.value);
155
155
  *
@@ -159,15 +159,15 @@ export declare namespace Json {
159
159
  * role: 'admin',
160
160
  * });
161
161
  *
162
- * assert.ok(!safeJson.value.includes('password'));
162
+ * assert.isFalse(safeJson.value.includes('password'));
163
163
  *
164
- * assert.ok(!safeJson.value.includes('email'));
164
+ * assert.isFalse(safeJson.value.includes('email'));
165
165
  * }
166
166
  *
167
167
  * // With formatting
168
168
  * const formatted = Json.stringifySelected(user, ['id', 'name'], 2);
169
169
  *
170
- * assert.ok(Result.isOk(formatted));
170
+ * assert.isTrue(Result.isOk(formatted));
171
171
  * ```
172
172
  *
173
173
  * @param value - The JavaScript value to serialize. While any value is
@@ -216,34 +216,34 @@ export declare namespace Json {
216
216
  * // Keys will be sorted alphabetically at all levels
217
217
  * const sorted = Json.stringifySortedKey(unorderedData);
218
218
  *
219
- * assert.ok(Result.isOk(sorted));
219
+ * assert.isTrue(Result.isOk(sorted));
220
220
  *
221
221
  * if (Result.isOk(sorted)) {
222
222
  * // Keys should appear in alphabetical order
223
223
  * const expected =
224
224
  * '{"apple":2,"mango":3,"nested":{"alpha":"a","beta":"b","zulu":"z"},"zebra":1}';
225
225
  *
226
- * assert(sorted.value === expected);
226
+ * assert.isTrue(sorted.value === expected);
227
227
  * }
228
228
  *
229
229
  * // With formatting
230
230
  * const formatted = Json.stringifySortedKey(unorderedData, 2);
231
231
  *
232
- * assert.ok(Result.isOk(formatted));
232
+ * assert.isTrue(Result.isOk(formatted));
233
233
  *
234
234
  * if (Result.isOk(formatted)) {
235
- * assert(isString(formatted.value));
235
+ * assert.isTrue(isString(formatted.value));
236
236
  *
237
237
  * // Check that keys are in order (first key should be "apple")
238
- * assert.ok(
238
+ * assert.isTrue(
239
239
  * formatted.value.indexOf('"apple"') < formatted.value.indexOf('"mango"'),
240
240
  * );
241
241
  *
242
- * assert.ok(
242
+ * assert.isTrue(
243
243
  * formatted.value.indexOf('"mango"') < formatted.value.indexOf('"nested"'),
244
244
  * );
245
245
  *
246
- * assert.ok(
246
+ * assert.isTrue(
247
247
  * formatted.value.indexOf('"nested"') < formatted.value.indexOf('"zebra"'),
248
248
  * );
249
249
  * }
@@ -67,13 +67,13 @@ var Json;
67
67
  *
68
68
  * const failed = Json.parse(invalidJson);
69
69
  *
70
- * assert.ok(Result.isOk(parsed));
70
+ * assert.isTrue(Result.isOk(parsed));
71
71
  *
72
72
  * if (Result.isOk(parsed)) {
73
73
  * assert.deepStrictEqual(parsed.value, { name: 'Alice', age: 30 });
74
74
  * }
75
75
  *
76
- * assert.ok(Result.isErr(failed));
76
+ * assert.isTrue(Result.isErr(failed));
77
77
  *
78
78
  * // With reviver
79
79
  * const jsonWithDate = '{"created": "2024-01-01T00:00:00.000Z"}';
@@ -86,7 +86,7 @@ var Json;
86
86
  * return value;
87
87
  * });
88
88
  *
89
- * assert.ok(Result.isOk(withReviver));
89
+ * assert.isTrue(Result.isOk(withReviver));
90
90
  * ```
91
91
  *
92
92
  * @param text - A valid JSON string to parse. Can contain any valid JSON data
@@ -129,16 +129,16 @@ var Json;
129
129
  * // Basic stringify
130
130
  * const basic = Json.stringify(data);
131
131
  *
132
- * assert.ok(Result.isOk(basic));
132
+ * assert.isTrue(Result.isOk(basic));
133
133
  *
134
134
  * if (Result.isOk(basic)) {
135
- * assert(basic.value === '{"name":"Bob","age":25,"active":true}');
135
+ * assert.isTrue(basic.value === '{"name":"Bob","age":25,"active":true}');
136
136
  * }
137
137
  *
138
138
  * // With formatting
139
139
  * const formatted = Json.stringify(data, undefined, 2);
140
140
  *
141
- * assert.ok(Result.isOk(formatted));
141
+ * assert.isTrue(Result.isOk(formatted));
142
142
  *
143
143
  * // With replacer
144
144
  * const filtered = Json.stringify(data, (key, value) => {
@@ -147,12 +147,12 @@ var Json;
147
147
  * return value;
148
148
  * });
149
149
  *
150
- * assert.ok(Result.isOk(filtered));
150
+ * assert.isTrue(Result.isOk(filtered));
151
151
  *
152
152
  * if (Result.isOk(filtered)) {
153
- * assert(isString(filtered.value));
153
+ * assert.isTrue(isString(filtered.value));
154
154
  *
155
- * assert.ok(!filtered.value.includes('age'));
155
+ * assert.isFalse(filtered.value.includes('age'));
156
156
  * }
157
157
  * ```
158
158
  *
@@ -208,10 +208,10 @@ var Json;
208
208
  * // Select only safe properties to serialize
209
209
  * const safeJson = Json.stringifySelected(user, ['id', 'name', 'role']);
210
210
  *
211
- * assert.ok(Result.isOk(safeJson));
211
+ * assert.isTrue(Result.isOk(safeJson));
212
212
  *
213
213
  * if (Result.isOk(safeJson)) {
214
- * assert(isString(safeJson.value));
214
+ * assert.isTrue(isString(safeJson.value));
215
215
  *
216
216
  * const parsed: unknown = JSON.parse(safeJson.value);
217
217
  *
@@ -221,15 +221,15 @@ var Json;
221
221
  * role: 'admin',
222
222
  * });
223
223
  *
224
- * assert.ok(!safeJson.value.includes('password'));
224
+ * assert.isFalse(safeJson.value.includes('password'));
225
225
  *
226
- * assert.ok(!safeJson.value.includes('email'));
226
+ * assert.isFalse(safeJson.value.includes('email'));
227
227
  * }
228
228
  *
229
229
  * // With formatting
230
230
  * const formatted = Json.stringifySelected(user, ['id', 'name'], 2);
231
231
  *
232
- * assert.ok(Result.isOk(formatted));
232
+ * assert.isTrue(Result.isOk(formatted));
233
233
  * ```
234
234
  *
235
235
  * @param value - The JavaScript value to serialize. While any value is
@@ -286,34 +286,34 @@ var Json;
286
286
  * // Keys will be sorted alphabetically at all levels
287
287
  * const sorted = Json.stringifySortedKey(unorderedData);
288
288
  *
289
- * assert.ok(Result.isOk(sorted));
289
+ * assert.isTrue(Result.isOk(sorted));
290
290
  *
291
291
  * if (Result.isOk(sorted)) {
292
292
  * // Keys should appear in alphabetical order
293
293
  * const expected =
294
294
  * '{"apple":2,"mango":3,"nested":{"alpha":"a","beta":"b","zulu":"z"},"zebra":1}';
295
295
  *
296
- * assert(sorted.value === expected);
296
+ * assert.isTrue(sorted.value === expected);
297
297
  * }
298
298
  *
299
299
  * // With formatting
300
300
  * const formatted = Json.stringifySortedKey(unorderedData, 2);
301
301
  *
302
- * assert.ok(Result.isOk(formatted));
302
+ * assert.isTrue(Result.isOk(formatted));
303
303
  *
304
304
  * if (Result.isOk(formatted)) {
305
- * assert(isString(formatted.value));
305
+ * assert.isTrue(isString(formatted.value));
306
306
  *
307
307
  * // Check that keys are in order (first key should be "apple")
308
- * assert.ok(
308
+ * assert.isTrue(
309
309
  * formatted.value.indexOf('"apple"') < formatted.value.indexOf('"mango"'),
310
310
  * );
311
311
  *
312
- * assert.ok(
312
+ * assert.isTrue(
313
313
  * formatted.value.indexOf('"mango"') < formatted.value.indexOf('"nested"'),
314
314
  * );
315
315
  *
316
- * assert.ok(
316
+ * assert.isTrue(
317
317
  * formatted.value.indexOf('"nested"') < formatted.value.indexOf('"zebra"'),
318
318
  * );
319
319
  * }