ts-data-forge 4.1.0 → 5.0.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-element-access.mjs +1 -0
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs +1 -0
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +2 -1
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.mjs +1 -0
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +1 -0
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/collections/imap-mapped.mjs +1 -0
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.mjs +1 -0
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/queue.mjs +1 -0
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.mjs +1 -0
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.mjs +2 -1
- package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +2 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
- package/dist/json/json.d.mts +9 -3
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +7 -0
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/refined-number-utils.mjs +1 -0
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/others/unknown-to-string.d.mts.map +1 -1
- package/dist/others/unknown-to-string.mjs +2 -1
- package/dist/others/unknown-to-string.mjs.map +1 -1
- package/dist/promise/promise.mjs +1 -0
- package/dist/promise/promise.mjs.map +1 -1
- package/package.json +18 -18
- package/src/array/impl/array-utils-creation.test.mts +187 -74
- package/src/array/impl/array-utils-element-access.test.mts +19 -3
- package/src/array/impl/array-utils-iterators.test.mts +44 -24
- package/src/array/impl/array-utils-modification.test.mts +36 -33
- package/src/array/impl/array-utils-reducing-value.mts +2 -1
- package/src/array/impl/array-utils-reducing-value.test.mts +47 -16
- package/src/array/impl/array-utils-search.test.mts +42 -9
- package/src/array/impl/array-utils-set-op.test.mts +54 -26
- package/src/array/impl/array-utils-size.test.mts +1 -0
- package/src/array/impl/array-utils-slice-clamped.test.mts +20 -11
- package/src/array/impl/array-utils-slicing.test.mts +27 -21
- package/src/array/impl/array-utils-transformation.test.mts +140 -92
- package/src/array/impl/array-utils-validation.test.mts +58 -10
- package/src/array/impl/array.test.mts +5 -5
- package/src/collections/imap-mapped.test.mts +63 -18
- package/src/collections/imap.test.mts +74 -26
- package/src/collections/iset-mapped.test.mts +81 -30
- package/src/collections/iset.test.mts +168 -68
- package/src/collections/queue.test.mts +32 -1
- package/src/collections/stack.test.mts +22 -8
- package/src/functional/match.test.mts +1 -1
- package/src/functional/optional.test.mts +61 -4
- package/src/functional/pipe.test.mts +10 -1
- package/src/functional/result/impl/result-from-throwable.mts +2 -1
- package/src/functional/result.test.mts +127 -4
- package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +2 -1
- package/src/functional/ternary-result.test.mts +34 -18
- package/src/guard/is-non-empty-string.test.mts +5 -2
- package/src/guard/is-non-null-object.test.mts +3 -5
- package/src/guard/is-primitive.test.mts +5 -3
- package/src/guard/is-record.test.mts +1 -1
- package/src/guard/is-type.test.mts +35 -20
- package/src/guard/key-is-in.test.mts +1 -1
- package/src/iterator/range.test.mts +22 -16
- package/src/json/json.mts +9 -3
- package/src/json/json.test.mts +140 -64
- package/src/number/branded-types/finite-number.test.mts +3 -2
- package/src/number/branded-types/int.test.mts +4 -3
- package/src/number/branded-types/int16.test.mts +9 -3
- package/src/number/branded-types/int32.test.mts +9 -3
- package/src/number/branded-types/non-negative-finite-number.test.mts +6 -4
- package/src/number/branded-types/non-negative-int16.test.mts +8 -3
- package/src/number/branded-types/non-negative-int32.test.mts +8 -3
- package/src/number/branded-types/non-zero-finite-number.test.mts +6 -3
- package/src/number/branded-types/non-zero-int.test.mts +6 -3
- package/src/number/branded-types/non-zero-int16.test.mts +9 -3
- package/src/number/branded-types/non-zero-int32.test.mts +9 -3
- package/src/number/branded-types/non-zero-safe-int.test.mts +10 -3
- package/src/number/branded-types/non-zero-uint16.test.mts +8 -3
- package/src/number/branded-types/non-zero-uint32.test.mts +8 -3
- package/src/number/branded-types/positive-finite-number.test.mts +7 -3
- package/src/number/branded-types/positive-int.test.mts +5 -3
- package/src/number/branded-types/positive-int16.test.mts +8 -3
- package/src/number/branded-types/positive-int32.test.mts +8 -3
- package/src/number/branded-types/positive-safe-int.test.mts +8 -3
- package/src/number/branded-types/positive-uint16.test.mts +8 -3
- package/src/number/branded-types/positive-uint32.test.mts +8 -3
- package/src/number/branded-types/safe-int.test.mts +8 -2
- package/src/number/branded-types/safe-uint.test.mts +8 -3
- package/src/number/branded-types/uint.test.mts +5 -3
- package/src/number/branded-types/uint16.test.mts +8 -3
- package/src/number/branded-types/uint32.test.mts +8 -3
- package/src/number/enum/int8.test.mts +8 -3
- package/src/number/enum/uint8.test.mts +6 -3
- package/src/number/num.test.mts +16 -2
- package/src/object/object.test.mts +26 -13
- package/src/others/cast-mutable.test.mts +10 -8
- package/src/others/cast-readonly.test.mts +9 -5
- package/src/others/if-then.test.mts +4 -1
- package/src/others/map-nullable.test.mts +28 -1
- package/src/others/memoize-function.test.mts +20 -17
- package/src/others/tuple.test.mts +3 -2
- package/src/others/unknown-to-string.mts +2 -1
- package/src/others/unknown-to-string.test.mts +15 -2
- package/src/promise/promise.test.mts +6 -1
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from './array-utils-validation.mjs';
|
|
12
12
|
|
|
13
13
|
describe('Arr validations', () => {
|
|
14
|
-
describe(
|
|
14
|
+
describe(isArray, () => {
|
|
15
15
|
test('should return true for arrays', () => {
|
|
16
16
|
expect(isArray([1, 2, 3])).toBe(true);
|
|
17
17
|
expect(isArray([])).toBe(true);
|
|
@@ -48,6 +48,7 @@ describe('Arr validations', () => {
|
|
|
48
48
|
const readonlyArray: readonly number[] = [1, 2, 3];
|
|
49
49
|
if (isArray(readonlyArray)) {
|
|
50
50
|
expectType<typeof readonlyArray, readonly number[]>('=');
|
|
51
|
+
|
|
51
52
|
expect(readonlyArray).toHaveLength(3);
|
|
52
53
|
}
|
|
53
54
|
});
|
|
@@ -56,6 +57,7 @@ describe('Arr validations', () => {
|
|
|
56
57
|
const mutableArray: number[] = [1, 2, 3];
|
|
57
58
|
if (isArray(mutableArray)) {
|
|
58
59
|
expectType<typeof mutableArray, number[]>('=');
|
|
60
|
+
|
|
59
61
|
expect(mutableArray).toHaveLength(3);
|
|
60
62
|
}
|
|
61
63
|
});
|
|
@@ -129,12 +131,14 @@ describe('Arr validations', () => {
|
|
|
129
131
|
const value: unknown = [1, 2, 3];
|
|
130
132
|
if (isArray(value)) {
|
|
131
133
|
expectType<typeof value, readonly unknown[]>('=');
|
|
134
|
+
|
|
132
135
|
expect(value).toHaveLength(3);
|
|
133
136
|
}
|
|
134
137
|
});
|
|
135
138
|
|
|
136
139
|
test('should handle array-like objects', () => {
|
|
137
140
|
const arrayLike = { 0: 'a', 1: 'b', length: 2 };
|
|
141
|
+
|
|
138
142
|
expect(isArray(arrayLike)).toBe(false);
|
|
139
143
|
});
|
|
140
144
|
|
|
@@ -195,6 +199,7 @@ describe('Arr validations', () => {
|
|
|
195
199
|
}
|
|
196
200
|
return 0;
|
|
197
201
|
};
|
|
202
|
+
|
|
198
203
|
expect(processGeneric([1, 2, 3])).toBe(3);
|
|
199
204
|
expect(processGeneric('hello')).toBe(0);
|
|
200
205
|
});
|
|
@@ -217,8 +222,9 @@ describe('Arr validations', () => {
|
|
|
217
222
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
218
223
|
return [value] as ArrayOrValue<T>;
|
|
219
224
|
};
|
|
220
|
-
|
|
221
|
-
|
|
225
|
+
|
|
226
|
+
assert.deepStrictEqual(makeArray([1, 2, 3]), [1, 2, 3]);
|
|
227
|
+
assert.deepStrictEqual(makeArray(5), [5]);
|
|
222
228
|
});
|
|
223
229
|
|
|
224
230
|
test('should handle intersection types', () => {
|
|
@@ -226,6 +232,7 @@ describe('Arr validations', () => {
|
|
|
226
232
|
const tagged = Object.assign([1, 2, 3], { tag: 'test' }) as TaggedArray;
|
|
227
233
|
if (isArray(tagged)) {
|
|
228
234
|
expectType<typeof tagged, TaggedArray>('=');
|
|
235
|
+
|
|
229
236
|
expect(tagged.tag).toBe('test');
|
|
230
237
|
}
|
|
231
238
|
});
|
|
@@ -299,7 +306,7 @@ describe('Arr validations', () => {
|
|
|
299
306
|
});
|
|
300
307
|
});
|
|
301
308
|
|
|
302
|
-
describe(
|
|
309
|
+
describe(isEmpty, () => {
|
|
303
310
|
const xs = [1, 2, 3] as const;
|
|
304
311
|
const result = isEmpty(xs);
|
|
305
312
|
|
|
@@ -314,7 +321,7 @@ describe('Arr validations', () => {
|
|
|
314
321
|
});
|
|
315
322
|
});
|
|
316
323
|
|
|
317
|
-
describe(
|
|
324
|
+
describe(isNonEmpty, () => {
|
|
318
325
|
const xs = [1, 2, 3] as const;
|
|
319
326
|
const result = isNonEmpty(xs);
|
|
320
327
|
|
|
@@ -329,10 +336,12 @@ describe('Arr validations', () => {
|
|
|
329
336
|
});
|
|
330
337
|
});
|
|
331
338
|
|
|
332
|
-
describe(
|
|
339
|
+
describe(isArrayOfLength, () => {
|
|
333
340
|
test('should return true if array has specified length', () => {
|
|
334
341
|
const arr = [1, 2, 3] as const;
|
|
342
|
+
|
|
335
343
|
expect(isArrayOfLength(arr, 3)).toBe(true);
|
|
344
|
+
|
|
336
345
|
if (isArrayOfLength(arr, 3)) {
|
|
337
346
|
expectType<typeof arr, readonly [1, 2, 3]>('=');
|
|
338
347
|
}
|
|
@@ -340,12 +349,15 @@ describe('Arr validations', () => {
|
|
|
340
349
|
|
|
341
350
|
test('should return false if array does not have specified length', () => {
|
|
342
351
|
const arr = [1, 2, 3] as const;
|
|
352
|
+
|
|
343
353
|
expect(isArrayOfLength(arr, 2)).toBe(false);
|
|
344
354
|
});
|
|
345
355
|
|
|
346
356
|
test('should return true for empty array and length 0', () => {
|
|
347
357
|
const arr = [] as const;
|
|
358
|
+
|
|
348
359
|
expect(isArrayOfLength(arr, 0)).toBe(true);
|
|
360
|
+
|
|
349
361
|
if (isArrayOfLength(arr, 0)) {
|
|
350
362
|
expectType<typeof arr, readonly []>('=');
|
|
351
363
|
}
|
|
@@ -353,24 +365,31 @@ describe('Arr validations', () => {
|
|
|
353
365
|
|
|
354
366
|
test('should return false for non-empty array and length 0', () => {
|
|
355
367
|
const arr = [1] as const;
|
|
368
|
+
|
|
356
369
|
expect(isArrayOfLength(arr, 0)).toBe(false);
|
|
357
370
|
});
|
|
358
371
|
|
|
359
372
|
test('should work with unknown array type', () => {
|
|
360
373
|
const arr: number[] = [1, 2];
|
|
374
|
+
|
|
361
375
|
expect(isArrayOfLength(arr, 2)).toBe(true);
|
|
376
|
+
|
|
362
377
|
if (isArrayOfLength(arr, 2)) {
|
|
363
378
|
expectType<typeof arr, number[] & ArrayOfLength<2, number>>('=');
|
|
364
379
|
}
|
|
380
|
+
|
|
365
381
|
expect(isArrayOfLength(arr, 3)).toBe(false);
|
|
366
382
|
});
|
|
367
383
|
|
|
368
384
|
test('should work with unknown readonly array type', () => {
|
|
369
385
|
const arr: readonly number[] = [1, 2];
|
|
386
|
+
|
|
370
387
|
expect(isArrayOfLength(arr, 2)).toBe(true);
|
|
388
|
+
|
|
371
389
|
if (isArrayOfLength(arr, 2)) {
|
|
372
390
|
expectType<typeof arr, ArrayOfLength<2, number>>('=');
|
|
373
391
|
}
|
|
392
|
+
|
|
374
393
|
expect(isArrayOfLength(arr, 3)).toBe(false);
|
|
375
394
|
});
|
|
376
395
|
|
|
@@ -390,19 +409,24 @@ describe('Arr validations', () => {
|
|
|
390
409
|
const array: readonly number[] = [1, 2, 3];
|
|
391
410
|
if (isArrayOfLength(array, 3)) {
|
|
392
411
|
expectType<typeof array, ArrayOfLength<3, number>>('=');
|
|
412
|
+
|
|
393
413
|
expect(array).toHaveLength(3);
|
|
394
414
|
}
|
|
395
415
|
});
|
|
396
416
|
});
|
|
397
417
|
|
|
398
|
-
describe(
|
|
418
|
+
describe(isArrayAtLeastLength, () => {
|
|
399
419
|
test('should return true if array length is greater than or equal to specified length', () => {
|
|
400
420
|
const arr = [1, 2, 3] as const;
|
|
421
|
+
|
|
401
422
|
expect(isArrayAtLeastLength(arr, 3)).toBe(true);
|
|
423
|
+
|
|
402
424
|
if (isArrayAtLeastLength(arr, 3)) {
|
|
403
425
|
expectType<typeof arr, readonly [1, 2, 3]>('=');
|
|
404
426
|
}
|
|
427
|
+
|
|
405
428
|
expect(isArrayAtLeastLength(arr, 2)).toBe(true);
|
|
429
|
+
|
|
406
430
|
if (isArrayAtLeastLength(arr, 2)) {
|
|
407
431
|
expectType<typeof arr, readonly [1, 2, 3]>('=');
|
|
408
432
|
}
|
|
@@ -410,12 +434,15 @@ describe('Arr validations', () => {
|
|
|
410
434
|
|
|
411
435
|
test('should return false if array length is less than specified length', () => {
|
|
412
436
|
const arr = [1, 2, 3] as const;
|
|
437
|
+
|
|
413
438
|
expect(isArrayAtLeastLength(arr, 4)).toBe(false);
|
|
414
439
|
});
|
|
415
440
|
|
|
416
441
|
test('should return true for empty array and length 0', () => {
|
|
417
442
|
const arr = [] as const;
|
|
443
|
+
|
|
418
444
|
expect(isArrayAtLeastLength(arr, 0)).toBe(true);
|
|
445
|
+
|
|
419
446
|
if (isArrayAtLeastLength(arr, 0)) {
|
|
420
447
|
expectType<typeof arr, readonly []>('=');
|
|
421
448
|
}
|
|
@@ -423,19 +450,25 @@ describe('Arr validations', () => {
|
|
|
423
450
|
|
|
424
451
|
test('should return false for empty array and positive length', () => {
|
|
425
452
|
const arr = [] as const;
|
|
453
|
+
|
|
426
454
|
expect(isArrayAtLeastLength(arr, 1)).toBe(false);
|
|
427
455
|
});
|
|
428
456
|
|
|
429
457
|
test('should work with unknown array type', () => {
|
|
430
458
|
const arr: number[] = [1, 2];
|
|
459
|
+
|
|
431
460
|
expect(isArrayAtLeastLength(arr, 2)).toBe(true);
|
|
461
|
+
|
|
432
462
|
if (isArrayAtLeastLength(arr, 2)) {
|
|
433
463
|
expectType<typeof arr, number[] & ArrayAtLeastLen<2, number>>('=');
|
|
434
464
|
}
|
|
465
|
+
|
|
435
466
|
expect(isArrayAtLeastLength(arr, 1)).toBe(true);
|
|
467
|
+
|
|
436
468
|
if (isArrayAtLeastLength(arr, 1)) {
|
|
437
469
|
expectType<typeof arr, number[] & ArrayAtLeastLen<1, number>>('=');
|
|
438
470
|
}
|
|
471
|
+
|
|
439
472
|
expect(isArrayAtLeastLength(arr, 3)).toBe(false);
|
|
440
473
|
});
|
|
441
474
|
|
|
@@ -455,21 +488,24 @@ describe('Arr validations', () => {
|
|
|
455
488
|
const array: readonly number[] = [1, 2, 3];
|
|
456
489
|
if (isArrayAtLeastLength(array, 2)) {
|
|
457
490
|
expectType<typeof array, ArrayAtLeastLen<2, number>>('=');
|
|
491
|
+
|
|
458
492
|
expect(array.length).toBeGreaterThanOrEqual(2);
|
|
459
493
|
}
|
|
460
494
|
});
|
|
461
495
|
});
|
|
462
496
|
|
|
463
|
-
describe(
|
|
497
|
+
describe(every, () => {
|
|
464
498
|
test('should return true when all elements satisfy predicate', () => {
|
|
465
499
|
const evens = [2, 4, 6, 8];
|
|
466
500
|
const allEven = every(evens, (n) => n % 2 === 0);
|
|
501
|
+
|
|
467
502
|
expect(allEven).toBe(true);
|
|
468
503
|
});
|
|
469
504
|
|
|
470
505
|
test('should return false when not all elements satisfy predicate', () => {
|
|
471
506
|
const mixed = [2, 3, 4, 6];
|
|
472
507
|
const allEven = every(mixed, (n) => n % 2 === 0);
|
|
508
|
+
|
|
473
509
|
expect(allEven).toBe(false);
|
|
474
510
|
});
|
|
475
511
|
|
|
@@ -484,6 +520,7 @@ describe('Arr validations', () => {
|
|
|
484
520
|
test('should work with curried version', () => {
|
|
485
521
|
const isPositive = (n: number): boolean => n > 0;
|
|
486
522
|
const allPositive = every(isPositive);
|
|
523
|
+
|
|
487
524
|
expect(allPositive([1, 2, 3])).toBe(true);
|
|
488
525
|
expect(allPositive([1, -2, 3])).toBe(false);
|
|
489
526
|
});
|
|
@@ -501,32 +538,37 @@ describe('Arr validations', () => {
|
|
|
501
538
|
test('should return true for empty array', () => {
|
|
502
539
|
const empty: number[] = [];
|
|
503
540
|
const result = every(empty, (n) => n > 0);
|
|
541
|
+
|
|
504
542
|
expect(result).toBe(true);
|
|
505
543
|
});
|
|
506
544
|
|
|
507
545
|
test('should pass index to predicate', () => {
|
|
508
546
|
const numbers = [0, 1, 2, 3];
|
|
509
547
|
const indexMatchesValue = every(numbers, (val, idx) => val === idx);
|
|
548
|
+
|
|
510
549
|
expect(indexMatchesValue).toBe(true);
|
|
511
550
|
});
|
|
512
551
|
});
|
|
513
552
|
|
|
514
|
-
describe(
|
|
553
|
+
describe(some, () => {
|
|
515
554
|
test('should return true when at least one element satisfies predicate', () => {
|
|
516
555
|
const numbers = [1, 3, 5, 8];
|
|
517
556
|
const hasEven = some(numbers, (n) => n % 2 === 0);
|
|
557
|
+
|
|
518
558
|
expect(hasEven).toBe(true);
|
|
519
559
|
});
|
|
520
560
|
|
|
521
561
|
test('should return false when no elements satisfy predicate', () => {
|
|
522
562
|
const odds = [1, 3, 5, 7];
|
|
523
563
|
const hasEven = some(odds, (n) => n % 2 === 0);
|
|
564
|
+
|
|
524
565
|
expect(hasEven).toBe(false);
|
|
525
566
|
});
|
|
526
567
|
|
|
527
568
|
test('should work with curried version', () => {
|
|
528
569
|
const isNegative = (n: number): boolean => n < 0;
|
|
529
570
|
const hasNegative = some(isNegative);
|
|
571
|
+
|
|
530
572
|
expect(hasNegative([1, 2, -3])).toBe(true);
|
|
531
573
|
expect(hasNegative([1, 2, 3])).toBe(false);
|
|
532
574
|
});
|
|
@@ -534,6 +576,7 @@ describe('Arr validations', () => {
|
|
|
534
576
|
test('should return false for empty array', () => {
|
|
535
577
|
const empty: number[] = [];
|
|
536
578
|
const result = some(empty, (n) => n > 0);
|
|
579
|
+
|
|
537
580
|
expect(result).toBe(false);
|
|
538
581
|
});
|
|
539
582
|
|
|
@@ -543,13 +586,15 @@ describe('Arr validations', () => {
|
|
|
543
586
|
numbers,
|
|
544
587
|
(val, idx) => val === idx * 10,
|
|
545
588
|
);
|
|
589
|
+
|
|
546
590
|
expect(hasValueMatchingIndex).toBe(true);
|
|
547
591
|
});
|
|
548
592
|
});
|
|
549
593
|
|
|
550
|
-
describe(
|
|
594
|
+
describe(indexIsInRange, () => {
|
|
551
595
|
test('should return true for valid indices', () => {
|
|
552
596
|
const array = ['a', 'b', 'c'];
|
|
597
|
+
|
|
553
598
|
expect(indexIsInRange(array, 0)).toBe(true);
|
|
554
599
|
expect(indexIsInRange(array, 1)).toBe(true);
|
|
555
600
|
expect(indexIsInRange(array, 2)).toBe(true);
|
|
@@ -557,12 +602,14 @@ describe('Arr validations', () => {
|
|
|
557
602
|
|
|
558
603
|
test('should return false for invalid indices', () => {
|
|
559
604
|
const array = ['a', 'b', 'c'];
|
|
605
|
+
|
|
560
606
|
expect(indexIsInRange(array, 3)).toBe(false);
|
|
561
607
|
expect(indexIsInRange(array, 10)).toBe(false);
|
|
562
608
|
});
|
|
563
609
|
|
|
564
610
|
test('should work with empty array', () => {
|
|
565
611
|
const empty: readonly string[] = [];
|
|
612
|
+
|
|
566
613
|
expect(indexIsInRange(empty, 0)).toBe(false);
|
|
567
614
|
// @ts-expect-error negative indices should not be allowed
|
|
568
615
|
expect(indexIsInRange(empty, -1)).toBe(false);
|
|
@@ -570,6 +617,7 @@ describe('Arr validations', () => {
|
|
|
570
617
|
|
|
571
618
|
test('should be type error with floating point indices', () => {
|
|
572
619
|
const array = [1, 2, 3];
|
|
620
|
+
|
|
573
621
|
// @ts-expect-error floating point indices should not be allowed
|
|
574
622
|
expect(indexIsInRange(array, 1.5)).toBe(true); // JavaScript arrays accept floating point indices
|
|
575
623
|
// @ts-expect-error floating point indices should not be allowed
|
|
@@ -40,7 +40,7 @@ describe('Array.flat', () => {
|
|
|
40
40
|
>('=');
|
|
41
41
|
|
|
42
42
|
test('case 1', () => {
|
|
43
|
-
|
|
43
|
+
assert.deepStrictEqual(result, [1, 2, 3, 4, [5, 6, [7, 8]]]);
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -75,7 +75,7 @@ describe('Array.find', () => {
|
|
|
75
75
|
expectType<typeof result, Readonly<{ v: 1 }> | undefined>('=');
|
|
76
76
|
|
|
77
77
|
test('case 1', () => {
|
|
78
|
-
|
|
78
|
+
assert.deepStrictEqual(result, { v: 1 });
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
{
|
|
@@ -89,7 +89,7 @@ describe('Array.find', () => {
|
|
|
89
89
|
expectType<typeof result, Readonly<{ v: 1 | 2 | 3 }> | undefined>('=');
|
|
90
90
|
|
|
91
91
|
test('case 2', () => {
|
|
92
|
-
|
|
92
|
+
assert.deepStrictEqual(result, { v: 1 });
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
});
|
|
@@ -129,7 +129,7 @@ describe('Array.filter', () => {
|
|
|
129
129
|
expectType<typeof filtered, (1 | 3)[]>('=');
|
|
130
130
|
|
|
131
131
|
test('case 1', () => {
|
|
132
|
-
|
|
132
|
+
assert.deepStrictEqual(filtered, [1, 3]);
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -140,7 +140,7 @@ describe('Array.filter', () => {
|
|
|
140
140
|
expectType<typeof filtered, (1 | 2 | 3)[]>('=');
|
|
141
141
|
|
|
142
142
|
test('case 2', () => {
|
|
143
|
-
|
|
143
|
+
assert.deepStrictEqual(filtered, [1, 3]);
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
});
|