@duplojs/utils 1.1.11 → 1.1.12

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.
@@ -50,6 +50,7 @@ var replace$1 = require('./findAndSplice/replace.cjs');
50
50
  var sum = require('./sum.cjs');
51
51
  var length = require('./length.cjs');
52
52
  var coalescing = require('./coalescing.cjs');
53
+ var toTuple = require('./toTuple.cjs');
53
54
 
54
55
 
55
56
 
@@ -105,3 +106,4 @@ exports.findAndSpliceReplace = replace$1.findAndSpliceReplace;
105
106
  exports.sum = sum.sum;
106
107
  exports.length = length.length;
107
108
  exports.coalescing = coalescing.coalescing;
109
+ exports.toTuple = toTuple.toTuple;
@@ -40,3 +40,4 @@ export * from "./findAndSplice";
40
40
  export * from "./sum";
41
41
  export * from "./length";
42
42
  export * from "./coalescing";
43
+ export * from "./toTuple";
@@ -48,3 +48,4 @@ export { findAndSpliceReplace } from './findAndSplice/replace.mjs';
48
48
  export { sum } from './sum.mjs';
49
49
  export { length } from './length.mjs';
50
50
  export { coalescing } from './coalescing.mjs';
51
+ export { toTuple } from './toTuple.mjs';
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ function toTuple(...args) {
4
+ if (args.length === 1) {
5
+ const [shape] = args;
6
+ return (input) => toTuple(input, shape);
7
+ }
8
+ const [input, shapeObject] = args;
9
+ return shapeObject.map((theFunction) => theFunction(input));
10
+ }
11
+
12
+ exports.toTuple = toTuple;
@@ -0,0 +1,12 @@
1
+ import { type FixDeepFunctionInfer, type AnyFunction } from "../common";
2
+ type ShapeTuple<GenericInput extends unknown = unknown> = readonly [
3
+ (input: GenericInput) => unknown,
4
+ ...((input: GenericInput) => unknown)[]
5
+ ];
6
+ type ComputesResult<GenericShapeTuple extends ShapeTuple<any>> = GenericShapeTuple extends readonly [
7
+ infer InferredFirst extends AnyFunction,
8
+ ...infer InferredRest extends ShapeTuple<any> | readonly []
9
+ ] ? InferredRest extends ShapeTuple<any> ? ComputesResult<InferredRest> extends infer inferredResult extends readonly any[] ? [ReturnType<InferredFirst>, ...inferredResult] : never : [ReturnType<InferredFirst>] : never;
10
+ export declare function toTuple<GenericInput extends unknown, GenericShapeTuple extends ShapeTuple<NoInfer<GenericInput>>>(shapeObject: ShapeTuple<NoInfer<GenericInput>> & GenericShapeTuple): (input: GenericInput) => ComputesResult<NoInfer<GenericShapeTuple>>;
11
+ export declare function toTuple<GenericInput extends unknown, GenericShapeTuple extends ShapeTuple<GenericInput>>(input: GenericInput, shapeObject: FixDeepFunctionInfer<ShapeTuple<GenericInput>, GenericShapeTuple>): ComputesResult<GenericShapeTuple>;
12
+ export {};
@@ -0,0 +1,10 @@
1
+ function toTuple(...args) {
2
+ if (args.length === 1) {
3
+ const [shape] = args;
4
+ return (input) => toTuple(input, shape);
5
+ }
6
+ const [input, shapeObject] = args;
7
+ return shapeObject.map((theFunction) => theFunction(input));
8
+ }
9
+
10
+ export { toTuple };
@@ -1,3 +1,14 @@
1
+ import { type Or, type UnionContain } from "./types";
1
2
  export type EligibleEqual = string | null | number | undefined | bigint | boolean | symbol;
2
- export declare function equal<GenericInput extends EligibleEqual, GenericValue extends GenericInput>(value: GenericValue | GenericValue[]): (input: GenericInput) => input is NoInfer<GenericValue>;
3
- export declare function equal<GenericInput extends EligibleEqual, GenericValue extends GenericInput>(input: GenericInput, value: GenericValue | GenericValue[]): input is GenericValue;
3
+ type ExpectLiteral<GenericValue extends EligibleEqual> = Or<[
4
+ UnionContain<GenericValue, string>,
5
+ UnionContain<GenericValue, number>,
6
+ UnionContain<GenericValue, boolean>,
7
+ UnionContain<GenericValue, bigint>,
8
+ UnionContain<GenericValue, symbol>
9
+ ]> extends true ? never : GenericValue;
10
+ export declare function equal<GenericInput extends EligibleEqual, GenericValue extends GenericInput>(value: ExpectLiteral<GenericValue> | ExpectLiteral<GenericValue>[]): (input: GenericInput) => input is NoInfer<GenericValue>;
11
+ export declare function equal<GenericInput extends EligibleEqual, GenericValue extends GenericInput>(value: GenericValue | GenericValue[]): (input: GenericInput) => boolean;
12
+ export declare function equal<GenericInput extends EligibleEqual, GenericValue extends GenericInput>(input: GenericInput, value: ExpectLiteral<GenericValue> | ExpectLiteral<GenericValue>[]): input is GenericValue;
13
+ export declare function equal<GenericInput extends EligibleEqual, GenericValue extends GenericInput>(input: GenericInput, value: GenericValue | GenericValue[]): boolean;
14
+ export {};
@@ -0,0 +1 @@
1
+ export type Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
@@ -7,3 +7,5 @@ export * from "./normalizeForm";
7
7
  export * from "./split";
8
8
  export * from "./stringLength";
9
9
  export * from "./forbiddenString";
10
+ export * from "./number";
11
+ export * from "./digit";
@@ -0,0 +1 @@
1
+ export type Number = `${number}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duplojs/utils",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "author": "mathcovax",
5
5
  "license": "MIT",
6
6
  "type": "module",