@vinicunca/perkakas 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bounded-partial-BzynYDVs.d.ts → bounded-partial-B15MLSAS.d.ts} +1 -2
- package/dist/{bounded-partial-BqwRN49U.d.cts → bounded-partial-BhnecV3P.d.cts} +1 -2
- package/dist/chunk-4Y6VRHEP.js +1 -0
- package/dist/chunk-ALP5JUXX.cjs +1 -0
- package/dist/{chunk-Z7D7Q6U3.js → chunk-DXA7AZUA.js} +1 -1
- package/dist/chunk-HHNHTPVO.cjs +1 -0
- package/dist/{chunk-FOUZI2Q3.cjs → chunk-QPMGUF2V.cjs} +1 -1
- package/dist/chunk-RZBBV6PK.js +1 -0
- package/dist/chunk.d.cts +1 -9
- package/dist/chunk.d.ts +1 -9
- package/dist/constant.d.cts +1 -1
- package/dist/constant.d.ts +1 -1
- package/dist/count-by.d.cts +2 -3
- package/dist/count-by.d.ts +2 -3
- package/dist/from-keys.d.cts +1 -2
- package/dist/from-keys.d.ts +1 -2
- package/dist/funnel.lodash-debounce-with-cached-value.test.cjs +1 -1
- package/dist/funnel.lodash-debounce-with-cached-value.test.js +1 -1
- package/dist/funnel.lodash-debounce.test.cjs +1 -1
- package/dist/funnel.lodash-debounce.test.js +1 -1
- package/dist/funnel.lodash-throttle-with-cached-value.test.cjs +1 -1
- package/dist/funnel.lodash-throttle-with-cached-value.test.js +1 -1
- package/dist/funnel.lodash-throttle.test.cjs +1 -1
- package/dist/funnel.lodash-throttle.test.js +1 -1
- package/dist/funnel.perkakas-debounce.test.cjs +1 -1
- package/dist/funnel.perkakas-debounce.test.js +1 -1
- package/dist/funnel.reference-batch.test.cjs +1 -1
- package/dist/funnel.reference-batch.test.js +1 -1
- package/dist/funnel.test-d.cjs +1 -1
- package/dist/funnel.test-d.js +1 -1
- package/dist/funnel.test.cjs +1 -1
- package/dist/funnel.test.js +1 -1
- package/dist/group-by-prop.d.cts +1 -2
- package/dist/group-by-prop.d.ts +1 -2
- package/dist/group-by.d.cts +2 -3
- package/dist/group-by.d.ts +2 -3
- package/dist/index-by.d.cts +2 -3
- package/dist/index-by.d.ts +2 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/map-keys.d.cts +2 -3
- package/dist/map-keys.d.ts +2 -3
- package/dist/map-values.d.cts +1 -1
- package/dist/map-values.d.ts +1 -1
- package/dist/n-tuple-5jljrt4c.d.cts +10 -0
- package/dist/n-tuple-5jljrt4c.d.ts +10 -0
- package/dist/omit-by.d.cts +2 -3
- package/dist/omit-by.d.ts +2 -3
- package/dist/path-or.d.cts +10 -0
- package/dist/path-or.d.ts +10 -0
- package/dist/pick-by.d.cts +3 -4
- package/dist/pick-by.d.ts +3 -4
- package/dist/pick.cjs +1 -1
- package/dist/pick.d.cts +3 -4
- package/dist/pick.d.ts +3 -4
- package/dist/pick.js +1 -1
- package/dist/prop.cjs +1 -1
- package/dist/prop.d.cts +118 -13
- package/dist/prop.d.ts +118 -13
- package/dist/prop.js +1 -1
- package/dist/pull-object.d.cts +2 -3
- package/dist/pull-object.d.ts +2 -3
- package/dist/sample.cjs +1 -1
- package/dist/sample.d.cts +32 -8
- package/dist/sample.d.ts +32 -8
- package/dist/sample.js +1 -1
- package/dist/string-to-path.d.cts +2 -3
- package/dist/string-to-path.d.ts +2 -3
- package/package.json +6 -6
- package/dist/chunk-2MHE6M7V.cjs +0 -1
- package/dist/chunk-NEIICTWC.js +0 -1
- package/dist/chunk-SOPOELNU.cjs +0 -1
- package/dist/chunk-XEAAXO7F.js +0 -1
- package/dist/if-D4QIikQ1.d.cts +0 -5
- package/dist/if-D4QIikQ1.d.ts +0 -5
- /package/dist/{chunk-P7RCAO7P.cjs → chunk-I5B54QDJ.cjs} +0 -0
- /package/dist/{chunk-Z23BZCCD.js → chunk-VVGDSDKI.js} +0 -0
package/dist/sample.d.ts
CHANGED
|
@@ -1,11 +1,35 @@
|
|
|
1
|
+
import { Or, IsEqual, IsNever, NonNegativeInteger, FixedLengthArray, Writable } from 'type-fest';
|
|
2
|
+
import { C as CoercedArray } from './coerced-array-DRz3tqda.js';
|
|
1
3
|
import { I as IterableContainer } from './iterable-container-BTpDVdNc.js';
|
|
4
|
+
import { N as NTuple } from './n-tuple-5jljrt4c.js';
|
|
5
|
+
import { P as PartialArray } from './partial-array-Vnf1fBtl.js';
|
|
6
|
+
import { T as TupleParts } from './tuple-parts-BTivqbtT.js';
|
|
7
|
+
import './perkakas-type-error-8wPb8T2y.js';
|
|
2
8
|
|
|
3
|
-
type Sampled<T extends IterableContainer, N extends number> =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
type Sampled<T extends IterableContainer, N extends number> = Or<IsEqual<N, 0>, IsEqual<T['length'], 0>> extends true ? [] : IsNever<NonNegativeInteger<N>> extends true ? SampledPrimitive<T> : IsLongerThan<T, N> extends true ? SampledLiteral<T, N> : Writable<T>;
|
|
10
|
+
/**
|
|
11
|
+
* When N is not a non-negative integer **literal** we can't use it in our
|
|
12
|
+
* reconstructing logic so we fallback to a simpler definition of the output of
|
|
13
|
+
* sample, which is any sub-tuple shape of T, of **any length**.
|
|
14
|
+
*/
|
|
15
|
+
type SampledPrimitive<T extends IterableContainer> = [
|
|
16
|
+
...FixedSubTuples<TupleParts<T>['required']>,
|
|
17
|
+
...PartialArray<FixedSubTuples<TupleParts<T>['optional']>>,
|
|
18
|
+
...CoercedArray<TupleParts<T>['item']>,
|
|
19
|
+
...FixedSubTuples<TupleParts<T>['suffix']>
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Knowing N is a non-negative literal integer we can construct all sub-tuples
|
|
23
|
+
* of T that are exactly N elements long.
|
|
24
|
+
*/
|
|
25
|
+
type SampledLiteral<T extends IterableContainer, N extends number> = Extract<FixedSubTuples<[
|
|
26
|
+
...TupleParts<T>['required'],
|
|
27
|
+
...(IsNever<TupleParts<T>['item']> extends true ? [] : NTuple<TupleParts<T>['item'], N>),
|
|
28
|
+
...TupleParts<T>['suffix']
|
|
29
|
+
]>, FixedLengthArray<unknown, N>> | SubSampled<TupleParts<T>['required'], TupleParts<T>['item'], TupleParts<T>['suffix'], N>;
|
|
30
|
+
type SubSampled<Prefix extends ReadonlyArray<unknown>, Item, Suffix extends ReadonlyArray<unknown>, N extends number> = IsLongerThan<[...Prefix, ...Suffix], N> extends true ? never : [...Prefix, ...Suffix]['length'] extends N ? never : [...Prefix, ...Suffix] | SubSampled<[...Prefix, Item], Item, Suffix, N>;
|
|
31
|
+
type IsLongerThan<T extends ReadonlyArray<unknown>, N extends number> = IsEqual<T[N], undefined> extends true ? false : true;
|
|
32
|
+
type FixedSubTuples<T> = T extends readonly [infer Head, ...infer Rest] ? FixedSubTuples<Rest> | [Head, ...FixedSubTuples<Rest>] : [];
|
|
9
33
|
/**
|
|
10
34
|
* Returns a random subset of size `sampleSize` from `array`.
|
|
11
35
|
*
|
|
@@ -27,7 +51,7 @@ type SampledLiteral<T extends IterableContainer, N extends number, Iteration ext
|
|
|
27
51
|
* @dataFirst
|
|
28
52
|
* @category Array
|
|
29
53
|
*/
|
|
30
|
-
declare function sample<T extends IterableContainer, N extends number = number>(data: T, sampleSize: N): Sampled<T, N>;
|
|
54
|
+
declare function sample<const T extends IterableContainer, N extends number = number>(data: T, sampleSize: N): Sampled<T, N>;
|
|
31
55
|
/**
|
|
32
56
|
* Returns a random subset of size `sampleSize` from `array`.
|
|
33
57
|
*
|
|
@@ -48,6 +72,6 @@ declare function sample<T extends IterableContainer, N extends number = number>(
|
|
|
48
72
|
* @dataLast
|
|
49
73
|
* @category Array
|
|
50
74
|
*/
|
|
51
|
-
declare function sample<T extends IterableContainer, N extends number = number>(sampleSize: N): (data: T) => Sampled<T, N>;
|
|
75
|
+
declare function sample<const T extends IterableContainer, N extends number = number>(sampleSize: N): (data: T) => Sampled<T, N>;
|
|
52
76
|
|
|
53
77
|
export { sample };
|
package/dist/sample.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-4Y6VRHEP.js";import"./chunk-J6WPJH72.js";import"./chunk-KGPDVVVV.js";import"./chunk-EK7ODJWE.js";export{a as sample};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { IsStringLiteral, IsNumericLiteral } from 'type-fest';
|
|
2
|
-
import { I as If } from './if-D4QIikQ1.cjs';
|
|
3
2
|
|
|
4
|
-
type StringToPath<S> =
|
|
3
|
+
type StringToPath<S> = IsStringLiteral<S> extends true ? StringToPathImpl<S> : Array<string | number>;
|
|
5
4
|
type StringToPathImpl<S> = S extends `${infer Head}['${infer Quoted}']${infer Tail}` ? [...StringToPath<Head>, Quoted, ...StringToPath<Tail>] : S extends `${infer Head}["${infer DoubleQuoted}"]${infer Tail}` ? [...StringToPath<Head>, DoubleQuoted, ...StringToPath<Tail>] : S extends `${infer Head}[${infer Unquoted}]${infer Tail}` ? [
|
|
6
5
|
...StringToPath<Head>,
|
|
7
6
|
...StringToPath<Unquoted>,
|
|
8
7
|
...StringToPath<Tail>
|
|
9
8
|
] : S extends `${infer Head}.${infer Tail}` ? [...StringToPath<Head>, ...StringToPath<Tail>] : '' extends S ? [] : S extends `${infer N extends number}` ? [
|
|
10
|
-
|
|
9
|
+
IsNumericLiteral<N> extends true ? N : S
|
|
11
10
|
] : [S];
|
|
12
11
|
/**
|
|
13
12
|
* A utility to allow JSONPath-like strings to be used in other utilities which
|
package/dist/string-to-path.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { IsStringLiteral, IsNumericLiteral } from 'type-fest';
|
|
2
|
-
import { I as If } from './if-D4QIikQ1.js';
|
|
3
2
|
|
|
4
|
-
type StringToPath<S> =
|
|
3
|
+
type StringToPath<S> = IsStringLiteral<S> extends true ? StringToPathImpl<S> : Array<string | number>;
|
|
5
4
|
type StringToPathImpl<S> = S extends `${infer Head}['${infer Quoted}']${infer Tail}` ? [...StringToPath<Head>, Quoted, ...StringToPath<Tail>] : S extends `${infer Head}["${infer DoubleQuoted}"]${infer Tail}` ? [...StringToPath<Head>, DoubleQuoted, ...StringToPath<Tail>] : S extends `${infer Head}[${infer Unquoted}]${infer Tail}` ? [
|
|
6
5
|
...StringToPath<Head>,
|
|
7
6
|
...StringToPath<Unquoted>,
|
|
8
7
|
...StringToPath<Tail>
|
|
9
8
|
] : S extends `${infer Head}.${infer Tail}` ? [...StringToPath<Head>, ...StringToPath<Tail>] : '' extends S ? [] : S extends `${infer N extends number}` ? [
|
|
10
|
-
|
|
9
|
+
IsNumericLiteral<N> extends true ? N : S
|
|
11
10
|
] : [S];
|
|
12
11
|
/**
|
|
13
12
|
* A utility to allow JSONPath-like strings to be used in other utilities which
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vinicunca/perkakas",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.1",
|
|
5
5
|
"description": "Utility for JavaScript and Typescript.",
|
|
6
6
|
"author": "praburangki<https://github.com/praburangki>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"type-fest": "^4.41.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^22.
|
|
44
|
-
"@vinicunca/eslint-config": "^3.
|
|
43
|
+
"@types/node": "^22.17.0",
|
|
44
|
+
"@vinicunca/eslint-config": "^3.20.0",
|
|
45
45
|
"@vitest/coverage-v8": "^3.2.4",
|
|
46
|
-
"bumpp": "^10.2.
|
|
47
|
-
"eslint": "^9.
|
|
46
|
+
"bumpp": "^10.2.2",
|
|
47
|
+
"eslint": "^9.32.0",
|
|
48
48
|
"prettier": "^3.6.2",
|
|
49
49
|
"taze": "^19.1.0",
|
|
50
50
|
"tsup": "^8.5.0",
|
|
51
|
-
"typescript": "^5.
|
|
51
|
+
"typescript": "^5.9.2",
|
|
52
52
|
"vitest": "^3.2.4"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
package/dist/chunk-2MHE6M7V.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function m(...e){return _chunkXR72I63Wcjs.a.call(void 0, o,e)}function o(e,r){if(r<=0)return[];if(r>=e.length)return[...e];let i=Math.min(r,e.length-r),t=new Set;for(;t.size<i;){let n=Math.floor(Math.random()*e.length);t.add(n)}return r===i?[...t].sort((n,a)=>n-a).map(n=>e[n]):e.filter((n,a)=>!t.has(a))}exports.a = m;
|
package/dist/chunk-NEIICTWC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as n}from"./chunk-J6WPJH72.js";function p(...e){return n(t,e)}function t(e,o){return e[o]}export{p as a,t as b};
|
package/dist/chunk-SOPOELNU.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXR72I63Wcjs = require('./chunk-XR72I63W.cjs');function p(...e){return _chunkXR72I63Wcjs.a.call(void 0, t,e)}function t(e,o){return e[o]}exports.a = p; exports.b = t;
|
package/dist/chunk-XEAAXO7F.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as l}from"./chunk-J6WPJH72.js";function m(...e){return l(o,e)}function o(e,r){if(r<=0)return[];if(r>=e.length)return[...e];let i=Math.min(r,e.length-r),t=new Set;for(;t.size<i;){let n=Math.floor(Math.random()*e.length);t.add(n)}return r===i?[...t].sort((n,a)=>n-a).map(n=>e[n]):e.filter((n,a)=>!t.has(a))}export{m as a};
|
package/dist/if-D4QIikQ1.d.cts
DELETED
package/dist/if-D4QIikQ1.d.ts
DELETED
|
File without changes
|
|
File without changes
|