@vinicunca/perkakas 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array-required-prefix-BW08fIbb.d.cts +35 -0
- package/dist/array-required-prefix-a3sgCkd2.d.ts +35 -0
- package/dist/bounded-partial-CJjczH6j.d.ts +14 -0
- package/dist/bounded-partial-wqR8ceNQ.d.cts +14 -0
- package/dist/{chunk-AJQEGHF5.cjs → chunk-22AQJBPW.cjs} +1 -1
- package/dist/chunk-2HQM73IT.cjs +1 -0
- package/dist/chunk-2XGSSTCA.js +1 -0
- package/dist/{chunk-6ENW2VLC.cjs → chunk-3LC3CLYE.cjs} +1 -1
- package/dist/chunk-44LUF6RO.js +1 -0
- package/dist/{chunk-IXGOK22A.cjs → chunk-5NW4GR2Q.cjs} +1 -1
- package/dist/chunk-5PMGMODH.js +1 -0
- package/dist/{chunk-GVYLRJPB.cjs → chunk-66JP4PUG.cjs} +1 -1
- package/dist/{chunk-6XVLHSPK.js → chunk-673TXH2U.js} +1 -1
- package/dist/chunk-6M4IYQFZ.js +1 -0
- package/dist/chunk-B6SBIS6W.js +1 -0
- package/dist/{chunk-OL2TQDYM.cjs → chunk-BDBX4ZMW.cjs} +1 -1
- package/dist/chunk-BEMQAYI5.cjs +1 -0
- package/dist/chunk-CTGIT5TY.js +1 -0
- package/dist/chunk-FGMSPUSF.cjs +1 -0
- package/dist/{chunk-Z46FX2Y4.js → chunk-FP3LV577.js} +1 -1
- package/dist/{chunk-22IDCBFS.js → chunk-GFXNX2W7.js} +1 -1
- package/dist/chunk-GW4KDK3D.cjs +1 -0
- package/dist/chunk-GWXILWA5.cjs +1 -0
- package/dist/chunk-HSNPZS6R.cjs +1 -0
- package/dist/chunk-ITDJLXHO.js +1 -0
- package/dist/{chunk-QQMFHVPX.cjs → chunk-J3ZXNDMT.cjs} +1 -1
- package/dist/{chunk-FLQYTU5W.cjs → chunk-JHFSYEXB.cjs} +1 -1
- package/dist/{chunk-WCPENZWH.js → chunk-JI5FJX2E.js} +1 -1
- package/dist/chunk-K26HQR4Y.cjs +1 -0
- package/dist/chunk-KYMVIFAW.cjs +1 -0
- package/dist/{chunk-ZQXE6PIV.cjs → chunk-NVCXF5UR.cjs} +1 -1
- package/dist/chunk-O74TUGYF.js +1 -0
- package/dist/{chunk-MHEODCN3.cjs → chunk-OMHZCALN.cjs} +1 -1
- package/dist/chunk-QFJ3I53F.js +0 -0
- package/dist/chunk-R4O7XE2F.cjs +1 -0
- package/dist/chunk-TVMG2NYC.js +1 -0
- package/dist/chunk-UWMBE6BM.js +1 -0
- package/dist/{chunk-VBH6SKKO.js → chunk-VI2QG3FU.js} +1 -1
- package/dist/chunk-YCSQX2SY.js +1 -0
- package/dist/chunk-ZITGCTSW.js +1 -0
- package/dist/chunk.cjs +1 -1
- package/dist/chunk.d.cts +33 -22
- package/dist/chunk.d.ts +33 -22
- package/dist/chunk.js +1 -1
- package/dist/clamped-integer-subtract-DZ7rsJE4.d.cts +15 -0
- package/dist/clamped-integer-subtract-DZ7rsJE4.d.ts +15 -0
- package/dist/coerced-array-DRz3tqda.d.cts +14 -0
- package/dist/coerced-array-DRz3tqda.d.ts +14 -0
- package/dist/count-by.cjs +1 -1
- package/dist/count-by.d.cts +3 -3
- package/dist/count-by.d.ts +3 -3
- package/dist/count-by.js +1 -1
- package/dist/drop-first-by.cjs +1 -1
- package/dist/drop-first-by.js +1 -1
- package/dist/drop.cjs +1 -1
- package/dist/drop.d.cts +17 -30
- package/dist/drop.d.ts +17 -30
- package/dist/drop.js +1 -1
- package/dist/filter.cjs +1 -1
- package/dist/filter.d.cts +12 -4
- package/dist/filter.d.ts +12 -4
- package/dist/filter.js +1 -1
- package/dist/filtered-array-BNHX1Nwj.d.ts +18 -0
- package/dist/filtered-array-DX6NNaBq.d.cts +18 -0
- package/dist/first-by.cjs +1 -1
- package/dist/first-by.js +1 -1
- package/dist/from-keys.cjs +1 -1
- package/dist/from-keys.d.cts +2 -2
- package/dist/from-keys.d.ts +2 -2
- package/dist/from-keys.js +1 -1
- package/dist/funnel.reference-batch.test.cjs +1 -1
- package/dist/funnel.reference-batch.test.js +1 -1
- package/dist/group-by-prop.cjs +1 -0
- package/dist/group-by-prop.d.cts +91 -0
- package/dist/group-by-prop.d.ts +91 -0
- package/dist/group-by-prop.js +1 -0
- package/dist/group-by.cjs +1 -1
- package/dist/group-by.d.cts +13 -3
- package/dist/group-by.d.ts +13 -3
- package/dist/group-by.js +1 -1
- package/dist/has-at-least.cjs +1 -1
- package/dist/has-at-least.d.cts +6 -15
- package/dist/has-at-least.d.ts +6 -15
- package/dist/has-at-least.js +1 -1
- package/dist/index-by.cjs +1 -1
- package/dist/index-by.d.cts +3 -3
- package/dist/index-by.d.ts +3 -3
- package/dist/index-by.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +1 -1
- package/dist/map-keys.cjs +1 -1
- package/dist/map-keys.d.cts +4 -4
- package/dist/map-keys.d.ts +4 -4
- package/dist/map-keys.js +1 -1
- package/dist/merge-all.d.cts +1 -1
- package/dist/merge-all.d.ts +1 -1
- package/dist/omit.cjs +1 -1
- package/dist/omit.js +1 -1
- package/dist/partial-array-Vnf1fBtl.d.cts +10 -0
- package/dist/partial-array-Vnf1fBtl.d.ts +10 -0
- package/dist/pull-object.cjs +1 -1
- package/dist/pull-object.d.cts +3 -3
- package/dist/pull-object.d.ts +3 -3
- package/dist/pull-object.js +1 -1
- package/dist/sort-by.d.cts +1 -1
- package/dist/sort-by.d.ts +1 -1
- package/dist/take-first-by.cjs +1 -1
- package/dist/take-first-by.js +1 -1
- package/dist/take-last-while.cjs +1 -1
- package/dist/take-last-while.d.cts +2 -0
- package/dist/take-last-while.d.ts +2 -0
- package/dist/take-last-while.js +1 -1
- package/dist/take-while.d.cts +2 -0
- package/dist/take-while.d.ts +2 -0
- package/dist/tuple-parts-CrwnkDKX.d.ts +100 -0
- package/dist/tuple-parts-DAqFAJP8.d.cts +100 -0
- package/dist/type.helpers.cjs +1 -0
- package/dist/type.helpers.d.cts +10 -0
- package/dist/type.helpers.d.ts +10 -0
- package/dist/type.helpers.js +1 -0
- package/package.json +1 -1
- package/dist/chunk-2MU3SHCO.js +0 -1
- package/dist/chunk-3CFBQYOQ.js +0 -1
- package/dist/chunk-5VXKW6SI.cjs +0 -1
- package/dist/chunk-APUBIDDU.cjs +0 -1
- package/dist/chunk-B5QDOWVQ.cjs +0 -1
- package/dist/chunk-B7RHAPUE.js +0 -1
- package/dist/chunk-BOOMUHPG.js +0 -1
- package/dist/chunk-DLXKXNZT.js +0 -1
- package/dist/chunk-I7K3Z4BT.js +0 -1
- package/dist/chunk-IJ4I5A3K.js +0 -1
- package/dist/chunk-L4ITKDYB.cjs +0 -1
- package/dist/chunk-OEJ5J23C.js +0 -1
- package/dist/chunk-PIF5X7RQ.cjs +0 -1
- package/dist/chunk-PWHX2554.js +0 -1
- package/dist/chunk-THE6MSJO.cjs +0 -1
- package/dist/chunk-UUYCL4G2.js +0 -1
- package/dist/chunk-XLGD5ZUY.cjs +0 -1
- package/dist/chunk-YCM6N46T.js +0 -1
- package/dist/exact-record-Dhbe_K-E.d.ts +0 -5
- package/dist/exact-record-_isi2JMR.d.cts +0 -5
- package/dist/n-tuple-5jljrt4c.d.cts +0 -10
- package/dist/n-tuple-5jljrt4c.d.ts +0 -10
- package/dist/take-last-while.spec-d-.cjs +0 -1
- package/dist/take-last-while.spec-d-.d.cts +0 -2
- package/dist/take-last-while.spec-d-.d.ts +0 -2
- package/dist/take-last-while.spec-d-.js +0 -1
- package/dist/tuple-parts-CP0H7BrE.d.cts +0 -37
- package/dist/tuple-parts-CP0H7BrE.d.ts +0 -37
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IsLiteral, And, GreaterThan, IsNever, IsEqual, ReadonlyTuple } from 'type-fest';
|
|
2
|
+
import { C as ClampedIntegerSubtract } from './clamped-integer-subtract-DZ7rsJE4.cjs';
|
|
3
|
+
import { C as CoercedArray } from './coerced-array-DRz3tqda.cjs';
|
|
4
|
+
import { I as IterableContainer } from './iterable-container-BTpDVdNc.cjs';
|
|
5
|
+
import { T as TupleParts, P as PerkakasTypeError } from './tuple-parts-DAqFAJP8.cjs';
|
|
6
|
+
|
|
7
|
+
type ArrayRequiredPrefix<T extends IterableContainer, N extends number> = IsLiteral<N> extends true ? T extends unknown ? ClampedIntegerSubtract<N, [
|
|
8
|
+
...TupleParts<T>['required'],
|
|
9
|
+
...TupleParts<T>['suffix']
|
|
10
|
+
]['length']> extends infer Remainder extends number ? Remainder extends 0 ? T : And<GreaterThan<Remainder, TupleParts<T>['optional']['length']>, IsNever<TupleParts<T>['item']>> extends true ? PerkakasTypeError<'ArrayRequiredPrefix', 'The input tuple cannot satisfy the minimum', {
|
|
11
|
+
type: never;
|
|
12
|
+
metadata: [T, N];
|
|
13
|
+
}> : WithSameReadonly<T, [
|
|
14
|
+
...TupleParts<T>['required'],
|
|
15
|
+
...OptionalTupleRequiredPrefix<TupleParts<T>['optional'], Remainder>,
|
|
16
|
+
...ReadonlyTuple<TupleParts<T>['item'], ClampedIntegerSubtract<Remainder, TupleParts<T>['optional']['length']>>,
|
|
17
|
+
...CoercedArray<TupleParts<T>['item']>,
|
|
18
|
+
...TupleParts<T>['suffix']
|
|
19
|
+
]> : PerkakasTypeError<'ArrayRequiredPrefix', 'Remainder didn\'t compute to a number?!', {
|
|
20
|
+
type: never;
|
|
21
|
+
metadata: [T, N];
|
|
22
|
+
}> : PerkakasTypeError<'ArrayRequiredPrefix', 'Failed to distribute union?!', {
|
|
23
|
+
type: never;
|
|
24
|
+
metadata: T;
|
|
25
|
+
}> : PerkakasTypeError<'ArrayRequiredPrefix', 'Only literal minimums are supported!', {
|
|
26
|
+
type: never;
|
|
27
|
+
metadata: N;
|
|
28
|
+
}>;
|
|
29
|
+
type WithSameReadonly<Source, Destination> = IsEqual<Source, Readonly<Source>> extends true ? Readonly<Destination> : Destination;
|
|
30
|
+
type OptionalTupleRequiredPrefix<T extends Array<unknown>, N, Prefix extends Array<unknown> = []> = Prefix['length'] extends N ? [
|
|
31
|
+
...Prefix,
|
|
32
|
+
...Partial<T>
|
|
33
|
+
] : T extends readonly [infer Head, ...infer Rest] ? OptionalTupleRequiredPrefix<Rest, N, [...Prefix, Head]> : Prefix;
|
|
34
|
+
|
|
35
|
+
export type { ArrayRequiredPrefix as A };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IsLiteral, And, GreaterThan, IsNever, IsEqual, ReadonlyTuple } from 'type-fest';
|
|
2
|
+
import { C as ClampedIntegerSubtract } from './clamped-integer-subtract-DZ7rsJE4.js';
|
|
3
|
+
import { C as CoercedArray } from './coerced-array-DRz3tqda.js';
|
|
4
|
+
import { I as IterableContainer } from './iterable-container-BTpDVdNc.js';
|
|
5
|
+
import { T as TupleParts, P as PerkakasTypeError } from './tuple-parts-CrwnkDKX.js';
|
|
6
|
+
|
|
7
|
+
type ArrayRequiredPrefix<T extends IterableContainer, N extends number> = IsLiteral<N> extends true ? T extends unknown ? ClampedIntegerSubtract<N, [
|
|
8
|
+
...TupleParts<T>['required'],
|
|
9
|
+
...TupleParts<T>['suffix']
|
|
10
|
+
]['length']> extends infer Remainder extends number ? Remainder extends 0 ? T : And<GreaterThan<Remainder, TupleParts<T>['optional']['length']>, IsNever<TupleParts<T>['item']>> extends true ? PerkakasTypeError<'ArrayRequiredPrefix', 'The input tuple cannot satisfy the minimum', {
|
|
11
|
+
type: never;
|
|
12
|
+
metadata: [T, N];
|
|
13
|
+
}> : WithSameReadonly<T, [
|
|
14
|
+
...TupleParts<T>['required'],
|
|
15
|
+
...OptionalTupleRequiredPrefix<TupleParts<T>['optional'], Remainder>,
|
|
16
|
+
...ReadonlyTuple<TupleParts<T>['item'], ClampedIntegerSubtract<Remainder, TupleParts<T>['optional']['length']>>,
|
|
17
|
+
...CoercedArray<TupleParts<T>['item']>,
|
|
18
|
+
...TupleParts<T>['suffix']
|
|
19
|
+
]> : PerkakasTypeError<'ArrayRequiredPrefix', 'Remainder didn\'t compute to a number?!', {
|
|
20
|
+
type: never;
|
|
21
|
+
metadata: [T, N];
|
|
22
|
+
}> : PerkakasTypeError<'ArrayRequiredPrefix', 'Failed to distribute union?!', {
|
|
23
|
+
type: never;
|
|
24
|
+
metadata: T;
|
|
25
|
+
}> : PerkakasTypeError<'ArrayRequiredPrefix', 'Only literal minimums are supported!', {
|
|
26
|
+
type: never;
|
|
27
|
+
metadata: N;
|
|
28
|
+
}>;
|
|
29
|
+
type WithSameReadonly<Source, Destination> = IsEqual<Source, Readonly<Source>> extends true ? Readonly<Destination> : Destination;
|
|
30
|
+
type OptionalTupleRequiredPrefix<T extends Array<unknown>, N, Prefix extends Array<unknown> = []> = Prefix['length'] extends N ? [
|
|
31
|
+
...Prefix,
|
|
32
|
+
...Partial<T>
|
|
33
|
+
] : T extends readonly [infer Head, ...infer Rest] ? OptionalTupleRequiredPrefix<Rest, N, [...Prefix, Head]> : Prefix;
|
|
34
|
+
|
|
35
|
+
export type { ArrayRequiredPrefix as A };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { I as IfBoundedRecord } from './if-bounded-record-Drd4UbBU.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Records with an unbounded set of keys have different semantics to those with
|
|
5
|
+
* a bounded set of keys when using 'noUncheckedIndexedAccess', the former
|
|
6
|
+
* being implicitly `Partial` whereas the latter are implicitly `Required`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* BoundedPartial<{ a: number }>; //=> { a?: number }
|
|
10
|
+
* BoundedPartial<Record<string, number>>; //=> Record<string, number>
|
|
11
|
+
*/
|
|
12
|
+
type BoundedPartial<T> = IfBoundedRecord<T, Partial<T>, T>;
|
|
13
|
+
|
|
14
|
+
export type { BoundedPartial as B };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { I as IfBoundedRecord } from './if-bounded-record-Drd4UbBU.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Records with an unbounded set of keys have different semantics to those with
|
|
5
|
+
* a bounded set of keys when using 'noUncheckedIndexedAccess', the former
|
|
6
|
+
* being implicitly `Partial` whereas the latter are implicitly `Required`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* BoundedPartial<{ a: number }>; //=> { a?: number }
|
|
10
|
+
* BoundedPartial<Record<string, number>>; //=> Record<string, number>
|
|
11
|
+
*/
|
|
12
|
+
type BoundedPartial<T> = IfBoundedRecord<T, Partial<T>, T>;
|
|
13
|
+
|
|
14
|
+
export type { BoundedPartial as B };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function c(...e){return _chunkXR72I63Wcjs.a.call(void 0, y,e)}function y(e,
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function c(...e){return _chunkXR72I63Wcjs.a.call(void 0, y,e)}function y(e,a){let n=new Map;for(let[d,u]of e.entries()){let r=a(u,d,e);if(r!==void 0){let t=n.get(r);t===void 0?n.set(r,1):n.set(r,t+1)}}return Object.fromEntries(n)}exports.a = c;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function o(...e){return _chunkXR72I63Wcjs.a.call(void 0, s,e)}function s(e,n){if(n<1)throw new RangeError(`chunk: A chunk size of '${n}' would result in an infinite array`);if(e.length===0)return[];if(n>=e.length)return[[...e]];let a=Math.ceil(e.length/n),u=new Array(a);if(n===1)for(let[r,t]of e.entries())u[r]=[t];else for(let r=0;r<a;r+=1){let t=r*n;u[r]=e.slice(t,t+n)}return u}exports.a = o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-J6WPJH72.js";function u(...e){return t(i,e)}function i(e,a){let r={};for(let[o,n]of e.entries()){let d=a(n,o,e);r[d]=n}return r}export{u as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkN5JE6642cjs = require('./chunk-N5JE6642.cjs');var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkN5JE6642cjs = require('./chunk-N5JE6642.cjs');var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function m(...e){return _chunkXR72I63Wcjs.a.call(void 0, o,e,i)}function o(e,n){return e.filter(n)}function i(e){return(n,a,d)=>e(n,a,d)?{done:!1,hasNext:!0,next:n}:_chunkN5JE6642cjs.a}exports.a = m;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-J6WPJH72.js";function i(...e){return a(u,e)}function u(e,d){let r=Object.create(null);for(let n=0;n<e.length;n++){let t=e[n],y=d(t,n,e);if(y!==void 0){let o=r[y];o===void 0?r[y]=[t]:o.push(t)}}return Object.setPrototypeOf(r,Object.prototype),r}export{i as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJHFSYEXBcjs = require('./chunk-JHFSYEXB.cjs');var _chunkEROXO3T4cjs = require('./chunk-EROXO3T4.cjs');function s(...r){return _chunkEROXO3T4cjs.b.call(void 0, p,r)}function p(r,t,e){if(e<=0)return[];if(e>=r.length)return[...r];let n=r.slice(0,e);_chunkJHFSYEXBcjs.a.call(void 0, n,t);let i=r.slice(e);for(let u of i)_chunkJHFSYEXBcjs.b.call(void 0, n,t,u);return n}exports.a = s;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-J6WPJH72.js";function d(...e){return t(y,e)}function y(e,a){let n={};for(let[o,r]of Object.entries(e)){let u=a(o,r,e);n[u]=r}return n}export{d as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function i(...e){return _chunkXR72I63Wcjs.a.call(void 0,
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function i(...e){return _chunkXR72I63Wcjs.a.call(void 0, n,e)}function n(e,r){return e.length>=r}exports.a = i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as y,b as a}from"./chunk-
|
|
1
|
+
import{a as y,b as a}from"./chunk-JI5FJX2E.js";import{b as o}from"./chunk-7KBK2RWQ.js";function s(...r){return o(p,r)}function p(r,t,e){if(e<=0)return[];if(e>=r.length)return[...r];let n=r.slice(0,e);y(n,t);let i=r.slice(e);for(let u of i)a(n,t,u);return n}export{s as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p}from"./chunk-J6WPJH72.js";function y(...r){return p(s,r)}function s(r,a){let e=Object.create(null);for(let t of r){let o=t?.[a];if(o!==void 0){let n=e[o];n===void 0?e[o]=[t]:n.push(t)}}return Object.setPrototypeOf(e,Object.prototype),e}export{y as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-J6WPJH72.js";function b(...e){return a(l,e)}function l(e,o,i){let t={};for(let[r,n]of e.entries()){let u=o(n,r,e),d=i(n,r,e);t[u]=d}return t}export{b as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkJHFSYEXBcjs = require('./chunk-JHFSYEXB.cjs');var _chunkEROXO3T4cjs = require('./chunk-EROXO3T4.cjs');function d(...r){return _chunkEROXO3T4cjs.b.call(void 0, s,r)}function s(r,n,e){if(e>=r.length)return[];if(e<=0)return[...r];let o=r.slice(0,e);_chunkJHFSYEXBcjs.a.call(void 0, o,n);let t=[],i=r.slice(e);for(let y of i){let m=_chunkJHFSYEXBcjs.b.call(void 0, o,n,y);t.push(_nullishCoalesce(m, () => (y)))}return t}exports.a = d;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function m(...e){return _chunkXR72I63Wcjs.a.call(void 0, y,e)}function y(e,o){let r={};for(let[a,n]of e.entries())r[n]=o(n,a,e);return r}exports.a = m;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./chunk-J6WPJH72.js";function c(...e){return o(y,e)}function y(e,a){let n=new Map;for(let[d,u]of e.entries()){let r=a(u,d,e);if(r!==void 0){let t=n.get(r);t===void 0?n.set(r,1):n.set(r,t+1)}}return Object.fromEntries(n)}export{c as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function b(...e){return _chunkXR72I63Wcjs.a.call(void 0, l,e)}function l(e,o,i){let t={};for(let[r,n]of e.entries()){let u=o(n,r,e),d=i(n,r,e);t[u]=d}return t}exports.a = b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t}from"./chunk-7KBK2RWQ.js";import{a as o}from"./chunk-
|
|
1
|
+
import{a as t}from"./chunk-7KBK2RWQ.js";import{a as o}from"./chunk-ITDJLXHO.js";function p(...n){return t(a,n)}function a(n,y){if(!o(n,2))return n[0];let[e]=n,[,...i]=n;for(let r of i)y(r,e)<0&&(e=r);return e}export{p as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as u,b as a}from"./chunk-
|
|
1
|
+
import{a as u,b as a}from"./chunk-JI5FJX2E.js";import{b as p}from"./chunk-7KBK2RWQ.js";function d(...r){return p(s,r)}function s(r,n,e){if(e>=r.length)return[];if(e<=0)return[...r];let o=r.slice(0,e);u(o,n);let t=[],i=r.slice(e);for(let y of i){let m=a(o,n,y);t.push(m??y)}return t}export{d as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function i(...e){return _chunkXR72I63Wcjs.a.call(void 0, u,e)}function u(e,d){let r=Object.create(null);for(let n=0;n<e.length;n++){let t=e[n],y=d(t,n,e);if(y!==void 0){let o=r[y];o===void 0?r[y]=[t]:o.push(t)}}return Object.setPrototypeOf(r,Object.prototype),r}exports.a = i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function y(...r){return _chunkXR72I63Wcjs.a.call(void 0, s,r)}function s(r,a){let e=Object.create(null);for(let t of r){let o=_optionalChain([t, 'optionalAccess', _ => _[a]]);if(o!==void 0){let n=e[o];n===void 0?e[o]=[t]:n.push(t)}}return Object.setPrototypeOf(e,Object.prototype),e}exports.a = y;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-J6WPJH72.js";function i(...e){return t(n,e)}function n(e,r){return e.length>=r}export{i as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEROXO3T4cjs = require('./chunk-EROXO3T4.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEROXO3T4cjs = require('./chunk-EROXO3T4.cjs');var _chunk66JP4PUGcjs = require('./chunk-66JP4PUG.cjs');function p(...n){return _chunkEROXO3T4cjs.a.call(void 0, a,n)}function a(n,y){if(!_chunk66JP4PUGcjs.a.call(void 0, n,2))return n[0];let[e]=n,[,...i]=n;for(let r of i)y(r,e)<0&&(e=r);return e}exports.a = p;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZ6OOXW67cjs = require('./chunk-Z6OOXW67.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZ6OOXW67cjs = require('./chunk-Z6OOXW67.cjs');var _chunk66JP4PUGcjs = require('./chunk-66JP4PUG.cjs');function T(n,o){for(let r=Math.floor(n.length/2)-1;r>=0;r--)c(n,r,o)}function m(n,o,r){if(!_chunk66JP4PUGcjs.a.call(void 0, n,1))return;let[t]=n;if(!(o(r,t)>=0))return n[0]=r,c(n,0,o),t}function c(n,o,r){let t=o;for(;t*2+1<n.length;){let i=t*2+1,e=r(n[t],n[i])<0?i:t,f=i+1;if(f<n.length&&r(n[e],n[f])<0&&(e=f),e===t)return;_chunkZ6OOXW67cjs.a.call(void 0, n,t,e),t=e}}exports.a = T; exports.b = m;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d}from"./chunk-YYEJOSR3.js";import{a as u}from"./chunk-
|
|
1
|
+
import{a as d}from"./chunk-YYEJOSR3.js";import{a as u}from"./chunk-ITDJLXHO.js";function T(n,o){for(let r=Math.floor(n.length/2)-1;r>=0;r--)c(n,r,o)}function m(n,o,r){if(!u(n,1))return;let[t]=n;if(!(o(r,t)>=0))return n[0]=r,c(n,0,o),t}function c(n,o,r){let t=o;for(;t*2+1<n.length;){let i=t*2+1,e=r(n[t],n[i])<0?i:t,f=i+1;if(f<n.length&&r(n[e],n[f])<0&&(e=f),e===t)return;d(n,t,e),t=e}}export{T as a,m as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function u(...e){return _chunkXR72I63Wcjs.a.call(void 0, i,e)}function i(e,a){let r={};for(let[o,n]of e.entries()){let d=a(n,o,e);r[d]=n}return r}exports.a = u;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function d(...e){return _chunkXR72I63Wcjs.a.call(void 0, y,e)}function y(e,a){let n={};for(let[o,r]of Object.entries(e)){let u=a(o,r,e);n[u]=r}return n}exports.a = d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function o(...e){return _chunkXR72I63Wcjs.a.call(void 0, a,e)}function a(e,
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function o(...e){return _chunkXR72I63Wcjs.a.call(void 0, a,e)}function a(e,r){for(let n=e.length-1;n>=0;n--)if(!r(e[n],n,e))return e.slice(n+1);return[...e]}exports.a = o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-J6WPJH72.js";function o(...e){return t(a,e)}function a(e,r){for(let n=e.length-1;n>=0;n--)if(!r(e[n],n,e))return e.slice(n+1);return[...e]}export{o as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk66JP4PUGcjs = require('./chunk-66JP4PUG.cjs');var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function y(...t){return _chunkXR72I63Wcjs.a.call(void 0, f,t)}function f(t,e){if(!_chunk66JP4PUGcjs.a.call(void 0, e,1))return{...t};if(!_chunk66JP4PUGcjs.a.call(void 0, e,2)){let{[e[0]]:r,...m}=t;return m}let o={...t};for(let r of e)delete o[r];return o}exports.a = y;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkN5JE6642cjs = require('./chunk-N5JE6642.cjs');var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function s(...e){return _chunkXR72I63Wcjs.a.call(void 0, p,e,o)}function p(e,r){return r<0?[...e]:e.slice(r)}function o(e){if(e<=0)return _chunkN5JE6642cjs.c;let r=e;return i=>r>0?(r-=1,_chunkN5JE6642cjs.a):{done:!1,hasNext:!0,next:i}}exports.a = s;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-J6WPJH72.js";function m(...e){return t(y,e)}function y(e,o){let r={};for(let[a,n]of e.entries())r[n]=o(n,a,e);return r}export{m as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-J6WPJH72.js";function o(...e){return i(s,e)}function s(e,n){if(n<1)throw new RangeError(`chunk: A chunk size of '${n}' would result in an infinite array`);if(e.length===0)return[];if(n>=e.length)return[[...e]];let a=Math.ceil(e.length/n),u=new Array(a);if(n===1)for(let[r,t]of e.entries())u[r]=[t];else for(let r=0;r<a;r+=1){let t=r*n;u[r]=e.slice(t,t+n)}return u}export{o as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"./chunk-
|
|
1
|
+
import{a as n}from"./chunk-ITDJLXHO.js";import{a as i}from"./chunk-J6WPJH72.js";function y(...t){return i(f,t)}function f(t,e){if(!n(e,1))return{...t};if(!n(e,2)){let{[e[0]]:r,...m}=t;return m}let o={...t};for(let r of e)delete o[r];return o}export{y as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n,c as a}from"./chunk-EPU4K3DD.js";import{a as t}from"./chunk-J6WPJH72.js";function s(...e){return t(p,e,o)}function p(e,r){return r<0?[...e]:e.slice(r)}function o(e){if(e<=0)return a;let r=e;return i=>r>0?(r-=1,n):{done:!1,hasNext:!0,next:i}}export{s as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-EPU4K3DD.js";import{a as t}from"./chunk-J6WPJH72.js";function m(...e){return t(o,e,i)}function o(e,n){return e.filter(n)}function i(e){return(n,a,d)=>e(n,a,d)?{done:!1,hasNext:!0,next:n}:r}export{m as a};
|
package/dist/chunk.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk2HQM73ITcjs = require('./chunk-2HQM73IT.cjs');require('./chunk-XR72I63W.cjs');require('./chunk-GZJMERDJ.cjs');exports.chunk = _chunk2HQM73ITcjs.a;
|
package/dist/chunk.d.cts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { IsNumericLiteral, LessThan, IfNever,
|
|
1
|
+
import { IsNumericLiteral, LessThan, IfNever, ValueOf, Subtract, IntRange } from 'type-fest';
|
|
2
2
|
import { I as IntRangeInclusive } from './int-range-inclusive-Cn-qsrAN.cjs';
|
|
3
3
|
import { I as IterableContainer } from './iterable-container-BTpDVdNc.cjs';
|
|
4
|
-
import { N as NTuple } from './n-tuple-5jljrt4c.cjs';
|
|
5
4
|
import { N as NonEmptyArray } from './non-empty-array-C9Od1wmF.cjs';
|
|
6
|
-
import {
|
|
5
|
+
import { P as PartialArray } from './partial-array-Vnf1fBtl.cjs';
|
|
6
|
+
import { T as TupleParts } from './tuple-parts-DAqFAJP8.cjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* An array with *exactly* N elements in it.
|
|
10
|
+
*
|
|
11
|
+
* Only literal N values are supported. For very large N the type might result
|
|
12
|
+
* in a recurse depth error. For negative N the type would result in an infinite
|
|
13
|
+
* recursion. None of these have protections because this is an internal type!
|
|
14
|
+
*/
|
|
15
|
+
type NTuple<T, N extends number, Result extends Array<unknown> = []> = Result['length'] extends N ? Result : NTuple<T, N, [...Result, T]>;
|
|
7
16
|
|
|
8
17
|
/**
|
|
9
18
|
* This prevents typescript from failing on complex arrays and large chunks.
|
|
@@ -17,14 +26,12 @@ type MAX_LITERAL_SIZE = 350;
|
|
|
17
26
|
type Chunk<T extends IterableContainer, N extends number> = T extends readonly [] ? [] : IsNumericLiteral<N> extends true ? LessThan<N, 1> extends true ? never : LessThan<N, MAX_LITERAL_SIZE> extends true ? [
|
|
18
27
|
...LiteralChunk<T, N>
|
|
19
28
|
] : GenericChunk<T> : GenericChunk<T>;
|
|
20
|
-
type LiteralChunk<T, N extends number
|
|
29
|
+
type LiteralChunk<T extends IterableContainer, N extends number> = ChunkRestElement<ChunkFixedTuple<TuplePrefix<T>, N>, TupleParts<T>['item'], TupleParts<T>['suffix'], N> | ([...TuplePrefix<T>, ...TupleParts<T>['suffix']] extends readonly [] ? [] : never);
|
|
21
30
|
/**
|
|
22
|
-
* This type **only** works if the input array `T` is a
|
|
23
|
-
*
|
|
24
|
-
* parameter). For these inputs the chunked output could be computed as literal
|
|
25
|
-
* finite tuples too.
|
|
31
|
+
* This type **only** works if the input array `T` is a fixed tuple. For these
|
|
32
|
+
* inputs the chunked output could be computed as literal finite tuples too.
|
|
26
33
|
*/
|
|
27
|
-
type
|
|
34
|
+
type ChunkFixedTuple<T, N extends number, Result = []> = T extends readonly [infer Head, ...infer Rest] ? ChunkFixedTuple<Rest, N, Result extends [
|
|
28
35
|
...infer Previous extends Array<Array<unknown>>,
|
|
29
36
|
infer Current extends Array<unknown>
|
|
30
37
|
] ? Current['length'] extends N ? [
|
|
@@ -43,27 +50,27 @@ type ChunkFinite<T, N extends number, Result = []> = T extends readonly [infer H
|
|
|
43
50
|
* creates all possible combinations of adding items to the prefix and suffix
|
|
44
51
|
* for all possible scenarios for how many items the rest param "represents".
|
|
45
52
|
*/
|
|
46
|
-
type
|
|
53
|
+
type ChunkRestElement<PrefixChunks, Item, Suffix extends Array<unknown>, N extends number> = IfNever<Item, PrefixChunks, PrefixChunks extends [
|
|
47
54
|
...infer PrefixFullChunks extends Array<Array<unknown>>,
|
|
48
55
|
infer LastPrefixChunk extends Array<unknown>
|
|
49
|
-
] ?
|
|
50
|
-
...PrefixFullChunks,
|
|
51
|
-
[
|
|
52
|
-
...LastPrefixChunk,
|
|
53
|
-
...NTuple<Item, Subtract<N, LastPrefixChunk['length']>>
|
|
54
|
-
],
|
|
55
|
-
...Array<NTuple<Item, N>>,
|
|
56
|
-
...SuffixChunk<Suffix, Item, N>
|
|
57
|
-
] | ValueOf<{
|
|
56
|
+
] ? ValueOf<{
|
|
58
57
|
[Padding in IntRangeInclusive<0, Subtract<N, LastPrefixChunk['length']>>]: [
|
|
59
58
|
...PrefixFullChunks,
|
|
60
|
-
...
|
|
59
|
+
...ChunkFixedTuple<[
|
|
61
60
|
...LastPrefixChunk,
|
|
62
61
|
...NTuple<Item, Padding>,
|
|
63
62
|
...Suffix
|
|
64
63
|
], N>
|
|
65
64
|
];
|
|
66
|
-
}>
|
|
65
|
+
}> | [
|
|
66
|
+
...PrefixFullChunks,
|
|
67
|
+
[
|
|
68
|
+
...LastPrefixChunk,
|
|
69
|
+
...NTuple<Item, Subtract<N, LastPrefixChunk['length']>>
|
|
70
|
+
],
|
|
71
|
+
...Array<NTuple<Item, N>>,
|
|
72
|
+
...SuffixChunk<Suffix, Item, N>
|
|
73
|
+
] : [
|
|
67
74
|
...Array<NTuple<Item, N>>,
|
|
68
75
|
...SuffixChunk<Suffix, Item, N>
|
|
69
76
|
]>;
|
|
@@ -78,7 +85,7 @@ type SuffixChunk<T extends Array<unknown>, Item, N extends number> = T extends r
|
|
|
78
85
|
[K in IntRangeInclusive<1, N>]: NTuple<Item, K>;
|
|
79
86
|
}>
|
|
80
87
|
] : ValueOf<{
|
|
81
|
-
[Padding in IntRange<0, N>]:
|
|
88
|
+
[Padding in IntRange<0, N>]: ChunkFixedTuple<[
|
|
82
89
|
...NTuple<Item, Padding>,
|
|
83
90
|
...T
|
|
84
91
|
], N>;
|
|
@@ -88,6 +95,10 @@ type SuffixChunk<T extends Array<unknown>, Item, N extends number> = T extends r
|
|
|
88
95
|
* our output based on if we know for sure that the array is empty or not.
|
|
89
96
|
*/
|
|
90
97
|
type GenericChunk<T extends IterableContainer> = T extends readonly [...Array<unknown>, unknown] | readonly [unknown, ...Array<unknown>] ? NonEmptyArray<NonEmptyArray<T[number]>> : Array<NonEmptyArray<T[number]>>;
|
|
98
|
+
type TuplePrefix<T extends IterableContainer> = [
|
|
99
|
+
...TupleParts<T>['required'],
|
|
100
|
+
...PartialArray<TupleParts<T>['optional']>
|
|
101
|
+
];
|
|
91
102
|
/**
|
|
92
103
|
* Split an array into groups the length of `size`. If `array` can't be split evenly, the final chunk will be the remaining elements.
|
|
93
104
|
*
|
package/dist/chunk.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { IsNumericLiteral, LessThan, IfNever,
|
|
1
|
+
import { IsNumericLiteral, LessThan, IfNever, ValueOf, Subtract, IntRange } from 'type-fest';
|
|
2
2
|
import { I as IntRangeInclusive } from './int-range-inclusive-Cn-qsrAN.js';
|
|
3
3
|
import { I as IterableContainer } from './iterable-container-BTpDVdNc.js';
|
|
4
|
-
import { N as NTuple } from './n-tuple-5jljrt4c.js';
|
|
5
4
|
import { N as NonEmptyArray } from './non-empty-array-C9Od1wmF.js';
|
|
6
|
-
import {
|
|
5
|
+
import { P as PartialArray } from './partial-array-Vnf1fBtl.js';
|
|
6
|
+
import { T as TupleParts } from './tuple-parts-CrwnkDKX.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* An array with *exactly* N elements in it.
|
|
10
|
+
*
|
|
11
|
+
* Only literal N values are supported. For very large N the type might result
|
|
12
|
+
* in a recurse depth error. For negative N the type would result in an infinite
|
|
13
|
+
* recursion. None of these have protections because this is an internal type!
|
|
14
|
+
*/
|
|
15
|
+
type NTuple<T, N extends number, Result extends Array<unknown> = []> = Result['length'] extends N ? Result : NTuple<T, N, [...Result, T]>;
|
|
7
16
|
|
|
8
17
|
/**
|
|
9
18
|
* This prevents typescript from failing on complex arrays and large chunks.
|
|
@@ -17,14 +26,12 @@ type MAX_LITERAL_SIZE = 350;
|
|
|
17
26
|
type Chunk<T extends IterableContainer, N extends number> = T extends readonly [] ? [] : IsNumericLiteral<N> extends true ? LessThan<N, 1> extends true ? never : LessThan<N, MAX_LITERAL_SIZE> extends true ? [
|
|
18
27
|
...LiteralChunk<T, N>
|
|
19
28
|
] : GenericChunk<T> : GenericChunk<T>;
|
|
20
|
-
type LiteralChunk<T, N extends number
|
|
29
|
+
type LiteralChunk<T extends IterableContainer, N extends number> = ChunkRestElement<ChunkFixedTuple<TuplePrefix<T>, N>, TupleParts<T>['item'], TupleParts<T>['suffix'], N> | ([...TuplePrefix<T>, ...TupleParts<T>['suffix']] extends readonly [] ? [] : never);
|
|
21
30
|
/**
|
|
22
|
-
* This type **only** works if the input array `T` is a
|
|
23
|
-
*
|
|
24
|
-
* parameter). For these inputs the chunked output could be computed as literal
|
|
25
|
-
* finite tuples too.
|
|
31
|
+
* This type **only** works if the input array `T` is a fixed tuple. For these
|
|
32
|
+
* inputs the chunked output could be computed as literal finite tuples too.
|
|
26
33
|
*/
|
|
27
|
-
type
|
|
34
|
+
type ChunkFixedTuple<T, N extends number, Result = []> = T extends readonly [infer Head, ...infer Rest] ? ChunkFixedTuple<Rest, N, Result extends [
|
|
28
35
|
...infer Previous extends Array<Array<unknown>>,
|
|
29
36
|
infer Current extends Array<unknown>
|
|
30
37
|
] ? Current['length'] extends N ? [
|
|
@@ -43,27 +50,27 @@ type ChunkFinite<T, N extends number, Result = []> = T extends readonly [infer H
|
|
|
43
50
|
* creates all possible combinations of adding items to the prefix and suffix
|
|
44
51
|
* for all possible scenarios for how many items the rest param "represents".
|
|
45
52
|
*/
|
|
46
|
-
type
|
|
53
|
+
type ChunkRestElement<PrefixChunks, Item, Suffix extends Array<unknown>, N extends number> = IfNever<Item, PrefixChunks, PrefixChunks extends [
|
|
47
54
|
...infer PrefixFullChunks extends Array<Array<unknown>>,
|
|
48
55
|
infer LastPrefixChunk extends Array<unknown>
|
|
49
|
-
] ?
|
|
50
|
-
...PrefixFullChunks,
|
|
51
|
-
[
|
|
52
|
-
...LastPrefixChunk,
|
|
53
|
-
...NTuple<Item, Subtract<N, LastPrefixChunk['length']>>
|
|
54
|
-
],
|
|
55
|
-
...Array<NTuple<Item, N>>,
|
|
56
|
-
...SuffixChunk<Suffix, Item, N>
|
|
57
|
-
] | ValueOf<{
|
|
56
|
+
] ? ValueOf<{
|
|
58
57
|
[Padding in IntRangeInclusive<0, Subtract<N, LastPrefixChunk['length']>>]: [
|
|
59
58
|
...PrefixFullChunks,
|
|
60
|
-
...
|
|
59
|
+
...ChunkFixedTuple<[
|
|
61
60
|
...LastPrefixChunk,
|
|
62
61
|
...NTuple<Item, Padding>,
|
|
63
62
|
...Suffix
|
|
64
63
|
], N>
|
|
65
64
|
];
|
|
66
|
-
}>
|
|
65
|
+
}> | [
|
|
66
|
+
...PrefixFullChunks,
|
|
67
|
+
[
|
|
68
|
+
...LastPrefixChunk,
|
|
69
|
+
...NTuple<Item, Subtract<N, LastPrefixChunk['length']>>
|
|
70
|
+
],
|
|
71
|
+
...Array<NTuple<Item, N>>,
|
|
72
|
+
...SuffixChunk<Suffix, Item, N>
|
|
73
|
+
] : [
|
|
67
74
|
...Array<NTuple<Item, N>>,
|
|
68
75
|
...SuffixChunk<Suffix, Item, N>
|
|
69
76
|
]>;
|
|
@@ -78,7 +85,7 @@ type SuffixChunk<T extends Array<unknown>, Item, N extends number> = T extends r
|
|
|
78
85
|
[K in IntRangeInclusive<1, N>]: NTuple<Item, K>;
|
|
79
86
|
}>
|
|
80
87
|
] : ValueOf<{
|
|
81
|
-
[Padding in IntRange<0, N>]:
|
|
88
|
+
[Padding in IntRange<0, N>]: ChunkFixedTuple<[
|
|
82
89
|
...NTuple<Item, Padding>,
|
|
83
90
|
...T
|
|
84
91
|
], N>;
|
|
@@ -88,6 +95,10 @@ type SuffixChunk<T extends Array<unknown>, Item, N extends number> = T extends r
|
|
|
88
95
|
* our output based on if we know for sure that the array is empty or not.
|
|
89
96
|
*/
|
|
90
97
|
type GenericChunk<T extends IterableContainer> = T extends readonly [...Array<unknown>, unknown] | readonly [unknown, ...Array<unknown>] ? NonEmptyArray<NonEmptyArray<T[number]>> : Array<NonEmptyArray<T[number]>>;
|
|
98
|
+
type TuplePrefix<T extends IterableContainer> = [
|
|
99
|
+
...TupleParts<T>['required'],
|
|
100
|
+
...PartialArray<TupleParts<T>['optional']>
|
|
101
|
+
];
|
|
91
102
|
/**
|
|
92
103
|
* Split an array into groups the length of `size`. If `array` can't be split evenly, the final chunk will be the remaining elements.
|
|
93
104
|
*
|
package/dist/chunk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-UWMBE6BM.js";import"./chunk-J6WPJH72.js";import"./chunk-KGPDVVVV.js";export{a as chunk};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We built our own version of Subtract instead of using type-fest's one
|
|
3
|
+
* because we needed a simpler implementation that isn't as prone to excessive
|
|
4
|
+
* recursion issues and that is clamped at 0 so that we don't need to handle
|
|
5
|
+
* negative values using even more utilities.
|
|
6
|
+
*/
|
|
7
|
+
type ClampedIntegerSubtract<Minuend, Subtrahend, SubtrahendBag extends Array<unknown> = [], ResultBag extends Array<unknown> = []> = [...SubtrahendBag, ...ResultBag]['length'] extends Minuend ? ResultBag['length'] : SubtrahendBag['length'] extends Subtrahend ? ClampedIntegerSubtract<Minuend, Subtrahend, SubtrahendBag, [
|
|
8
|
+
...ResultBag,
|
|
9
|
+
unknown
|
|
10
|
+
]> : ClampedIntegerSubtract<Minuend, Subtrahend, [
|
|
11
|
+
...SubtrahendBag,
|
|
12
|
+
unknown
|
|
13
|
+
], ResultBag>;
|
|
14
|
+
|
|
15
|
+
export type { ClampedIntegerSubtract as C };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We built our own version of Subtract instead of using type-fest's one
|
|
3
|
+
* because we needed a simpler implementation that isn't as prone to excessive
|
|
4
|
+
* recursion issues and that is clamped at 0 so that we don't need to handle
|
|
5
|
+
* negative values using even more utilities.
|
|
6
|
+
*/
|
|
7
|
+
type ClampedIntegerSubtract<Minuend, Subtrahend, SubtrahendBag extends Array<unknown> = [], ResultBag extends Array<unknown> = []> = [...SubtrahendBag, ...ResultBag]['length'] extends Minuend ? ResultBag['length'] : SubtrahendBag['length'] extends Subtrahend ? ClampedIntegerSubtract<Minuend, Subtrahend, SubtrahendBag, [
|
|
8
|
+
...ResultBag,
|
|
9
|
+
unknown
|
|
10
|
+
]> : ClampedIntegerSubtract<Minuend, Subtrahend, [
|
|
11
|
+
...SubtrahendBag,
|
|
12
|
+
unknown
|
|
13
|
+
], ResultBag>;
|
|
14
|
+
|
|
15
|
+
export type { ClampedIntegerSubtract as C };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IfNever } from 'type-fest';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `never[]` and `[]` are not the same type, and in some cases they aren't
|
|
5
|
+
* interchangeable.
|
|
6
|
+
*
|
|
7
|
+
* This type makes it easier to use the result of TupleParts when the input is a
|
|
8
|
+
* fixed-length tuple but we still want to spread the rest of the array. e.g.
|
|
9
|
+
* `[...CoercedArray<TupleParts<T>["item"]>, ...TupleParts<T>["suffix"]]`.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
type CoercedArray<T> = IfNever<T, [], Array<T>>;
|
|
13
|
+
|
|
14
|
+
export type { CoercedArray as C };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IfNever } from 'type-fest';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `never[]` and `[]` are not the same type, and in some cases they aren't
|
|
5
|
+
* interchangeable.
|
|
6
|
+
*
|
|
7
|
+
* This type makes it easier to use the result of TupleParts when the input is a
|
|
8
|
+
* fixed-length tuple but we still want to spread the rest of the array. e.g.
|
|
9
|
+
* `[...CoercedArray<TupleParts<T>["item"]>, ...TupleParts<T>["suffix"]]`.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
type CoercedArray<T> = IfNever<T, [], Array<T>>;
|
|
13
|
+
|
|
14
|
+
export type { CoercedArray as C };
|
package/dist/count-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 _chunk22AQJBPWcjs = require('./chunk-22AQJBPW.cjs');require('./chunk-XR72I63W.cjs');require('./chunk-GZJMERDJ.cjs');exports.countBy = _chunk22AQJBPWcjs.a;
|
package/dist/count-by.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as BoundedPartial } from './bounded-partial-wqR8ceNQ.cjs';
|
|
2
2
|
import './if-bounded-record-Drd4UbBU.cjs';
|
|
3
3
|
import 'type-fest';
|
|
4
4
|
|
|
@@ -19,7 +19,7 @@ import 'type-fest';
|
|
|
19
19
|
* @dataFirst
|
|
20
20
|
* @category Array
|
|
21
21
|
*/
|
|
22
|
-
declare function countBy<T, K extends PropertyKey>(data: ReadonlyArray<T>, categorizationFn: (value: T, index: number, data: ReadonlyArray<T>) => K | undefined):
|
|
22
|
+
declare function countBy<T, K extends PropertyKey>(data: ReadonlyArray<T>, categorizationFn: (value: T, index: number, data: ReadonlyArray<T>) => K | undefined): BoundedPartial<Record<K, number>>;
|
|
23
23
|
/**
|
|
24
24
|
* Categorize and count elements in an array using a defined callback function.
|
|
25
25
|
* The callback function is applied to each element in the array to determine
|
|
@@ -36,6 +36,6 @@ declare function countBy<T, K extends PropertyKey>(data: ReadonlyArray<T>, categ
|
|
|
36
36
|
* @dataLast
|
|
37
37
|
* @category Array
|
|
38
38
|
*/
|
|
39
|
-
declare function countBy<T, K extends PropertyKey>(categorizationFn: (value: T, index: number, data: ReadonlyArray<T>) => K | undefined): (data: ReadonlyArray<T>) =>
|
|
39
|
+
declare function countBy<T, K extends PropertyKey>(categorizationFn: (value: T, index: number, data: ReadonlyArray<T>) => K | undefined): (data: ReadonlyArray<T>) => BoundedPartial<Record<K, number>>;
|
|
40
40
|
|
|
41
41
|
export { countBy };
|
package/dist/count-by.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as BoundedPartial } from './bounded-partial-CJjczH6j.js';
|
|
2
2
|
import './if-bounded-record-Drd4UbBU.js';
|
|
3
3
|
import 'type-fest';
|
|
4
4
|
|
|
@@ -19,7 +19,7 @@ import 'type-fest';
|
|
|
19
19
|
* @dataFirst
|
|
20
20
|
* @category Array
|
|
21
21
|
*/
|
|
22
|
-
declare function countBy<T, K extends PropertyKey>(data: ReadonlyArray<T>, categorizationFn: (value: T, index: number, data: ReadonlyArray<T>) => K | undefined):
|
|
22
|
+
declare function countBy<T, K extends PropertyKey>(data: ReadonlyArray<T>, categorizationFn: (value: T, index: number, data: ReadonlyArray<T>) => K | undefined): BoundedPartial<Record<K, number>>;
|
|
23
23
|
/**
|
|
24
24
|
* Categorize and count elements in an array using a defined callback function.
|
|
25
25
|
* The callback function is applied to each element in the array to determine
|
|
@@ -36,6 +36,6 @@ declare function countBy<T, K extends PropertyKey>(data: ReadonlyArray<T>, categ
|
|
|
36
36
|
* @dataLast
|
|
37
37
|
* @category Array
|
|
38
38
|
*/
|
|
39
|
-
declare function countBy<T, K extends PropertyKey>(categorizationFn: (value: T, index: number, data: ReadonlyArray<T>) => K | undefined): (data: ReadonlyArray<T>) =>
|
|
39
|
+
declare function countBy<T, K extends PropertyKey>(categorizationFn: (value: T, index: number, data: ReadonlyArray<T>) => K | undefined): (data: ReadonlyArray<T>) => BoundedPartial<Record<K, number>>;
|
|
40
40
|
|
|
41
41
|
export { countBy };
|
package/dist/count-by.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-CTGIT5TY.js";import"./chunk-J6WPJH72.js";import"./chunk-KGPDVVVV.js";export{a as countBy};
|