ts-data-forge 6.8.0 → 6.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
- package/dist/array/impl/array-utils-set-op.mjs +1 -3
- package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +2 -6
- package/dist/array/impl/array-utils-validation.mjs.map +1 -1
- package/dist/object/object.d.mts +52 -0
- package/dist/object/object.d.mts.map +1 -1
- package/dist/object/object.mjs +103 -1
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/fast-deep-equal.d.mts.map +1 -1
- package/dist/others/fast-deep-equal.mjs +0 -1
- package/dist/others/fast-deep-equal.mjs.map +1 -1
- package/package.json +20 -20
- package/src/array/impl/array-utils-overload-type-error.test.mts +2 -4
- package/src/array/impl/array-utils-set-op.mts +0 -1
- package/src/array/impl/array-utils-validation.mts +2 -6
- package/src/functional/optional.test.mts +5 -7
- package/src/functional/result.test.mts +8 -10
- package/src/functional/ternary-result.test.mts +4 -4
- package/src/json/json.test.mts +5 -5
- package/src/number/branded-types/finite-number.test.mts +11 -15
- package/src/number/branded-types/int.test.mts +13 -13
- package/src/number/branded-types/int16.test.mts +15 -15
- package/src/number/branded-types/int32.test.mts +15 -15
- package/src/number/branded-types/non-negative-finite-number.test.mts +15 -19
- package/src/number/branded-types/non-negative-int16.test.mts +15 -15
- package/src/number/branded-types/non-negative-int32.test.mts +15 -15
- package/src/number/branded-types/non-zero-finite-number.test.mts +18 -18
- package/src/number/branded-types/non-zero-int.test.mts +14 -18
- package/src/number/branded-types/non-zero-int16.test.mts +15 -19
- package/src/number/branded-types/non-zero-int32.test.mts +15 -19
- package/src/number/branded-types/non-zero-safe-int.test.mts +18 -22
- package/src/number/branded-types/non-zero-uint16.test.mts +15 -15
- package/src/number/branded-types/non-zero-uint32.test.mts +15 -15
- package/src/number/branded-types/positive-finite-number.test.mts +18 -18
- package/src/number/branded-types/positive-int.test.mts +16 -22
- package/src/number/branded-types/positive-int16.test.mts +14 -14
- package/src/number/branded-types/positive-int32.test.mts +14 -14
- package/src/number/branded-types/positive-safe-int.test.mts +18 -20
- package/src/number/branded-types/positive-uint16.test.mts +15 -15
- package/src/number/branded-types/positive-uint32.test.mts +15 -15
- package/src/number/branded-types/safe-int.test.mts +17 -21
- package/src/number/branded-types/safe-uint.test.mts +16 -22
- package/src/number/branded-types/uint.test.mts +14 -14
- package/src/number/branded-types/uint16.test.mts +14 -14
- package/src/number/branded-types/uint32.test.mts +14 -14
- package/src/number/enum/int8.test.mts +1 -1
- package/src/number/enum/uint8.test.mts +1 -1
- package/src/object/object.mts +170 -1
- package/src/object/object.test.mts +172 -0
- package/src/others/fast-deep-equal.mts +0 -1
- package/src/others/unknown-to-string.test.mts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-set-op.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-set-op.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,EAAE,GAAI,CAAC,EAClB,QAAQ,SAAS,CAAC,EAAE,EACpB,QAAQ,SAAS,CAAC,EAAE,EACpB,WAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAmB,KAC5C,
|
|
1
|
+
{"version":3,"file":"array-utils-set-op.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-set-op.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,EAAE,GAAI,CAAC,EAClB,QAAQ,SAAS,CAAC,EAAE,EACpB,QAAQ,SAAS,CAAC,EAAE,EACpB,WAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAmB,KAC5C,OAG8C,CAAC;AAElD;;;;GAIG;AACH,eA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|
*/
|
|
18
|
-
const eq = (array1, array2, equality = Object.is) =>
|
|
19
|
-
// eslint-disable-next-line ts-data-forge/prefer-arr-is-array-of-length
|
|
20
|
-
array1.length === array2.length &&
|
|
18
|
+
const eq = (array1, array2, equality = Object.is) => array1.length === array2.length &&
|
|
21
19
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
22
20
|
array1.every((v, i) => equality(v, array2[i]));
|
|
23
21
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-set-op.mjs","sources":["../../../src/array/impl/array-utils-set-op.mts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;AAgBG;
|
|
1
|
+
{"version":3,"file":"array-utils-set-op.mjs","sources":["../../../src/array/impl/array-utils-set-op.mts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;AAgBG;MACU,EAAE,GAAG,CAChB,MAAoB,EACpB,MAAoB,EACpB,QAAA,GAAoC,MAAM,CAAC,EAAE,KAE7C,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;;IAE/B,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAE,CAAC;AAEhD;;;;AAIG;AACI,MAAM,KAAK,GAAG;AAErB;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,QAAQ,GAAG,CACtB,MAAqB,EACrB,MAAqB,KAErB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACb;AACA,MAAM,CAAC,QAAQ,CAAC,CAAY,CAAC;AAGjC;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,UAAU,GAAG,CACxB,MAAqB,EACrB,MAAqB,KACT,QAAQ,CAAC,MAAM,EAAE,MAAM;AAErC;;;;;;;;;;;;;;AAcG;MACU,eAAe,GAAG,CAI7B,MAAqB,EACrB,MAAqB;AAErB;AACA;AACC,MAA+B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AAE,KAAK,OAAO,CAAC;AAyBpC;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAC9B,OAAO,SAAS,CAAC,EAAE,EACnB,OAAO,QAAQ,CAAC,MAAM,KACrB,OAAgD,CAAC"}
|
|
@@ -115,9 +115,7 @@ array.length > 0;
|
|
|
115
115
|
* }
|
|
116
116
|
* ```
|
|
117
117
|
*/
|
|
118
|
-
const isArrayOfLength = (array, len) =>
|
|
119
|
-
// eslint-disable-next-line ts-data-forge/prefer-arr-is-array-of-length
|
|
120
|
-
array.length === len;
|
|
118
|
+
const isArrayOfLength = (array, len) => array.length === len;
|
|
121
119
|
/**
|
|
122
120
|
* Checks if an array has at least a specific length.
|
|
123
121
|
*
|
|
@@ -137,9 +135,7 @@ array.length === len;
|
|
|
137
135
|
* }
|
|
138
136
|
* ```
|
|
139
137
|
*/
|
|
140
|
-
const isArrayAtLeastLength = (array, len) =>
|
|
141
|
-
// eslint-disable-next-line ts-data-forge/prefer-arr-is-array-at-least-length
|
|
142
|
-
array.length >= len;
|
|
138
|
+
const isArrayAtLeastLength = (array, len) => array.length >= len;
|
|
143
139
|
function every(...args) {
|
|
144
140
|
switch (args.length) {
|
|
145
141
|
case 2: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-validation.mjs","sources":["../../../src/array/impl/array-utils-validation.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,OAAO,GAAG,CAAK,KAAQ;AAClC;AACA,KAAK,CAAC,OAAO,CAAC,KAAK;AAarB;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,OAAO,GAAG,CAAK,KAAmB;AAC7C;AACA,KAAK,CAAC,MAAM,KAAK;AAEnB;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,UAAU,GAAG,CACxB,KAAmB;AAEnB;AACA,KAAK,CAAC,MAAM,GAAG;AAEjB;;;;;;;;;;;;;;;;;;AAkBG;
|
|
1
|
+
{"version":3,"file":"array-utils-validation.mjs","sources":["../../../src/array/impl/array-utils-validation.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,OAAO,GAAG,CAAK,KAAQ;AAClC;AACA,KAAK,CAAC,OAAO,CAAC,KAAK;AAarB;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,OAAO,GAAG,CAAK,KAAmB;AAC7C;AACA,KAAK,CAAC,MAAM,KAAK;AAEnB;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,UAAU,GAAG,CACxB,KAAmB;AAEnB;AACA,KAAK,CAAC,MAAM,GAAG;AAEjB;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,eAAe,GAAG,CAC7B,KAAmB,EACnB,GAAM,KAC2B,KAAK,CAAC,MAAM,KAAK;AAEpD;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,oBAAoB,GAAG,CAClC,KAAmB,EACnB,GAAM,KAC6B,KAAK,CAAC,MAAM,IAAI;AAyC/C,SAAU,KAAK,CACnB,GAAG,IAK6D,EAAA;AAEhE,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,IAAI;YAE/B,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD;QAEA,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI;YAExB,OAAO,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC;QAC3C;;AAEJ;AA8BM,SAAU,IAAI,CAClB,GAAG,IAK6D,EAAA;AAEhE,IAAA,QAAQ,IAAI,CAAC,MAAM;QACjB,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,IAAI;YAE/B,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD;QAEA,KAAK,CAAC,EAAE;AACN,YAAA,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI;YAExB,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC;QAC1C;;AAEJ;AAEA;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,cAAc,GAAG,CAC5B,KAAmB,EACnB,KAAsB,KACV,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK;;;;"}
|
package/dist/object/object.d.mts
CHANGED
|
@@ -211,6 +211,58 @@ export declare namespace Obj {
|
|
|
211
211
|
* @returns A new record with all properties merged
|
|
212
212
|
*/
|
|
213
213
|
const merge: <const Records extends readonly UnknownRecord[]>(...records: Records) => TsDataForgeInternals.MergeAll<Records>;
|
|
214
|
+
/**
|
|
215
|
+
* Deeply picks a nested property from an object along the specified key path.
|
|
216
|
+
* Supports both direct and curried usage.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
*
|
|
220
|
+
* ```ts
|
|
221
|
+
* const data = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 } as const;
|
|
222
|
+
*
|
|
223
|
+
* // Direct usage
|
|
224
|
+
* const result = Obj.deepPick(data, ['a', 'b', 'c']);
|
|
225
|
+
* assert.deepStrictEqual(result, { a: { b: { c: 1 } } });
|
|
226
|
+
*
|
|
227
|
+
* // Curried usage with pipe
|
|
228
|
+
* const pickName = Obj.deepPick(['user', 'name']);
|
|
229
|
+
* const result2 = pipe(data).map(pickName).value;
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* @template R - The type of the input record
|
|
233
|
+
* @template Path - The key path tuple
|
|
234
|
+
* @param record - The source record
|
|
235
|
+
* @param path - A readonly tuple of keys representing the nested path
|
|
236
|
+
* @returns A new record containing only the nested property at the path
|
|
237
|
+
*/
|
|
238
|
+
function deepPick<const R extends UnknownRecord, const Path extends readonly (string | number)[]>(record: R, path: Path): DeepPick<R, Path>;
|
|
239
|
+
function deepPick<const Path extends readonly (string | number)[]>(path: Path): <const R extends UnknownRecord>(record: R) => DeepPick<R, Path>;
|
|
240
|
+
/**
|
|
241
|
+
* Deeply omits a nested property from an object along the specified key path.
|
|
242
|
+
* Supports both direct and curried usage.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
*
|
|
246
|
+
* ```ts
|
|
247
|
+
* const data = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 } as const;
|
|
248
|
+
*
|
|
249
|
+
* // Direct usage
|
|
250
|
+
* const result = Obj.deepOmit(data, ['a', 'b', 'c']);
|
|
251
|
+
* assert.deepStrictEqual(result, { a: { b: { d: 2 }, e: 3 }, f: 4 });
|
|
252
|
+
*
|
|
253
|
+
* // Curried usage with pipe
|
|
254
|
+
* const omitPassword = Obj.deepOmit(['user', 'password']);
|
|
255
|
+
* const result2 = pipe(data).map(omitPassword).value;
|
|
256
|
+
* ```
|
|
257
|
+
*
|
|
258
|
+
* @template R - The type of the input record
|
|
259
|
+
* @template Path - The key path tuple
|
|
260
|
+
* @param record - The source record
|
|
261
|
+
* @param path - A readonly tuple of keys representing the nested path to omit
|
|
262
|
+
* @returns A new record with the nested property at the path removed
|
|
263
|
+
*/
|
|
264
|
+
function deepOmit<const R extends UnknownRecord, const Path extends readonly (string | number)[]>(record: R, path: Path): DeepOmit<R, Path>;
|
|
265
|
+
function deepOmit<const Path extends readonly (string | number)[]>(path: Path): <const R extends UnknownRecord>(record: R) => DeepOmit<R, Path>;
|
|
214
266
|
}
|
|
215
267
|
/**
|
|
216
268
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.mts","sourceRoot":"","sources":["../../src/object/object.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"object.d.mts","sourceRoot":"","sources":["../../src/object/object.mts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,yBAAiB,GAAG,CAAC;IACnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;IACI,MAAM,SAAS,GACpB,GAAG,aAAa,EAChB,GAAG,aAAa,EAChB,KAAI,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,KAAK,OAAmB,KAClD,OAQF,CAAC;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACH,SAAgB,IAAI,CAClB,KAAK,CAAC,CAAC,SAAS,aAAa,EAC7B,KAAK,CAAC,IAAI,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EACvC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAGtD,SAAgB,IAAI,CAAC,KAAK,CAAC,IAAI,SAAS,SAAS,WAAW,EAAE,EAC5D,IAAI,EAAE,IAAI,GACT,CAAC,KAAK,CAAC,CAAC,SAAS,aAAa,EAC/B,MAAM,EAAE,CAAC,KACN,WAAW,CAAC,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAgCxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,SAAgB,IAAI,CAClB,KAAK,CAAC,CAAC,SAAS,aAAa,EAC7B,KAAK,CAAC,IAAI,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EACvC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,IAA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EAAE,CAAC,CAAC,GAC7D,KAAK,GACL,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KACb,GAAG;QAGF,QAAQ,EAAE,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAC7D,CAAC,GACD,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAClB,SAAS,MAAM,CAAC,GACb,QAAQ,CACN;SAEG,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAC1D,GAAG;SAED,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAC3D,CACF,GACD,KAAK,CAAC;IAEV,sEAAsE;IACtE,KAAY,QAAQ,CAClB,OAAO,SAAS,SAAS,aAAa,EAAE,EAExC,GAAG,SAAS,aAAa,GAAG,EAAE,IAE9B,iBAAiB,CAAC,OAAO,CAAC,SAAS,KAAK,GACpC,YAAY,CAAC,OAAO,CAAC,GACrB,OAAO,SAAS,SAAS;QACrB,MAAM,KAAK,SAAS,aAAa;QACjC,GAAG,MAAM,IAAI,SAAS,SAAS,aAAa,EAAE;KAC/C,GACD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,GACpC,GAAG,CAAC;CACb"}
|
package/dist/object/object.mjs
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
import '../number/branded-types/finite-number.mjs';
|
|
2
|
+
import '../number/branded-types/int.mjs';
|
|
3
|
+
import '../number/branded-types/int16.mjs';
|
|
4
|
+
import '../number/branded-types/int32.mjs';
|
|
5
|
+
import '../number/branded-types/non-negative-finite-number.mjs';
|
|
6
|
+
import '../number/branded-types/non-negative-int16.mjs';
|
|
7
|
+
import '../number/branded-types/non-negative-int32.mjs';
|
|
8
|
+
import '../number/branded-types/non-zero-finite-number.mjs';
|
|
9
|
+
import '../number/branded-types/non-zero-int.mjs';
|
|
10
|
+
import '../number/branded-types/non-zero-int16.mjs';
|
|
11
|
+
import '../number/branded-types/non-zero-int32.mjs';
|
|
12
|
+
import '../number/branded-types/non-zero-safe-int.mjs';
|
|
13
|
+
import '../number/branded-types/non-zero-uint16.mjs';
|
|
14
|
+
import '../number/branded-types/non-zero-uint32.mjs';
|
|
15
|
+
import '../number/branded-types/positive-finite-number.mjs';
|
|
16
|
+
import '../number/branded-types/positive-int.mjs';
|
|
17
|
+
import '../number/branded-types/positive-int16.mjs';
|
|
18
|
+
import '../number/branded-types/positive-int32.mjs';
|
|
19
|
+
import '../number/branded-types/positive-safe-int.mjs';
|
|
20
|
+
import '../number/branded-types/positive-uint16.mjs';
|
|
21
|
+
import '../number/branded-types/positive-uint32.mjs';
|
|
22
|
+
import '../number/branded-types/safe-int.mjs';
|
|
23
|
+
import '../number/branded-types/safe-uint.mjs';
|
|
24
|
+
import '../number/branded-types/uint.mjs';
|
|
25
|
+
import '../number/branded-types/uint16.mjs';
|
|
26
|
+
import '../number/branded-types/uint32.mjs';
|
|
27
|
+
import '../number/enum/int8.mjs';
|
|
28
|
+
import '../number/enum/uint8.mjs';
|
|
29
|
+
import '../number/num.mjs';
|
|
30
|
+
import '../number/refined-number-utils.mjs';
|
|
31
|
+
import { hasKey } from '../guard/has-key.mjs';
|
|
32
|
+
import { isRecord } from '../guard/is-record.mjs';
|
|
33
|
+
import '@sindresorhus/is';
|
|
34
|
+
import '../collections/imap-mapped.mjs';
|
|
35
|
+
import '../collections/imap.mjs';
|
|
36
|
+
import '../collections/iset-mapped.mjs';
|
|
37
|
+
import '../collections/iset.mjs';
|
|
38
|
+
import { isNonEmpty } from '../array/impl/array-utils-validation.mjs';
|
|
39
|
+
|
|
1
40
|
/**
|
|
2
41
|
* A collection of type-safe object utility functions providing functional
|
|
3
42
|
* programming patterns for object manipulation, including pick, omit, shallow
|
|
@@ -53,7 +92,6 @@ var Obj;
|
|
|
53
92
|
Obj.shallowEq = (a, b, eq = Object.is) => {
|
|
54
93
|
const aEntries = Object.entries(a);
|
|
55
94
|
const bEntries = Object.entries(b);
|
|
56
|
-
// eslint-disable-next-line ts-data-forge/prefer-arr-is-array-of-length
|
|
57
95
|
if (aEntries.length !== bEntries.length)
|
|
58
96
|
return false;
|
|
59
97
|
return aEntries.every(([k, v]) => eq(b[k], v));
|
|
@@ -167,7 +205,71 @@ var Obj;
|
|
|
167
205
|
Obj.merge = (...records) =>
|
|
168
206
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
169
207
|
Object.fromEntries(records.flatMap((r) => Object.entries(r)));
|
|
208
|
+
function deepPick(...args) {
|
|
209
|
+
switch (args.length) {
|
|
210
|
+
case 2: {
|
|
211
|
+
const [record, path] = args;
|
|
212
|
+
return (
|
|
213
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
214
|
+
deepPickImpl(record, path));
|
|
215
|
+
}
|
|
216
|
+
case 1: {
|
|
217
|
+
const [path] = args;
|
|
218
|
+
return (record) => deepPick(record, path);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
Obj.deepPick = deepPick;
|
|
223
|
+
function deepOmit(...args) {
|
|
224
|
+
switch (args.length) {
|
|
225
|
+
case 2: {
|
|
226
|
+
const [record, path] = args;
|
|
227
|
+
return (
|
|
228
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
229
|
+
deepOmitImpl(record, path));
|
|
230
|
+
}
|
|
231
|
+
case 1: {
|
|
232
|
+
const [path] = args;
|
|
233
|
+
return (record) => deepOmit(record, path);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
Obj.deepOmit = deepOmit;
|
|
170
238
|
})(Obj || (Obj = {}));
|
|
239
|
+
const deepPickImpl = (record, path) => {
|
|
240
|
+
if (!isNonEmpty(path))
|
|
241
|
+
return record;
|
|
242
|
+
const head = path[0];
|
|
243
|
+
if (!hasKey(record, head))
|
|
244
|
+
return {};
|
|
245
|
+
const value = record[head];
|
|
246
|
+
const tail = path.slice(1);
|
|
247
|
+
if (!isNonEmpty(tail))
|
|
248
|
+
return { [head]: value };
|
|
249
|
+
if (!isRecord(value))
|
|
250
|
+
return { [head]: {} };
|
|
251
|
+
return {
|
|
252
|
+
[head]: deepPickImpl(value, tail),
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
const deepOmitImpl = (record, path) => {
|
|
256
|
+
if (!isNonEmpty(path))
|
|
257
|
+
return record;
|
|
258
|
+
const head = path[0];
|
|
259
|
+
const tail = path.slice(1);
|
|
260
|
+
if (!hasKey(record, head))
|
|
261
|
+
return record;
|
|
262
|
+
if (!isNonEmpty(tail)) {
|
|
263
|
+
return Object.fromEntries(Object.entries(record).filter(([k]) => k !== head));
|
|
264
|
+
}
|
|
265
|
+
const value = record[head];
|
|
266
|
+
if (!isRecord(value))
|
|
267
|
+
return record;
|
|
268
|
+
return {
|
|
269
|
+
...record,
|
|
270
|
+
[head]: deepOmitImpl(value, tail),
|
|
271
|
+
};
|
|
272
|
+
};
|
|
171
273
|
|
|
172
274
|
export { Obj };
|
|
173
275
|
//# sourceMappingURL=object.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.mjs","sources":["../../src/object/object.mts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"object.mjs","sources":["../../src/object/object.mts"],"sourcesContent":[null],"names":["Arr.isNonEmpty"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;AAOG;AACG,IAAW;AAAjB,CAAA,UAAiB,GAAG,EAAA;AAClB;;;;;;;;;;;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E,QAAA,OAAO,EAAE,CAAC,IAAI,GAAG,EAAE,EAAE;IAE3C,OAAO;QACL,CAAC,IAAI,GAAG,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC;KAClC;AACH,CAAC;AAED,MAAM,YAAY,GAAG,CACnB,MAAqB,EACrB,IAAkC,KACjB;AACjB,IAAA,IAAI,CAACA,UAAc,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,MAAM;AAExC,IAAA,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC;IAEpB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAE1B,IAAA,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;AAAE,QAAA,OAAO,MAAM;IAExC,IAAI,CAACA,UAAc,CAAC,IAAI,CAAC,EAAE;QACzB,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CACnD;IACH;AAEA,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;AAE1B,IAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,MAAM;IAEnC,OAAO;AACL,QAAA,GAAG,MAAM;QACT,CAAC,IAAI,GAAG,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC;KAClC;AACH,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-deep-equal.d.mts","sourceRoot":"","sources":["../../src/others/fast-deep-equal.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fast-deep-equal.d.mts","sourceRoot":"","sources":["../../src/others/fast-deep-equal.mts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,EAAG,GAAG,CAAC,EAAE,GAAG,CAAC,KAAG,OAqF9C,CAAC"}
|
|
@@ -2,7 +2,6 @@ import { isMap, isSet, isTypedArray, isRegExp } from '@sindresorhus/is';
|
|
|
2
2
|
import { hasKey } from '../guard/has-key.mjs';
|
|
3
3
|
import { isRecord } from '../guard/is-record.mjs';
|
|
4
4
|
|
|
5
|
-
/* eslint-disable ts-data-forge/prefer-arr-is-array-of-length */
|
|
6
5
|
/* eslint-disable ts-data-forge/prefer-arr-is-array */
|
|
7
6
|
/**
|
|
8
7
|
* The fastest deep equal with ES6 Map, Set and Typed arrays support.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-deep-equal.mjs","sources":["../../src/others/fast-deep-equal.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;
|
|
1
|
+
{"version":3,"file":"fast-deep-equal.mjs","sources":["../../src/others/fast-deep-equal.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;AAKA;;;;;AAKG;MACU,aAAa,GAAG,CAAK,CAAI,EAAE,CAAI,KAAa;AACvD,IAAA,IAAI,CAAC,KAAK,CAAC,EAAE;AACX,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,IAAI,OAAO,CAAC,KAAK,OAAO,CAAC,EAAE;AACzB,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE;AACf,QAAA,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;AAChB,YAAA,OAAO,KAAK;QACd;QAEA,IAAI,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,EAAE;AACnC,YAAA,OAAO,KAAK;QACd;AAEA,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;AACpB,YAAA,QACE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,gBAAA,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;gBACrB,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,KAAK,KAAK,aAAa,CAAC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K,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE;YAC1C,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE;QACpC;QAEA,IAAI,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC5C,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE;QACtC;QAEA,MAAM,KAAK,GAAsB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAE/C,MAAM,KAAK,GAAsB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAE/C,QAAA,QACE,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;AAC7B,YAAA,KAAK,CAAC,KAAK,CACT,CAAC,GAAG,KACF,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC;;;;;gBAKd,EAAE,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC;AACpC,gBAAA,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAChC;IAEL;;AAGA,IAAA,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3C;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-data-forge",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.9.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"z:vitest:node": "pnpm run z:vitest --project='Node.js'"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@sindresorhus/is": "^
|
|
86
|
-
"ts-type-forge": "^2.
|
|
85
|
+
"@sindresorhus/is": "^8.0.0",
|
|
86
|
+
"ts-type-forge": "^2.4.0"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
89
|
"@emotion/react": "11.14.0",
|
|
@@ -99,48 +99,48 @@
|
|
|
99
99
|
"@semantic-release/github": "12.0.6",
|
|
100
100
|
"@semantic-release/npm": "13.1.5",
|
|
101
101
|
"@semantic-release/release-notes-generator": "14.1.0",
|
|
102
|
-
"@types/node": "25.5.
|
|
102
|
+
"@types/node": "25.5.2",
|
|
103
103
|
"@types/react": "19.2.14",
|
|
104
|
-
"@vitest/browser-playwright": "4.
|
|
105
|
-
"@vitest/coverage-v8": "4.
|
|
106
|
-
"@vitest/ui": "4.
|
|
107
|
-
"conventional-changelog-conventionalcommits": "9.3.
|
|
108
|
-
"cspell": "
|
|
104
|
+
"@vitest/browser-playwright": "4.1.2",
|
|
105
|
+
"@vitest/coverage-v8": "4.1.2",
|
|
106
|
+
"@vitest/ui": "4.1.2",
|
|
107
|
+
"conventional-changelog-conventionalcommits": "9.3.1",
|
|
108
|
+
"cspell": "10.0.0",
|
|
109
109
|
"dedent": "^1.7.2",
|
|
110
110
|
"eslint": "9.39.4",
|
|
111
|
-
"eslint-config-typed": "4.
|
|
112
|
-
"github-settings-as-code": "1.2.
|
|
111
|
+
"eslint-config-typed": "4.8.0",
|
|
112
|
+
"github-settings-as-code": "1.2.2",
|
|
113
113
|
"immer": "11.1.4",
|
|
114
114
|
"jiti": "2.6.1",
|
|
115
115
|
"markdownlint": "0.40.0",
|
|
116
|
-
"markdownlint-cli2": "0.
|
|
116
|
+
"markdownlint-cli2": "0.22.0",
|
|
117
117
|
"npm-run-all2": "8.0.4",
|
|
118
118
|
"playwright": "1.58.2",
|
|
119
119
|
"prettier": "3.8.1",
|
|
120
120
|
"prettier-plugin-organize-imports": "4.3.0",
|
|
121
121
|
"prettier-plugin-packagejson": "3.0.2",
|
|
122
122
|
"react": "^19.2.4",
|
|
123
|
-
"rollup": "4.
|
|
123
|
+
"rollup": "4.60.1",
|
|
124
124
|
"semantic-release": "25.0.3",
|
|
125
125
|
"ts-codemod-lib": "^2.1.1",
|
|
126
126
|
"ts-repo-utils": "9.0.0",
|
|
127
127
|
"tslib": "2.8.1",
|
|
128
128
|
"tsx": "4.21.0",
|
|
129
|
-
"typedoc": "0.28.
|
|
129
|
+
"typedoc": "0.28.18",
|
|
130
130
|
"typedoc-github-theme": "0.4.0",
|
|
131
131
|
"typescript": "5.9.3",
|
|
132
|
-
"vite": "
|
|
133
|
-
"vitest": "4.
|
|
132
|
+
"vite": "8.0.8",
|
|
133
|
+
"vitest": "4.1.2"
|
|
134
134
|
},
|
|
135
135
|
"peerDependencies": {
|
|
136
136
|
"typescript": ">=4.8"
|
|
137
137
|
},
|
|
138
|
-
"packageManager": "pnpm@10.
|
|
138
|
+
"packageManager": "pnpm@10.33.1",
|
|
139
139
|
"engines": {
|
|
140
|
-
"node": ">=
|
|
141
|
-
"pnpm": ">=
|
|
140
|
+
"node": ">=22.12.0",
|
|
141
|
+
"pnpm": ">=9.0.0"
|
|
142
142
|
},
|
|
143
143
|
"volta": {
|
|
144
|
-
"node": "25.
|
|
144
|
+
"node": "25.9.0"
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -93,7 +93,7 @@ describe('Array overloaded functions - type error validation', () => {
|
|
|
93
93
|
|
|
94
94
|
test('partition type constraints work correctly', () => {
|
|
95
95
|
// @ts-expect-error - Partition size should be number, not string
|
|
96
|
-
expect(() => partition(testArray, 'invalid')).
|
|
96
|
+
expect(() => partition(testArray, 'invalid')).toThrow(
|
|
97
97
|
'Expected a non-negative integer less than 2^32, got: NaN',
|
|
98
98
|
);
|
|
99
99
|
|
|
@@ -116,9 +116,7 @@ describe('Array overloaded functions - type error validation', () => {
|
|
|
116
116
|
|
|
117
117
|
test('range type constraints work correctly', () => {
|
|
118
118
|
// @ts-expect-error - Range bounds should be numbers, not strings
|
|
119
|
-
expect(() => range('1', '5')).
|
|
120
|
-
'Expected a safe integer, got: 1',
|
|
121
|
-
);
|
|
119
|
+
expect(() => range('1', '5')).toThrow('Expected a safe integer, got: 1');
|
|
122
120
|
|
|
123
121
|
// @ts-expect-error - Step should be number, not string
|
|
124
122
|
range(1, 5, 'invalid');
|
|
@@ -20,7 +20,6 @@ export const eq = <E,>(
|
|
|
20
20
|
array2: readonly E[],
|
|
21
21
|
equality: (a: E, b: E) => boolean = Object.is,
|
|
22
22
|
): boolean =>
|
|
23
|
-
// eslint-disable-next-line ts-data-forge/prefer-arr-is-array-of-length
|
|
24
23
|
array1.length === array2.length &&
|
|
25
24
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
26
25
|
array1.every((v, i) => equality(v, array2[i]!));
|
|
@@ -106,9 +106,7 @@ export const isNonEmpty = <E,>(
|
|
|
106
106
|
export const isArrayOfLength = <E, N extends SizeType.ArgArr>(
|
|
107
107
|
array: readonly E[],
|
|
108
108
|
len: N,
|
|
109
|
-
): array is ArrayOfLength<N, E> =>
|
|
110
|
-
// eslint-disable-next-line ts-data-forge/prefer-arr-is-array-of-length
|
|
111
|
-
array.length === len;
|
|
109
|
+
): array is ArrayOfLength<N, E> => array.length === len;
|
|
112
110
|
|
|
113
111
|
/**
|
|
114
112
|
* Checks if an array has at least a specific length.
|
|
@@ -132,9 +130,7 @@ export const isArrayOfLength = <E, N extends SizeType.ArgArr>(
|
|
|
132
130
|
export const isArrayAtLeastLength = <E, N extends SizeType.ArgArr>(
|
|
133
131
|
array: readonly E[],
|
|
134
132
|
len: N,
|
|
135
|
-
): array is ArrayAtLeastLen<N, E> =>
|
|
136
|
-
// eslint-disable-next-line ts-data-forge/prefer-arr-is-array-at-least-length
|
|
137
|
-
array.length >= len;
|
|
133
|
+
): array is ArrayAtLeastLen<N, E> => array.length >= len;
|
|
138
134
|
|
|
139
135
|
/**
|
|
140
136
|
* Tests whether all elements in an array pass a test implemented by a predicate.
|
|
@@ -218,7 +218,7 @@ describe('Optional test', () => {
|
|
|
218
218
|
});
|
|
219
219
|
|
|
220
220
|
test('should throw for None', () => {
|
|
221
|
-
expect(() => Optional.unwrapThrow(Optional.none)).
|
|
221
|
+
expect(() => Optional.unwrapThrow(Optional.none)).toThrow(
|
|
222
222
|
'`unwrapThrow()` has failed because it is `None`',
|
|
223
223
|
);
|
|
224
224
|
});
|
|
@@ -300,9 +300,7 @@ describe('Optional test', () => {
|
|
|
300
300
|
test('should throw with custom message for None', () => {
|
|
301
301
|
const expectNumber = Optional.expectToBe<number>('Expected a number');
|
|
302
302
|
|
|
303
|
-
expect(() => expectNumber(Optional.none)).
|
|
304
|
-
'Expected a number',
|
|
305
|
-
);
|
|
303
|
+
expect(() => expectNumber(Optional.none)).toThrow('Expected a number');
|
|
306
304
|
});
|
|
307
305
|
|
|
308
306
|
test('should be curried', () => {
|
|
@@ -314,7 +312,7 @@ describe('Optional test', () => {
|
|
|
314
312
|
|
|
315
313
|
expect(expectValidId(id1)).toBe('user-123');
|
|
316
314
|
|
|
317
|
-
expect(() => expectValidId(id2)).
|
|
315
|
+
expect(() => expectValidId(id2)).toThrow('ID is required');
|
|
318
316
|
});
|
|
319
317
|
|
|
320
318
|
test('should support curried form', () => {
|
|
@@ -328,7 +326,7 @@ describe('Optional test', () => {
|
|
|
328
326
|
|
|
329
327
|
const noneValue = Optional.none;
|
|
330
328
|
|
|
331
|
-
expect(() => getValue(noneValue)).
|
|
329
|
+
expect(() => getValue(noneValue)).toThrow('Value must exist');
|
|
332
330
|
});
|
|
333
331
|
|
|
334
332
|
test('should work with pipe when curried', () => {
|
|
@@ -340,7 +338,7 @@ describe('Optional test', () => {
|
|
|
340
338
|
|
|
341
339
|
assert.deepStrictEqual(someResult, { name: 'Alice', age: 30 });
|
|
342
340
|
|
|
343
|
-
expect(() => pipe(Optional.none).map(expectUser).value).
|
|
341
|
+
expect(() => pipe(Optional.none).map(expectUser).value).toThrow(
|
|
344
342
|
'User not found',
|
|
345
343
|
);
|
|
346
344
|
});
|
|
@@ -248,7 +248,7 @@ describe('Result test', () => {
|
|
|
248
248
|
test('throws on Err result', () => {
|
|
249
249
|
const result = Result.err('error message');
|
|
250
250
|
|
|
251
|
-
expect(() => Result.unwrapThrow(result)).
|
|
251
|
+
expect(() => Result.unwrapThrow(result)).toThrow('error message');
|
|
252
252
|
});
|
|
253
253
|
});
|
|
254
254
|
|
|
@@ -589,7 +589,7 @@ describe('Result test', () => {
|
|
|
589
589
|
test('should throw for Ok', () => {
|
|
590
590
|
const result = Result.ok(42);
|
|
591
591
|
|
|
592
|
-
expect(() => Result.unwrapErrThrow(result)).
|
|
592
|
+
expect(() => Result.unwrapErrThrow(result)).toThrow(
|
|
593
593
|
'Expected Err but got Ok: 42',
|
|
594
594
|
);
|
|
595
595
|
});
|
|
@@ -599,7 +599,7 @@ describe('Result test', () => {
|
|
|
599
599
|
|
|
600
600
|
expect(() =>
|
|
601
601
|
Result.unwrapErrThrow(result, (obj) => `Object(id=${obj.id})`),
|
|
602
|
-
).
|
|
602
|
+
).toThrow('Expected Err but got Ok: Object(id=1)');
|
|
603
603
|
});
|
|
604
604
|
});
|
|
605
605
|
|
|
@@ -665,9 +665,9 @@ describe('Result test', () => {
|
|
|
665
665
|
test('should throw custom error for Err result', () => {
|
|
666
666
|
const result = Result.err('failed');
|
|
667
667
|
|
|
668
|
-
expect(() =>
|
|
669
|
-
|
|
670
|
-
)
|
|
668
|
+
expect(() => Result.expectToBe(result, 'Operation must succeed')).toThrow(
|
|
669
|
+
'Operation must succeed',
|
|
670
|
+
);
|
|
671
671
|
});
|
|
672
672
|
|
|
673
673
|
test('should support curried form', () => {
|
|
@@ -681,9 +681,7 @@ describe('Result test', () => {
|
|
|
681
681
|
|
|
682
682
|
const errResult: Result<string, string> = Result.err('failed');
|
|
683
683
|
|
|
684
|
-
expect(() => mustBeOk(errResult)).
|
|
685
|
-
'Expected successful result',
|
|
686
|
-
);
|
|
684
|
+
expect(() => mustBeOk(errResult)).toThrow('Expected successful result');
|
|
687
685
|
});
|
|
688
686
|
|
|
689
687
|
test('should work with pipe when curried', () => {
|
|
@@ -695,7 +693,7 @@ describe('Result test', () => {
|
|
|
695
693
|
|
|
696
694
|
expect(
|
|
697
695
|
() => pipe(Result.err('validation error')).map(mustBeOk).value,
|
|
698
|
-
).
|
|
696
|
+
).toThrow('Validation failed');
|
|
699
697
|
});
|
|
700
698
|
});
|
|
701
699
|
|
|
@@ -171,15 +171,15 @@ describe('TernaryResult test', () => {
|
|
|
171
171
|
test('throwing unwrap variants provide descriptive errors', () => {
|
|
172
172
|
expect(() =>
|
|
173
173
|
TernaryResult.unwrapThrow(TernaryResult.warn('notice', 'warned')),
|
|
174
|
-
).
|
|
174
|
+
).toThrow(/Warn/u);
|
|
175
175
|
|
|
176
176
|
expect(() =>
|
|
177
177
|
TernaryResult.unwrapWarnThrow(TernaryResult.err('no warn')),
|
|
178
|
-
).
|
|
178
|
+
).toThrow(/Err/u);
|
|
179
179
|
|
|
180
180
|
expect(() =>
|
|
181
181
|
TernaryResult.unwrapErrThrow(TernaryResult.ok('no err')),
|
|
182
|
-
).
|
|
182
|
+
).toThrow(/Ok/u);
|
|
183
183
|
});
|
|
184
184
|
|
|
185
185
|
test('expectToBe unwraps Ok values', () => {
|
|
@@ -187,7 +187,7 @@ describe('TernaryResult test', () => {
|
|
|
187
187
|
|
|
188
188
|
expect(() =>
|
|
189
189
|
TernaryResult.expectToBe(TernaryResult.err('x'), 'missing'),
|
|
190
|
-
).
|
|
190
|
+
).toThrow(/missing/u);
|
|
191
191
|
});
|
|
192
192
|
|
|
193
193
|
test('zip prefers Err over Warn or Ok.', () => {
|
package/src/json/json.test.mts
CHANGED
|
@@ -118,11 +118,11 @@ describe('parse', () => {
|
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
test('should not throw errors', () => {
|
|
121
|
-
expect(() => Json.parse('{{{')).not.
|
|
121
|
+
expect(() => Json.parse('{{{')).not.toThrow();
|
|
122
122
|
|
|
123
|
-
expect(() => Json.parse('null null')).not.
|
|
123
|
+
expect(() => Json.parse('null null')).not.toThrow();
|
|
124
124
|
|
|
125
|
-
expect(() => Json.parse(String(undefined))).not.
|
|
125
|
+
expect(() => Json.parse(String(undefined))).not.toThrow();
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
test('should use reviver function to transform values', () => {
|
|
@@ -323,9 +323,9 @@ describe('stringify', () => {
|
|
|
323
323
|
|
|
324
324
|
mut_circularArray.push(mut_circularArray);
|
|
325
325
|
|
|
326
|
-
expect(() => Json.stringify(mut_circularArray)).not.
|
|
326
|
+
expect(() => Json.stringify(mut_circularArray)).not.toThrow();
|
|
327
327
|
|
|
328
|
-
expect(() => Json.stringify({ fn: () => {} })).not.
|
|
328
|
+
expect(() => Json.stringify({ fn: () => {} })).not.toThrow();
|
|
329
329
|
});
|
|
330
330
|
|
|
331
331
|
test('should use replacer function to filter values', () => {
|