@vinicunca/perkakas 1.0.3 → 1.0.5
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/add-prop.d.cts +1 -1
- package/dist/add-prop.d.ts +1 -1
- package/dist/chunk-3DFX2FQG.cjs +1 -0
- package/dist/chunk-4WU7JGWS.cjs +1 -0
- package/dist/chunk-AACZ5UGG.cjs +1 -0
- package/dist/chunk-AKGWT6GC.js +1 -0
- package/dist/chunk-BT3FI7L7.js +1 -0
- package/dist/chunk-D5B5IQRS.js +1 -0
- package/dist/{chunk-XQOKSJ5R.cjs → chunk-E6RBEL5Z.cjs} +1 -1
- package/dist/chunk-EPHUNAE5.js +1 -0
- package/dist/chunk-G7BJFBAZ.cjs +1 -0
- package/dist/{chunk-YIUDV3OA.cjs → chunk-HTO3K3VA.cjs} +1 -1
- package/dist/chunk-IABWIMQT.js +1 -0
- package/dist/chunk-IOSBDH5J.cjs +1 -0
- package/dist/chunk-KAA6IVBL.js +1 -0
- package/dist/chunk-MADDQNAR.cjs +1 -0
- package/dist/chunk-OJ2QGTFS.js +1 -0
- package/dist/chunk-PFLGL4YP.js +1 -0
- package/dist/chunk-QT66COHU.js +1 -0
- package/dist/chunk-QTQTKNWA.js +1 -0
- package/dist/chunk-RJAVPEJT.cjs +1 -0
- package/dist/chunk-U2BXIRBJ.js +1 -0
- package/dist/chunk-VN2OAM2N.js +1 -0
- package/dist/chunk-VPG3W5JH.cjs +1 -0
- package/dist/chunk-WQDEYM64.js +1 -0
- package/dist/chunk-WRKGH4XX.js +1 -0
- package/dist/chunk-Y3WI7FPB.cjs +1 -0
- package/dist/chunk-Z5UEQBZP.cjs +1 -0
- package/dist/chunk-Z6HCXPKS.cjs +1 -0
- package/dist/chunk-ZO4ND36N.cjs +1 -0
- package/dist/chunk.cjs +1 -1
- package/dist/chunk.d.cts +91 -5
- package/dist/chunk.d.ts +91 -5
- package/dist/chunk.js +1 -1
- package/dist/chunk.spec-d.cjs +1 -1
- package/dist/chunk.spec-d.js +1 -1
- package/dist/concat.d.cts +1 -1
- package/dist/concat.d.ts +1 -1
- package/dist/conditional.d.cts +1 -1
- package/dist/conditional.d.ts +1 -1
- package/dist/conditional.spec-d.cjs +1 -1
- package/dist/conditional.spec-d.js +1 -1
- package/dist/drop-first-by.d.cts +1 -1
- package/dist/drop-first-by.d.ts +1 -1
- package/dist/drop-last-while.cjs +1 -1
- package/dist/drop-last-while.d.cts +5 -2
- package/dist/drop-last-while.d.ts +5 -2
- package/dist/drop-last-while.js +1 -1
- package/dist/drop-last-while.spec-d.cjs +1 -0
- package/dist/drop-last-while.spec-d.d.cts +2 -0
- package/dist/drop-last-while.spec-d.d.ts +2 -0
- package/dist/drop-last-while.spec-d.js +1 -0
- package/dist/drop-last.cjs +1 -1
- package/dist/drop-last.d.cts +5 -2
- package/dist/drop-last.d.ts +5 -2
- package/dist/drop-last.js +1 -1
- package/dist/drop-last.spec-d.cjs +1 -0
- package/dist/drop-last.spec-d.d.cts +2 -0
- package/dist/drop-last.spec-d.d.ts +2 -0
- package/dist/drop-last.spec-d.js +1 -0
- package/dist/drop-while.cjs +1 -1
- package/dist/drop-while.d.cts +5 -2
- package/dist/drop-while.d.ts +5 -2
- package/dist/drop-while.js +1 -1
- package/dist/drop-while.spec-d.cjs +1 -0
- package/dist/drop-while.spec-d.d.cts +2 -0
- package/dist/drop-while.spec-d.d.ts +2 -0
- package/dist/drop-while.spec-d.js +1 -0
- package/dist/drop.cjs +1 -1
- package/dist/drop.d.cts +23 -2
- package/dist/drop.d.ts +23 -2
- package/dist/drop.js +1 -1
- package/dist/drop.spec-d.cjs +1 -0
- package/dist/drop.spec-d.d.cts +2 -0
- package/dist/drop.spec-d.d.ts +2 -0
- package/dist/drop.spec-d.js +1 -0
- package/dist/evolve.d.cts +1 -1
- package/dist/evolve.d.ts +1 -1
- package/dist/first-by.d.cts +1 -1
- package/dist/first-by.d.ts +1 -1
- package/dist/first.d.cts +1 -1
- package/dist/first.d.ts +1 -1
- package/dist/flat.d.cts +1 -1
- package/dist/flat.d.ts +1 -1
- package/dist/for-each-obj.d.cts +1 -1
- package/dist/for-each-obj.d.ts +1 -1
- package/dist/for-each.d.cts +1 -1
- package/dist/for-each.d.ts +1 -1
- package/dist/from-entries.d.cts +1 -1
- package/dist/from-entries.d.ts +1 -1
- package/dist/from-keys.d.cts +1 -1
- package/dist/from-keys.d.ts +1 -1
- package/dist/group-by.d.cts +1 -1
- package/dist/group-by.d.ts +1 -1
- package/dist/has-at-least.d.cts +1 -1
- package/dist/has-at-least.d.ts +1 -1
- package/dist/has-sub-object.d.cts +1 -1
- package/dist/has-sub-object.d.ts +1 -1
- package/dist/index-by.d.cts +1 -1
- package/dist/index-by.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/is-array.d.cts +1 -1
- package/dist/is-array.d.ts +1 -1
- package/dist/is-big-int.d.cts +1 -1
- package/dist/is-big-int.d.ts +1 -1
- package/dist/is-boolean.d.cts +1 -1
- package/dist/is-boolean.d.ts +1 -1
- package/dist/is-empty.d.cts +1 -1
- package/dist/is-empty.d.ts +1 -1
- package/dist/is-included-in.d.cts +1 -1
- package/dist/is-included-in.d.ts +1 -1
- package/dist/is-nullish.d.cts +1 -1
- package/dist/is-nullish.d.ts +1 -1
- package/dist/is-number.d.cts +1 -1
- package/dist/is-number.d.ts +1 -1
- package/dist/is-object-type.d.cts +1 -1
- package/dist/is-object-type.d.ts +1 -1
- package/dist/is-plain-object.d.cts +1 -1
- package/dist/is-plain-object.d.ts +1 -1
- package/dist/is-string.d.cts +1 -1
- package/dist/is-string.d.ts +1 -1
- package/dist/is-symbol.d.cts +1 -1
- package/dist/is-symbol.d.ts +1 -1
- package/dist/keys.d.cts +1 -1
- package/dist/keys.d.ts +1 -1
- package/dist/last.d.cts +1 -1
- package/dist/last.d.ts +1 -1
- package/dist/map-keys.d.cts +1 -1
- package/dist/map-keys.d.ts +1 -1
- package/dist/map-values.d.cts +1 -1
- package/dist/map-values.d.ts +1 -1
- package/dist/map-with-feedback.d.cts +1 -1
- package/dist/map-with-feedback.d.ts +1 -1
- package/dist/map.d.cts +1 -1
- package/dist/map.d.ts +1 -1
- package/dist/nth-by.d.cts +1 -1
- package/dist/nth-by.d.ts +1 -1
- package/dist/omit-by.d.cts +1 -1
- package/dist/omit-by.d.ts +1 -1
- package/dist/only.d.cts +1 -1
- package/dist/only.d.ts +1 -1
- package/dist/pick-by.d.cts +1 -1
- package/dist/pick-by.d.ts +1 -1
- package/dist/product.d.cts +1 -1
- package/dist/product.d.ts +1 -1
- package/dist/pull-object.d.cts +1 -1
- package/dist/pull-object.d.ts +1 -1
- package/dist/random-integer.cjs +1 -0
- package/dist/random-integer.d.cts +20 -0
- package/dist/random-integer.d.ts +20 -0
- package/dist/random-integer.js +1 -0
- package/dist/random-integer.spec-d.cjs +1 -0
- package/dist/random-integer.spec-d.d.cts +2 -0
- package/dist/random-integer.spec-d.d.ts +2 -0
- package/dist/random-integer.spec-d.js +1 -0
- package/dist/rank-by.d.cts +1 -1
- package/dist/rank-by.d.ts +1 -1
- package/dist/sample.d.cts +1 -1
- package/dist/sample.d.ts +1 -1
- package/dist/set.d.cts +1 -1
- package/dist/set.d.ts +1 -1
- package/dist/shuffle.cjs +1 -1
- package/dist/shuffle.d.cts +5 -2
- package/dist/shuffle.d.ts +5 -2
- package/dist/shuffle.js +1 -1
- package/dist/shuffle.spec-d.cjs +1 -0
- package/dist/shuffle.spec-d.d.cts +2 -0
- package/dist/shuffle.spec-d.d.ts +2 -0
- package/dist/shuffle.spec-d.js +1 -0
- package/dist/sort-by.d.cts +1 -1
- package/dist/sort-by.d.ts +1 -1
- package/dist/sort.d.cts +1 -1
- package/dist/sort.d.ts +1 -1
- package/dist/sum.d.cts +1 -1
- package/dist/sum.d.ts +1 -1
- package/dist/swap-indices.d.cts +1 -1
- package/dist/swap-indices.d.ts +1 -1
- package/dist/take-first-by.d.cts +1 -1
- package/dist/take-first-by.d.ts +1 -1
- package/dist/take-last-while.cjs +1 -1
- package/dist/take-last-while.d.cts +5 -2
- package/dist/take-last-while.d.ts +5 -2
- package/dist/take-last-while.js +1 -1
- package/dist/take-last-while.spec-d-.cjs +1 -0
- package/dist/take-last-while.spec-d-.d.cts +2 -0
- package/dist/take-last-while.spec-d-.d.ts +2 -0
- package/dist/take-last-while.spec-d-.js +1 -0
- package/dist/take-last.cjs +1 -1
- package/dist/take-last.d.cts +5 -2
- package/dist/take-last.d.ts +5 -2
- package/dist/take-last.js +1 -1
- package/dist/take-last.spec-d.cjs +1 -0
- package/dist/take-last.spec-d.d.cts +2 -0
- package/dist/take-last.spec-d.d.ts +2 -0
- package/dist/take-last.spec-d.js +1 -0
- package/dist/take-while.cjs +1 -1
- package/dist/take-while.d.cts +5 -2
- package/dist/take-while.d.ts +5 -2
- package/dist/take-while.js +1 -1
- package/dist/take-white.spec-d.cjs +1 -0
- package/dist/take-white.spec-d.d.cts +2 -0
- package/dist/take-white.spec-d.d.ts +2 -0
- package/dist/take-white.spec-d.js +1 -0
- package/dist/take.cjs +1 -1
- package/dist/take.d.cts +5 -2
- package/dist/take.d.ts +5 -2
- package/dist/take.js +1 -1
- package/dist/take.spec-d.cjs +1 -0
- package/dist/take.spec-d.d.cts +2 -0
- package/dist/take.spec-d.d.ts +2 -0
- package/dist/take.spec-d.js +1 -0
- package/dist/tap.spec-d.cjs +1 -1
- package/dist/tap.spec-d.js +1 -1
- package/dist/{types-BMu1PIvo.d.cts → types-CC8iZVKO.d.cts} +56 -3
- package/dist/{types-BMu1PIvo.d.ts → types-CC8iZVKO.d.ts} +56 -3
- package/dist/unique-by.cjs +1 -1
- package/dist/unique-by.d.cts +5 -2
- package/dist/unique-by.d.ts +5 -2
- package/dist/unique-by.js +1 -1
- package/dist/unique-with.cjs +1 -1
- package/dist/unique-with.d.cts +5 -2
- package/dist/unique-with.d.ts +5 -2
- package/dist/unique-with.js +1 -1
- package/dist/unique.cjs +1 -1
- package/dist/unique.d.cts +6 -3
- package/dist/unique.d.ts +6 -3
- package/dist/unique.js +1 -1
- package/dist/values.d.cts +1 -1
- package/dist/values.d.ts +1 -1
- package/dist/zip-with.d.cts +1 -1
- package/dist/zip-with.d.ts +1 -1
- package/dist/zip.d.cts +1 -1
- package/dist/zip.d.ts +1 -1
- package/package.json +12 -12
- package/dist/chunk-3UUZWCRS.cjs +0 -1
- package/dist/chunk-65DHT5Z7.cjs +0 -1
- package/dist/chunk-66KQORMS.js +0 -1
- package/dist/chunk-AE5HI6VG.cjs +0 -1
- package/dist/chunk-CIF6WEFP.js +0 -1
- package/dist/chunk-COBRSP66.js +0 -1
- package/dist/chunk-DUKQ2ODK.js +0 -1
- package/dist/chunk-DWPHE3F2.cjs +0 -1
- package/dist/chunk-HUWRVMPE.js +0 -1
- package/dist/chunk-LIKMH7XD.js +0 -1
- package/dist/chunk-LOPUNSWJ.js +0 -1
- package/dist/chunk-MENOHSYF.js +0 -1
- package/dist/chunk-NNK6R67E.cjs +0 -1
- package/dist/chunk-P7OXTPPH.cjs +0 -1
- package/dist/chunk-QTCQZ7LU.js +0 -1
- package/dist/chunk-RSJJRJTH.cjs +0 -1
- package/dist/chunk-TR5T6KUC.js +0 -1
- package/dist/chunk-U5EQP4BO.cjs +0 -1
- package/dist/chunk-VNLOBA2B.cjs +0 -1
- package/dist/chunk-X6AB3I7Z.cjs +0 -1
- package/dist/chunk-YQKPA3BB.js +0 -1
- package/dist/chunk-YWSZXRUY.js +0 -1
- package/dist/chunk-Z7EBGO2B.js +0 -1
- package/dist/chunk-ZCFTW5HO.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-PFLGL4YP.js";import{a as t}from"./chunk-6ALZHU2N.js";import"./chunk-MYLYERXO.js";import"./chunk-JFXZ246Y.js";import"./chunk-KQGY2DBY.js";test("regular array",()=>{let e=r([]);expectTypeOf(e).toEqualTypeOf()});test("non-empty tail-rest array",()=>{let e=r([1]);expectTypeOf(e).toEqualTypeOf()});test("non-empty head-rest array",()=>{let e=r([1]);expectTypeOf(e).toEqualTypeOf()});test("fixed size tuple",()=>{let e=r([1,"a",!0]);expectTypeOf(e).toEqualTypeOf()});it("removes readonlyness from array",()=>{let e=r([]);expectTypeOf(e).toEqualTypeOf()});it("infers type via a pipe",()=>{let e=t(["a",1,!0],r());expectTypeOf(e).toEqualTypeOf()});
|
package/dist/sort-by.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IterableContainer,
|
|
1
|
+
import { I as IterableContainer, a as NonEmptyArray, g as ReorderedArray } from './types-CC8iZVKO.cjs';
|
|
2
2
|
import { O as OrderRule } from './curry-order-rules-DETxSzle.cjs';
|
|
3
3
|
import 'type-fest';
|
|
4
4
|
|
package/dist/sort-by.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IterableContainer,
|
|
1
|
+
import { I as IterableContainer, a as NonEmptyArray, g as ReorderedArray } from './types-CC8iZVKO.js';
|
|
2
2
|
import { O as OrderRule } from './curry-order-rules-DETxSzle.js';
|
|
3
3
|
import 'type-fest';
|
|
4
4
|
|
package/dist/sort.d.cts
CHANGED
package/dist/sort.d.ts
CHANGED
package/dist/sum.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IterableContainer } from './types-
|
|
1
|
+
import { I as IterableContainer } from './types-CC8iZVKO.cjs';
|
|
2
2
|
import 'type-fest';
|
|
3
3
|
|
|
4
4
|
type Sum<T extends IterableContainer<bigint> | IterableContainer<number>> = T extends readonly [] ? 0 : T extends readonly [bigint, ...ReadonlyArray<unknown>] ? bigint : T[number] extends bigint ? 0 | bigint : number;
|
package/dist/sum.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IterableContainer } from './types-
|
|
1
|
+
import { I as IterableContainer } from './types-CC8iZVKO.js';
|
|
2
2
|
import 'type-fest';
|
|
3
3
|
|
|
4
4
|
type Sum<T extends IterableContainer<bigint> | IterableContainer<number>> = T extends readonly [] ? 0 : T extends readonly [bigint, ...ReadonlyArray<unknown>] ? bigint : T[number] extends bigint ? 0 | bigint : number;
|
package/dist/swap-indices.d.cts
CHANGED
package/dist/swap-indices.d.ts
CHANGED
package/dist/take-first-by.d.cts
CHANGED
package/dist/take-first-by.d.ts
CHANGED
package/dist/take-last-while.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkVPG3W5JHcjs = require('./chunk-VPG3W5JH.cjs');require('./chunk-Y74ER22O.cjs');require('./chunk-7T4AVFYJ.cjs');exports.takeLastWhile = _chunkVPG3W5JHcjs.a;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { I as IterableContainer } from './types-CC8iZVKO.cjs';
|
|
2
|
+
import 'type-fest';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Returns elements from the end of the array until the predicate returns false.
|
|
3
6
|
* The returned elements will be in the same order as in the original array.
|
|
@@ -11,7 +14,7 @@
|
|
|
11
14
|
* @dataFirst
|
|
12
15
|
* @category Array
|
|
13
16
|
*/
|
|
14
|
-
declare function takeLastWhile<T>(data:
|
|
17
|
+
declare function takeLastWhile<T extends IterableContainer>(data: T, predicate: (item: T[number], index: number, data: T) => boolean): Array<T[number]>;
|
|
15
18
|
/**
|
|
16
19
|
* Returns elements from the end of the array until the predicate returns false.
|
|
17
20
|
* The returned elements will be in the same order as in the original array.
|
|
@@ -24,6 +27,6 @@ declare function takeLastWhile<T>(data: ReadonlyArray<T>, predicate: (item: T, i
|
|
|
24
27
|
* @dataLast
|
|
25
28
|
* @category Array
|
|
26
29
|
*/
|
|
27
|
-
declare function takeLastWhile<T>(predicate: (item: T, index: number, data:
|
|
30
|
+
declare function takeLastWhile<T extends IterableContainer>(predicate: (item: T[number], index: number, data: T) => boolean): (data: T) => Array<T[number]>;
|
|
28
31
|
|
|
29
32
|
export { takeLastWhile };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { I as IterableContainer } from './types-CC8iZVKO.js';
|
|
2
|
+
import 'type-fest';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Returns elements from the end of the array until the predicate returns false.
|
|
3
6
|
* The returned elements will be in the same order as in the original array.
|
|
@@ -11,7 +14,7 @@
|
|
|
11
14
|
* @dataFirst
|
|
12
15
|
* @category Array
|
|
13
16
|
*/
|
|
14
|
-
declare function takeLastWhile<T>(data:
|
|
17
|
+
declare function takeLastWhile<T extends IterableContainer>(data: T, predicate: (item: T[number], index: number, data: T) => boolean): Array<T[number]>;
|
|
15
18
|
/**
|
|
16
19
|
* Returns elements from the end of the array until the predicate returns false.
|
|
17
20
|
* The returned elements will be in the same order as in the original array.
|
|
@@ -24,6 +27,6 @@ declare function takeLastWhile<T>(data: ReadonlyArray<T>, predicate: (item: T, i
|
|
|
24
27
|
* @dataLast
|
|
25
28
|
* @category Array
|
|
26
29
|
*/
|
|
27
|
-
declare function takeLastWhile<T>(predicate: (item: T, index: number, data:
|
|
30
|
+
declare function takeLastWhile<T extends IterableContainer>(predicate: (item: T[number], index: number, data: T) => boolean): (data: T) => Array<T[number]>;
|
|
28
31
|
|
|
29
32
|
export { takeLastWhile };
|
package/dist/take-last-while.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-KAA6IVBL.js";import"./chunk-JFXZ246Y.js";import"./chunk-KQGY2DBY.js";export{a as takeLastWhile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _chunkVPG3W5JHcjs = require('./chunk-VPG3W5JH.cjs');var _chunkI6VXEY44cjs = require('./chunk-I6VXEY44.cjs');require('./chunk-3X6SAJDQ.cjs');var _chunkWLNQOMKLcjs = require('./chunk-WLNQOMKL.cjs');require('./chunk-Y74ER22O.cjs');require('./chunk-7T4AVFYJ.cjs');describe("data-first",()=>{test("empty array",()=>{let e=_chunkVPG3W5JHcjs.a.call(void 0, [],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("regular array",()=>{let e=_chunkVPG3W5JHcjs.a.call(void 0, [],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("regular array with union type",()=>{let e=_chunkVPG3W5JHcjs.a.call(void 0, [],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("prefix array",()=>{let e=_chunkVPG3W5JHcjs.a.call(void 0, [1],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("suffix array",()=>{let e=_chunkVPG3W5JHcjs.a.call(void 0, [1],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let e=_chunkVPG3W5JHcjs.a.call(void 0, [1,"a"],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("tuple",()=>{let e=_chunkVPG3W5JHcjs.a.call(void 0, [1,"a",!0],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("union of arrays",()=>{let e=_chunkVPG3W5JHcjs.a.call(void 0, [],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()})});describe("data-last",()=>{test("empty array",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [],_chunkVPG3W5JHcjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("regular array",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [],_chunkVPG3W5JHcjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("regular array with union type",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [],_chunkVPG3W5JHcjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("prefix array",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [1],_chunkVPG3W5JHcjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("suffix array",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [1],_chunkVPG3W5JHcjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [1,"a"],_chunkVPG3W5JHcjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("tuple",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [1,"a",!0],_chunkVPG3W5JHcjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("union of arrays",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [],_chunkVPG3W5JHcjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),describe("predicate is typed correctly",()=>{test("empty array",()=>{_chunkI6VXEY44cjs.a.call(void 0, [],_chunkVPG3W5JHcjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("regular array",()=>{_chunkI6VXEY44cjs.a.call(void 0, [],_chunkVPG3W5JHcjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("regular array with union type",()=>{_chunkI6VXEY44cjs.a.call(void 0, [],_chunkVPG3W5JHcjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("prefix array",()=>{_chunkI6VXEY44cjs.a.call(void 0, [1],_chunkVPG3W5JHcjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("suffix array",()=>{_chunkI6VXEY44cjs.a.call(void 0, [1],_chunkVPG3W5JHcjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("array with suffix and prefix",()=>{_chunkI6VXEY44cjs.a.call(void 0, [1,"a"],_chunkVPG3W5JHcjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("tuple",()=>{_chunkI6VXEY44cjs.a.call(void 0, [1,"a",!0],_chunkVPG3W5JHcjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("union of arrays",()=>{_chunkI6VXEY44cjs.a.call(void 0, [],_chunkVPG3W5JHcjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-KAA6IVBL.js";import{a as t}from"./chunk-6ALZHU2N.js";import"./chunk-MYLYERXO.js";import{a}from"./chunk-T5XG33UI.js";import"./chunk-JFXZ246Y.js";import"./chunk-KQGY2DBY.js";describe("data-first",()=>{test("empty array",()=>{let e=r([],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("regular array",()=>{let e=r([],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("regular array with union type",()=>{let e=r([],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("prefix array",()=>{let e=r([1],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("suffix array",()=>{let e=r([1],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let e=r([1,"a"],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("tuple",()=>{let e=r([1,"a",!0],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("union of arrays",()=>{let e=r([],a(!0));expectTypeOf(e).toEqualTypeOf()})});describe("data-last",()=>{test("empty array",()=>{let e=t([],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("regular array",()=>{let e=t([],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("regular array with union type",()=>{let e=t([],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("prefix array",()=>{let e=t([1],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("suffix array",()=>{let e=t([1],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let e=t([1,"a"],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("tuple",()=>{let e=t([1,"a",!0],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("union of arrays",()=>{let e=t([],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),describe("predicate is typed correctly",()=>{test("empty array",()=>{t([],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("regular array",()=>{t([],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("regular array with union type",()=>{t([],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("prefix array",()=>{t([1],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("suffix array",()=>{t([1],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("array with suffix and prefix",()=>{t([1,"a"],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("tuple",()=>{t([1,"a",!0],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("union of arrays",()=>{t([],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))})})});
|
package/dist/take-last.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3DFX2FQGcjs = require('./chunk-3DFX2FQG.cjs');require('./chunk-Y74ER22O.cjs');require('./chunk-7T4AVFYJ.cjs');exports.takeLast = _chunk3DFX2FQGcjs.a;
|
package/dist/take-last.d.cts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { I as IterableContainer } from './types-CC8iZVKO.cjs';
|
|
2
|
+
import 'type-fest';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Takes the last `n` elements from the `array`.
|
|
3
6
|
*
|
|
@@ -10,7 +13,7 @@
|
|
|
10
13
|
* @dataFirst
|
|
11
14
|
* @category Array
|
|
12
15
|
*/
|
|
13
|
-
declare function takeLast<T>(array:
|
|
16
|
+
declare function takeLast<T extends IterableContainer>(array: T, n: number): Array<T[number]>;
|
|
14
17
|
/**
|
|
15
18
|
* Take the last `n` elements from the `array`.
|
|
16
19
|
*
|
|
@@ -22,6 +25,6 @@ declare function takeLast<T>(array: ReadonlyArray<T>, n: number): Array<T>;
|
|
|
22
25
|
* @dataLast
|
|
23
26
|
* @category Array
|
|
24
27
|
*/
|
|
25
|
-
declare function takeLast<T>(n: number): (array:
|
|
28
|
+
declare function takeLast<T extends IterableContainer>(n: number): (array: T) => Array<T[number]>;
|
|
26
29
|
|
|
27
30
|
export { takeLast };
|
package/dist/take-last.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { I as IterableContainer } from './types-CC8iZVKO.js';
|
|
2
|
+
import 'type-fest';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Takes the last `n` elements from the `array`.
|
|
3
6
|
*
|
|
@@ -10,7 +13,7 @@
|
|
|
10
13
|
* @dataFirst
|
|
11
14
|
* @category Array
|
|
12
15
|
*/
|
|
13
|
-
declare function takeLast<T>(array:
|
|
16
|
+
declare function takeLast<T extends IterableContainer>(array: T, n: number): Array<T[number]>;
|
|
14
17
|
/**
|
|
15
18
|
* Take the last `n` elements from the `array`.
|
|
16
19
|
*
|
|
@@ -22,6 +25,6 @@ declare function takeLast<T>(array: ReadonlyArray<T>, n: number): Array<T>;
|
|
|
22
25
|
* @dataLast
|
|
23
26
|
* @category Array
|
|
24
27
|
*/
|
|
25
|
-
declare function takeLast<T>(n: number): (array:
|
|
28
|
+
declare function takeLast<T extends IterableContainer>(n: number): (array: T) => Array<T[number]>;
|
|
26
29
|
|
|
27
30
|
export { takeLast };
|
package/dist/take-last.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-OJ2QGTFS.js";import"./chunk-JFXZ246Y.js";import"./chunk-KQGY2DBY.js";export{a as takeLast};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _chunk3DFX2FQGcjs = require('./chunk-3DFX2FQG.cjs');var _chunkI6VXEY44cjs = require('./chunk-I6VXEY44.cjs');require('./chunk-3X6SAJDQ.cjs');require('./chunk-Y74ER22O.cjs');require('./chunk-7T4AVFYJ.cjs');describe("data-first",()=>{test("empty array",()=>{let r=_chunk3DFX2FQGcjs.a.call(void 0, [],2);expectTypeOf(r).toEqualTypeOf()}),test("regular array",()=>{let r=_chunk3DFX2FQGcjs.a.call(void 0, [],2);expectTypeOf(r).toEqualTypeOf()}),test("regular array with union type",()=>{let r=_chunk3DFX2FQGcjs.a.call(void 0, [],2);expectTypeOf(r).toEqualTypeOf()}),test("prefix array",()=>{let r=_chunk3DFX2FQGcjs.a.call(void 0, [1],2);expectTypeOf(r).toEqualTypeOf()}),test("suffix array",()=>{let r=_chunk3DFX2FQGcjs.a.call(void 0, [1],2);expectTypeOf(r).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let r=_chunk3DFX2FQGcjs.a.call(void 0, [1,"a"],2);expectTypeOf(r).toEqualTypeOf()}),test("tuple",()=>{let r=_chunk3DFX2FQGcjs.a.call(void 0, [1,"a",!0],2);expectTypeOf(r).toEqualTypeOf()}),test("union of arrays",()=>{let r=_chunk3DFX2FQGcjs.a.call(void 0, [],2);expectTypeOf(r).toEqualTypeOf()})});describe("data-last",()=>{test("empty array",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [],_chunk3DFX2FQGcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("regular array",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [],_chunk3DFX2FQGcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("regular array with union type",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [],_chunk3DFX2FQGcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("prefix array",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [1],_chunk3DFX2FQGcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("suffix array",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [1],_chunk3DFX2FQGcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [1,"a"],_chunk3DFX2FQGcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("tuple",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [1,"a",!0],_chunk3DFX2FQGcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("union of arrays",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [],_chunk3DFX2FQGcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-OJ2QGTFS.js";import{a as t}from"./chunk-6ALZHU2N.js";import"./chunk-MYLYERXO.js";import"./chunk-JFXZ246Y.js";import"./chunk-KQGY2DBY.js";describe("data-first",()=>{test("empty array",()=>{let r=e([],2);expectTypeOf(r).toEqualTypeOf()}),test("regular array",()=>{let r=e([],2);expectTypeOf(r).toEqualTypeOf()}),test("regular array with union type",()=>{let r=e([],2);expectTypeOf(r).toEqualTypeOf()}),test("prefix array",()=>{let r=e([1],2);expectTypeOf(r).toEqualTypeOf()}),test("suffix array",()=>{let r=e([1],2);expectTypeOf(r).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let r=e([1,"a"],2);expectTypeOf(r).toEqualTypeOf()}),test("tuple",()=>{let r=e([1,"a",!0],2);expectTypeOf(r).toEqualTypeOf()}),test("union of arrays",()=>{let r=e([],2);expectTypeOf(r).toEqualTypeOf()})});describe("data-last",()=>{test("empty array",()=>{let r=t([],e(2));expectTypeOf(r).toEqualTypeOf()}),test("regular array",()=>{let r=t([],e(2));expectTypeOf(r).toEqualTypeOf()}),test("regular array with union type",()=>{let r=t([],e(2));expectTypeOf(r).toEqualTypeOf()}),test("prefix array",()=>{let r=t([1],e(2));expectTypeOf(r).toEqualTypeOf()}),test("suffix array",()=>{let r=t([1],e(2));expectTypeOf(r).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let r=t([1,"a"],e(2));expectTypeOf(r).toEqualTypeOf()}),test("tuple",()=>{let r=t([1,"a",!0],e(2));expectTypeOf(r).toEqualTypeOf()}),test("union of arrays",()=>{let r=t([],e(2));expectTypeOf(r).toEqualTypeOf()})});
|
package/dist/take-while.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZO4ND36Ncjs = require('./chunk-ZO4ND36N.cjs');require('./chunk-Y74ER22O.cjs');require('./chunk-7T4AVFYJ.cjs');exports.takeWhile = _chunkZO4ND36Ncjs.a;
|
package/dist/take-while.d.cts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { I as IterableContainer } from './types-CC8iZVKO.cjs';
|
|
2
|
+
import 'type-fest';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Returns elements from the array until predicate returns false.
|
|
3
6
|
*
|
|
@@ -10,7 +13,7 @@
|
|
|
10
13
|
* @dataFirst
|
|
11
14
|
* @category Array
|
|
12
15
|
*/
|
|
13
|
-
declare function takeWhile<T>(data:
|
|
16
|
+
declare function takeWhile<T extends IterableContainer>(data: T, predicate: (item: T[number], index: number, data: T) => boolean): Array<T[number]>;
|
|
14
17
|
/**
|
|
15
18
|
* Returns elements from the array until predicate returns false.
|
|
16
19
|
*
|
|
@@ -22,6 +25,6 @@ declare function takeWhile<T>(data: ReadonlyArray<T>, predicate: (item: T, index
|
|
|
22
25
|
* @dataLast
|
|
23
26
|
* @category Array
|
|
24
27
|
*/
|
|
25
|
-
declare function takeWhile<T>(predicate: (item: T, index: number, data:
|
|
28
|
+
declare function takeWhile<T extends IterableContainer>(predicate: (item: T[number], index: number, data: T) => boolean): (array: T) => Array<T[number]>;
|
|
26
29
|
|
|
27
30
|
export { takeWhile };
|
package/dist/take-while.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { I as IterableContainer } from './types-CC8iZVKO.js';
|
|
2
|
+
import 'type-fest';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Returns elements from the array until predicate returns false.
|
|
3
6
|
*
|
|
@@ -10,7 +13,7 @@
|
|
|
10
13
|
* @dataFirst
|
|
11
14
|
* @category Array
|
|
12
15
|
*/
|
|
13
|
-
declare function takeWhile<T>(data:
|
|
16
|
+
declare function takeWhile<T extends IterableContainer>(data: T, predicate: (item: T[number], index: number, data: T) => boolean): Array<T[number]>;
|
|
14
17
|
/**
|
|
15
18
|
* Returns elements from the array until predicate returns false.
|
|
16
19
|
*
|
|
@@ -22,6 +25,6 @@ declare function takeWhile<T>(data: ReadonlyArray<T>, predicate: (item: T, index
|
|
|
22
25
|
* @dataLast
|
|
23
26
|
* @category Array
|
|
24
27
|
*/
|
|
25
|
-
declare function takeWhile<T>(predicate: (item: T, index: number, data:
|
|
28
|
+
declare function takeWhile<T extends IterableContainer>(predicate: (item: T[number], index: number, data: T) => boolean): (array: T) => Array<T[number]>;
|
|
26
29
|
|
|
27
30
|
export { takeWhile };
|
package/dist/take-while.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-VN2OAM2N.js";import"./chunk-JFXZ246Y.js";import"./chunk-KQGY2DBY.js";export{a as takeWhile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _chunkZO4ND36Ncjs = require('./chunk-ZO4ND36N.cjs');var _chunkI6VXEY44cjs = require('./chunk-I6VXEY44.cjs');require('./chunk-3X6SAJDQ.cjs');var _chunkWLNQOMKLcjs = require('./chunk-WLNQOMKL.cjs');require('./chunk-Y74ER22O.cjs');require('./chunk-7T4AVFYJ.cjs');describe("data-first",()=>{test("empty array",()=>{let e=_chunkZO4ND36Ncjs.a.call(void 0, [],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("regular array",()=>{let e=_chunkZO4ND36Ncjs.a.call(void 0, [],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("regular array with union type",()=>{let e=_chunkZO4ND36Ncjs.a.call(void 0, [],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("prefix array",()=>{let e=_chunkZO4ND36Ncjs.a.call(void 0, [1],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("suffix array",()=>{let e=_chunkZO4ND36Ncjs.a.call(void 0, [1],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let e=_chunkZO4ND36Ncjs.a.call(void 0, [1,"a"],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("tuple",()=>{let e=_chunkZO4ND36Ncjs.a.call(void 0, [1,"a",!0],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()}),test("union of arrays",()=>{let e=_chunkZO4ND36Ncjs.a.call(void 0, [],_chunkWLNQOMKLcjs.a.call(void 0, !0));expectTypeOf(e).toEqualTypeOf()})});describe("data-last",()=>{test("empty array",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [],_chunkZO4ND36Ncjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("regular array",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [],_chunkZO4ND36Ncjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("regular array with union type",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [],_chunkZO4ND36Ncjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("prefix array",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [1],_chunkZO4ND36Ncjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("suffix array",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [1],_chunkZO4ND36Ncjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [1,"a"],_chunkZO4ND36Ncjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("tuple",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [1,"a",!0],_chunkZO4ND36Ncjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),test("union of arrays",()=>{let e=_chunkI6VXEY44cjs.a.call(void 0, [],_chunkZO4ND36Ncjs.a.call(void 0, _chunkWLNQOMKLcjs.a.call(void 0, !0)));expectTypeOf(e).toEqualTypeOf()}),describe("predicate is typed correctly",()=>{test("empty array",()=>{_chunkI6VXEY44cjs.a.call(void 0, [],_chunkZO4ND36Ncjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("regular array",()=>{_chunkI6VXEY44cjs.a.call(void 0, [],_chunkZO4ND36Ncjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("regular array with union type",()=>{_chunkI6VXEY44cjs.a.call(void 0, [],_chunkZO4ND36Ncjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("prefix array",()=>{_chunkI6VXEY44cjs.a.call(void 0, [1],_chunkZO4ND36Ncjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("suffix array",()=>{_chunkI6VXEY44cjs.a.call(void 0, [1],_chunkZO4ND36Ncjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("array with suffix and prefix",()=>{_chunkI6VXEY44cjs.a.call(void 0, [1,"a"],_chunkZO4ND36Ncjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("tuple",()=>{_chunkI6VXEY44cjs.a.call(void 0, [1,"a",!0],_chunkZO4ND36Ncjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("union of arrays",()=>{_chunkI6VXEY44cjs.a.call(void 0, [],_chunkZO4ND36Ncjs.a.call(void 0, (e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-VN2OAM2N.js";import{a as t}from"./chunk-6ALZHU2N.js";import"./chunk-MYLYERXO.js";import{a}from"./chunk-T5XG33UI.js";import"./chunk-JFXZ246Y.js";import"./chunk-KQGY2DBY.js";describe("data-first",()=>{test("empty array",()=>{let e=r([],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("regular array",()=>{let e=r([],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("regular array with union type",()=>{let e=r([],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("prefix array",()=>{let e=r([1],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("suffix array",()=>{let e=r([1],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let e=r([1,"a"],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("tuple",()=>{let e=r([1,"a",!0],a(!0));expectTypeOf(e).toEqualTypeOf()}),test("union of arrays",()=>{let e=r([],a(!0));expectTypeOf(e).toEqualTypeOf()})});describe("data-last",()=>{test("empty array",()=>{let e=t([],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("regular array",()=>{let e=t([],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("regular array with union type",()=>{let e=t([],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("prefix array",()=>{let e=t([1],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("suffix array",()=>{let e=t([1],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let e=t([1,"a"],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("tuple",()=>{let e=t([1,"a",!0],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),test("union of arrays",()=>{let e=t([],r(a(!0)));expectTypeOf(e).toEqualTypeOf()}),describe("predicate is typed correctly",()=>{test("empty array",()=>{t([],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("regular array",()=>{t([],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("regular array with union type",()=>{t([],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("prefix array",()=>{t([1],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("suffix array",()=>{t([1],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("array with suffix and prefix",()=>{t([1,"a"],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("tuple",()=>{t([1,"a",!0],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))}),test("union of arrays",()=>{t([],r((e,u,y)=>(expectTypeOf(e).toEqualTypeOf(),expectTypeOf(u).toEqualTypeOf(),expectTypeOf(y).toEqualTypeOf(),!0)))})})});
|
package/dist/take.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZ5UEQBZPcjs = require('./chunk-Z5UEQBZP.cjs');require('./chunk-3X6SAJDQ.cjs');require('./chunk-Y74ER22O.cjs');require('./chunk-7T4AVFYJ.cjs');exports.take = _chunkZ5UEQBZPcjs.a;
|
package/dist/take.d.cts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { I as IterableContainer } from './types-CC8iZVKO.cjs';
|
|
2
|
+
import 'type-fest';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Returns the first `n` elements of `array`.
|
|
3
6
|
*
|
|
@@ -11,7 +14,7 @@
|
|
|
11
14
|
* @lazy
|
|
12
15
|
* @category Array
|
|
13
16
|
*/
|
|
14
|
-
declare function take<T>(array:
|
|
17
|
+
declare function take<T extends IterableContainer>(array: T, n: number): Array<T[number]>;
|
|
15
18
|
/**
|
|
16
19
|
* Returns the first `n` elements of `array`.
|
|
17
20
|
*
|
|
@@ -24,6 +27,6 @@ declare function take<T>(array: ReadonlyArray<T>, n: number): Array<T>;
|
|
|
24
27
|
* @lazy
|
|
25
28
|
* @category Array
|
|
26
29
|
*/
|
|
27
|
-
declare function take
|
|
30
|
+
declare function take(n: number): <T extends IterableContainer>(array: T) => Array<T[number]>;
|
|
28
31
|
|
|
29
32
|
export { take };
|
package/dist/take.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { I as IterableContainer } from './types-CC8iZVKO.js';
|
|
2
|
+
import 'type-fest';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Returns the first `n` elements of `array`.
|
|
3
6
|
*
|
|
@@ -11,7 +14,7 @@
|
|
|
11
14
|
* @lazy
|
|
12
15
|
* @category Array
|
|
13
16
|
*/
|
|
14
|
-
declare function take<T>(array:
|
|
17
|
+
declare function take<T extends IterableContainer>(array: T, n: number): Array<T[number]>;
|
|
15
18
|
/**
|
|
16
19
|
* Returns the first `n` elements of `array`.
|
|
17
20
|
*
|
|
@@ -24,6 +27,6 @@ declare function take<T>(array: ReadonlyArray<T>, n: number): Array<T>;
|
|
|
24
27
|
* @lazy
|
|
25
28
|
* @category Array
|
|
26
29
|
*/
|
|
27
|
-
declare function take
|
|
30
|
+
declare function take(n: number): <T extends IterableContainer>(array: T) => Array<T[number]>;
|
|
28
31
|
|
|
29
32
|
export { take };
|
package/dist/take.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-EPHUNAE5.js";import"./chunk-MYLYERXO.js";import"./chunk-JFXZ246Y.js";import"./chunk-KQGY2DBY.js";export{a as take};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _chunkZ5UEQBZPcjs = require('./chunk-Z5UEQBZP.cjs');var _chunkI6VXEY44cjs = require('./chunk-I6VXEY44.cjs');require('./chunk-3X6SAJDQ.cjs');require('./chunk-Y74ER22O.cjs');require('./chunk-7T4AVFYJ.cjs');describe("data-first",()=>{test("empty array",()=>{let r=_chunkZ5UEQBZPcjs.a.call(void 0, [],2);expectTypeOf(r).toEqualTypeOf()}),test("regular array",()=>{let r=_chunkZ5UEQBZPcjs.a.call(void 0, [],2);expectTypeOf(r).toEqualTypeOf()}),test("regular array with union type",()=>{let r=_chunkZ5UEQBZPcjs.a.call(void 0, [],2);expectTypeOf(r).toEqualTypeOf()}),test("prefix array",()=>{let r=_chunkZ5UEQBZPcjs.a.call(void 0, [1],2);expectTypeOf(r).toEqualTypeOf()}),test("suffix array",()=>{let r=_chunkZ5UEQBZPcjs.a.call(void 0, [1],2);expectTypeOf(r).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let r=_chunkZ5UEQBZPcjs.a.call(void 0, [1,"a"],2);expectTypeOf(r).toEqualTypeOf()}),test("tuple",()=>{let r=_chunkZ5UEQBZPcjs.a.call(void 0, [1,"a",!0],2);expectTypeOf(r).toEqualTypeOf()}),test("union of arrays",()=>{let r=_chunkZ5UEQBZPcjs.a.call(void 0, [],2);expectTypeOf(r).toEqualTypeOf()})});describe("data-last",()=>{test("empty array",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [],_chunkZ5UEQBZPcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("regular array",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [],_chunkZ5UEQBZPcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("regular array with union type",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [],_chunkZ5UEQBZPcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("prefix array",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [1],_chunkZ5UEQBZPcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("suffix array",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [1],_chunkZ5UEQBZPcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [1,"a"],_chunkZ5UEQBZPcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("tuple",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [1,"a",!0],_chunkZ5UEQBZPcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()}),test("union of arrays",()=>{let r=_chunkI6VXEY44cjs.a.call(void 0, [],_chunkZ5UEQBZPcjs.a.call(void 0, 2));expectTypeOf(r).toEqualTypeOf()})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-EPHUNAE5.js";import{a as t}from"./chunk-6ALZHU2N.js";import"./chunk-MYLYERXO.js";import"./chunk-JFXZ246Y.js";import"./chunk-KQGY2DBY.js";describe("data-first",()=>{test("empty array",()=>{let r=e([],2);expectTypeOf(r).toEqualTypeOf()}),test("regular array",()=>{let r=e([],2);expectTypeOf(r).toEqualTypeOf()}),test("regular array with union type",()=>{let r=e([],2);expectTypeOf(r).toEqualTypeOf()}),test("prefix array",()=>{let r=e([1],2);expectTypeOf(r).toEqualTypeOf()}),test("suffix array",()=>{let r=e([1],2);expectTypeOf(r).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let r=e([1,"a"],2);expectTypeOf(r).toEqualTypeOf()}),test("tuple",()=>{let r=e([1,"a",!0],2);expectTypeOf(r).toEqualTypeOf()}),test("union of arrays",()=>{let r=e([],2);expectTypeOf(r).toEqualTypeOf()})});describe("data-last",()=>{test("empty array",()=>{let r=t([],e(2));expectTypeOf(r).toEqualTypeOf()}),test("regular array",()=>{let r=t([],e(2));expectTypeOf(r).toEqualTypeOf()}),test("regular array with union type",()=>{let r=t([],e(2));expectTypeOf(r).toEqualTypeOf()}),test("prefix array",()=>{let r=t([1],e(2));expectTypeOf(r).toEqualTypeOf()}),test("suffix array",()=>{let r=t([1],e(2));expectTypeOf(r).toEqualTypeOf()}),test("array with suffix and prefix",()=>{let r=t([1,"a"],e(2));expectTypeOf(r).toEqualTypeOf()}),test("tuple",()=>{let r=t([1,"a",!0],e(2));expectTypeOf(r).toEqualTypeOf()}),test("union of arrays",()=>{let r=t([],e(2));expectTypeOf(r).toEqualTypeOf()})});
|
package/dist/tap.spec-d.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _chunkYWO7TFODcjs = require('./chunk-YWO7TFOD.cjs');var _chunkKLQZU5J4cjs = require('./chunk-KLQZU5J4.cjs');var
|
|
1
|
+
"use strict";var _chunkYWO7TFODcjs = require('./chunk-YWO7TFOD.cjs');var _chunkKLQZU5J4cjs = require('./chunk-KLQZU5J4.cjs');var _chunkWW7P3TAUcjs = require('./chunk-WW7P3TAU.cjs');var _chunk7IYJC2PMcjs = require('./chunk-7IYJC2PM.cjs');var _chunkI6VXEY44cjs = require('./chunk-I6VXEY44.cjs');require('./chunk-3X6SAJDQ.cjs');require('./chunk-Y74ER22O.cjs');require('./chunk-7T4AVFYJ.cjs');it("should work in the middle of pipe sequence",()=>{_chunkI6VXEY44cjs.a.call(void 0, [-1,2],_chunk7IYJC2PMcjs.a.call(void 0, e=>e>0),_chunkYWO7TFODcjs.a.call(void 0, e=>{expectTypeOf(e).toEqualTypeOf()}),_chunkWW7P3TAUcjs.a.call(void 0, _chunkKLQZU5J4cjs.a.call(void 0, 2)))});it("should infer types after tapping function reference with parameter type any",()=>{_chunkI6VXEY44cjs.a.call(void 0, [-1,2],_chunk7IYJC2PMcjs.a.call(void 0, e=>e>0),_chunkYWO7TFODcjs.a.call(void 0, i),_chunkWW7P3TAUcjs.a.call(void 0, e=>(expectTypeOf(e).toEqualTypeOf(),e*2)))});function i(e){return e}
|
package/dist/tap.spec-d.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"./chunk-ENIRKKU6.js";import{a as n}from"./chunk-MBYBX5B3.js";import{a as
|
|
1
|
+
import{a as o}from"./chunk-ENIRKKU6.js";import{a as n}from"./chunk-MBYBX5B3.js";import{a as t}from"./chunk-QRDGUNHT.js";import{a as p}from"./chunk-BGPRJNRQ.js";import{a as r}from"./chunk-6ALZHU2N.js";import"./chunk-MYLYERXO.js";import"./chunk-JFXZ246Y.js";import"./chunk-KQGY2DBY.js";it("should work in the middle of pipe sequence",()=>{r([-1,2],p(e=>e>0),o(e=>{expectTypeOf(e).toEqualTypeOf()}),t(n(2)))});it("should infer types after tapping function reference with parameter type any",()=>{r([-1,2],p(e=>e>0),o(i),t(e=>(expectTypeOf(e).toEqualTypeOf(),e*2)))});function i(e){return e}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmptyObject, IsAny, Simplify, IsLiteral, IsNever, KeysOfUnion, IsStringLiteral, IsNumericLiteral, IsSymbolLiteral, Split } from 'type-fest';
|
|
1
|
+
import { EmptyObject, IsAny, Simplify, IsLiteral, IsNever, KeysOfUnion, IsStringLiteral, IsNumericLiteral, IsSymbolLiteral, Split, IfNever } from 'type-fest';
|
|
2
2
|
|
|
3
3
|
declare const __brand: unique symbol;
|
|
4
4
|
type Branded<T, Brand extends symbol> = T & {
|
|
@@ -19,7 +19,7 @@ type Mapped<T extends IterableContainer, K> = {
|
|
|
19
19
|
* We would've named this `ArrayLike`, but that's already used by typescript...
|
|
20
20
|
* @see This was inspired by the type-definition of Promise.all (https://github.com/microsoft/TypeScript/blob/1df5717b120cddd325deab8b0f2b2c3eecaf2b01/src/lib/es2015.promise.d.ts#L21)
|
|
21
21
|
*/
|
|
22
|
-
type IterableContainer<T = unknown> =
|
|
22
|
+
type IterableContainer<T = unknown> = readonly [] | ReadonlyArray<T>;
|
|
23
23
|
/**
|
|
24
24
|
* Check if a type is guaranteed to be a bounded record: a record with a finite
|
|
25
25
|
* set of keys.
|
|
@@ -111,5 +111,58 @@ type InternalIsUnion<T, U = T> = (IsNever<T> extends true ? false : T extends an
|
|
|
111
111
|
* type Result = GuardType<TypeGuardFn>; // `string`
|
|
112
112
|
*/
|
|
113
113
|
type GuardType<T, Fallback = never> = T extends (x: any, ...rest: any) => x is infer U ? U : Fallback;
|
|
114
|
+
/**
|
|
115
|
+
* An array with *exactly* N elements in it.
|
|
116
|
+
*
|
|
117
|
+
* Only literal N values are supported. For very large N the type might result
|
|
118
|
+
* in a recurse depth error. For negative N the type would result in an infinite
|
|
119
|
+
* recursion. None of these have protections because this is an internal type!
|
|
120
|
+
*/
|
|
121
|
+
type NTuple<T, N extends number, Result extends Array<unknown> = []> = Result['length'] extends N ? Result : NTuple<T, N, [...Result, T]>;
|
|
122
|
+
/**
|
|
123
|
+
* Takes an array and returns the types that make up it's parts. The suffix is
|
|
124
|
+
* anything before the rest parameter (if any), the prefix is anything after the
|
|
125
|
+
* rest parameter (if any), and the item is the type of the rest parameter.
|
|
126
|
+
*
|
|
127
|
+
* The output could be used to reconstruct the input: `[
|
|
128
|
+
* ...TupleParts<T>["prefix"],
|
|
129
|
+
* ...Array<TupleParts<T>["item"]>,
|
|
130
|
+
* ...TupleParts<T>["suffix"],
|
|
131
|
+
* ]`.
|
|
132
|
+
*/
|
|
133
|
+
type TupleParts<T, Prefix extends Array<unknown> = [], Suffix extends Array<unknown> = []> = T extends readonly [infer Head, ...infer Tail] ? TupleParts<Tail, [...Prefix, Head], Suffix> : T extends readonly [...infer Head, infer Tail] ? TupleParts<Head, Prefix, [Tail, ...Suffix]> : T extends ReadonlyArray<infer Item> ? {
|
|
134
|
+
prefix: Prefix;
|
|
135
|
+
item: Item;
|
|
136
|
+
suffix: Suffix;
|
|
137
|
+
} : never;
|
|
138
|
+
/**
|
|
139
|
+
* `never[]` and `[]` are not the same type, and in some cases they aren't
|
|
140
|
+
* interchangeable.
|
|
141
|
+
*
|
|
142
|
+
* This type makes it easier to use the result of TupleParts when the input is a
|
|
143
|
+
* fixed-length tuple but we still want to spread the rest of the array. e.g.
|
|
144
|
+
* `[...CoercedArray<TupleParts<T>["item"]>, ...TupleParts<T>["suffix"]]`.
|
|
145
|
+
*
|
|
146
|
+
*/
|
|
147
|
+
type CoercedArray<T> = IfNever<T, [], Array<T>>;
|
|
148
|
+
/**
|
|
149
|
+
* The result of running a function that would dedupe an array (`unique`,
|
|
150
|
+
* `uniqueBy`, and `uniqueWith`).
|
|
151
|
+
*
|
|
152
|
+
* There are certain traits of the output which are unique to a deduped array
|
|
153
|
+
* that allow us to create a better type; see comments inline.
|
|
154
|
+
*
|
|
155
|
+
* !Note: We can build better types for each of the unique functions
|
|
156
|
+
* _separately_ by taking advantage of _other_ characteristics that are unique
|
|
157
|
+
* to each one (e.g. in `unique` we know that each item that has a disjoint type
|
|
158
|
+
* to all previous items would be part of the output, even when it isn't the
|
|
159
|
+
* first), but to make this utility the most useful we kept it simple and
|
|
160
|
+
* generic for now.
|
|
161
|
+
*/
|
|
162
|
+
type Deduped<T extends IterableContainer> = T extends readonly [] ? [
|
|
163
|
+
] : T extends readonly [infer Head, ...infer Rest] ? [
|
|
164
|
+
Head,
|
|
165
|
+
...Array<Rest[number]>
|
|
166
|
+
] : T extends readonly [...Array<unknown>, unknown] ? NonEmptyArray<T[number]> : Array<T[number]>;
|
|
114
167
|
|
|
115
|
-
export type { Branded as B, EnumerableStringKeyedValueOf as E, GuardType as G, IterableContainer as I, Mapped as M,
|
|
168
|
+
export type { Branded as B, CoercedArray as C, Deduped as D, EnumerableStringKeyedValueOf as E, GuardType as G, IterableContainer as I, Mapped as M, NTuple as N, ReconstructedRecord as R, TupleParts as T, UpsertProp as U, NonEmptyArray as a, EnumerableStringKeyOf as b, ExactRecord as c, NarrowedTo as d, IsUnion as e, IfBoundedRecord as f, ReorderedArray as g };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmptyObject, IsAny, Simplify, IsLiteral, IsNever, KeysOfUnion, IsStringLiteral, IsNumericLiteral, IsSymbolLiteral, Split } from 'type-fest';
|
|
1
|
+
import { EmptyObject, IsAny, Simplify, IsLiteral, IsNever, KeysOfUnion, IsStringLiteral, IsNumericLiteral, IsSymbolLiteral, Split, IfNever } from 'type-fest';
|
|
2
2
|
|
|
3
3
|
declare const __brand: unique symbol;
|
|
4
4
|
type Branded<T, Brand extends symbol> = T & {
|
|
@@ -19,7 +19,7 @@ type Mapped<T extends IterableContainer, K> = {
|
|
|
19
19
|
* We would've named this `ArrayLike`, but that's already used by typescript...
|
|
20
20
|
* @see This was inspired by the type-definition of Promise.all (https://github.com/microsoft/TypeScript/blob/1df5717b120cddd325deab8b0f2b2c3eecaf2b01/src/lib/es2015.promise.d.ts#L21)
|
|
21
21
|
*/
|
|
22
|
-
type IterableContainer<T = unknown> =
|
|
22
|
+
type IterableContainer<T = unknown> = readonly [] | ReadonlyArray<T>;
|
|
23
23
|
/**
|
|
24
24
|
* Check if a type is guaranteed to be a bounded record: a record with a finite
|
|
25
25
|
* set of keys.
|
|
@@ -111,5 +111,58 @@ type InternalIsUnion<T, U = T> = (IsNever<T> extends true ? false : T extends an
|
|
|
111
111
|
* type Result = GuardType<TypeGuardFn>; // `string`
|
|
112
112
|
*/
|
|
113
113
|
type GuardType<T, Fallback = never> = T extends (x: any, ...rest: any) => x is infer U ? U : Fallback;
|
|
114
|
+
/**
|
|
115
|
+
* An array with *exactly* N elements in it.
|
|
116
|
+
*
|
|
117
|
+
* Only literal N values are supported. For very large N the type might result
|
|
118
|
+
* in a recurse depth error. For negative N the type would result in an infinite
|
|
119
|
+
* recursion. None of these have protections because this is an internal type!
|
|
120
|
+
*/
|
|
121
|
+
type NTuple<T, N extends number, Result extends Array<unknown> = []> = Result['length'] extends N ? Result : NTuple<T, N, [...Result, T]>;
|
|
122
|
+
/**
|
|
123
|
+
* Takes an array and returns the types that make up it's parts. The suffix is
|
|
124
|
+
* anything before the rest parameter (if any), the prefix is anything after the
|
|
125
|
+
* rest parameter (if any), and the item is the type of the rest parameter.
|
|
126
|
+
*
|
|
127
|
+
* The output could be used to reconstruct the input: `[
|
|
128
|
+
* ...TupleParts<T>["prefix"],
|
|
129
|
+
* ...Array<TupleParts<T>["item"]>,
|
|
130
|
+
* ...TupleParts<T>["suffix"],
|
|
131
|
+
* ]`.
|
|
132
|
+
*/
|
|
133
|
+
type TupleParts<T, Prefix extends Array<unknown> = [], Suffix extends Array<unknown> = []> = T extends readonly [infer Head, ...infer Tail] ? TupleParts<Tail, [...Prefix, Head], Suffix> : T extends readonly [...infer Head, infer Tail] ? TupleParts<Head, Prefix, [Tail, ...Suffix]> : T extends ReadonlyArray<infer Item> ? {
|
|
134
|
+
prefix: Prefix;
|
|
135
|
+
item: Item;
|
|
136
|
+
suffix: Suffix;
|
|
137
|
+
} : never;
|
|
138
|
+
/**
|
|
139
|
+
* `never[]` and `[]` are not the same type, and in some cases they aren't
|
|
140
|
+
* interchangeable.
|
|
141
|
+
*
|
|
142
|
+
* This type makes it easier to use the result of TupleParts when the input is a
|
|
143
|
+
* fixed-length tuple but we still want to spread the rest of the array. e.g.
|
|
144
|
+
* `[...CoercedArray<TupleParts<T>["item"]>, ...TupleParts<T>["suffix"]]`.
|
|
145
|
+
*
|
|
146
|
+
*/
|
|
147
|
+
type CoercedArray<T> = IfNever<T, [], Array<T>>;
|
|
148
|
+
/**
|
|
149
|
+
* The result of running a function that would dedupe an array (`unique`,
|
|
150
|
+
* `uniqueBy`, and `uniqueWith`).
|
|
151
|
+
*
|
|
152
|
+
* There are certain traits of the output which are unique to a deduped array
|
|
153
|
+
* that allow us to create a better type; see comments inline.
|
|
154
|
+
*
|
|
155
|
+
* !Note: We can build better types for each of the unique functions
|
|
156
|
+
* _separately_ by taking advantage of _other_ characteristics that are unique
|
|
157
|
+
* to each one (e.g. in `unique` we know that each item that has a disjoint type
|
|
158
|
+
* to all previous items would be part of the output, even when it isn't the
|
|
159
|
+
* first), but to make this utility the most useful we kept it simple and
|
|
160
|
+
* generic for now.
|
|
161
|
+
*/
|
|
162
|
+
type Deduped<T extends IterableContainer> = T extends readonly [] ? [
|
|
163
|
+
] : T extends readonly [infer Head, ...infer Rest] ? [
|
|
164
|
+
Head,
|
|
165
|
+
...Array<Rest[number]>
|
|
166
|
+
] : T extends readonly [...Array<unknown>, unknown] ? NonEmptyArray<T[number]> : Array<T[number]>;
|
|
114
167
|
|
|
115
|
-
export type { Branded as B, EnumerableStringKeyedValueOf as E, GuardType as G, IterableContainer as I, Mapped as M,
|
|
168
|
+
export type { Branded as B, CoercedArray as C, Deduped as D, EnumerableStringKeyedValueOf as E, GuardType as G, IterableContainer as I, Mapped as M, NTuple as N, ReconstructedRecord as R, TupleParts as T, UpsertProp as U, NonEmptyArray as a, EnumerableStringKeyOf as b, ExactRecord as c, NarrowedTo as d, IsUnion as e, IfBoundedRecord as f, ReorderedArray as g };
|
package/dist/unique-by.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMADDQNARcjs = require('./chunk-MADDQNAR.cjs');require('./chunk-NLX7PGPI.cjs');require('./chunk-I6VXEY44.cjs');require('./chunk-3X6SAJDQ.cjs');exports.uniqueBy = _chunkMADDQNARcjs.a;
|