@duplojs/utils 1.2.17 → 1.2.19
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/chunk.cjs +16 -0
- package/dist/array/chunk.d.ts +2 -0
- package/dist/array/chunk.mjs +14 -0
- package/dist/array/every.cjs +6 -3
- package/dist/array/every.d.ts +4 -3
- package/dist/array/every.mjs +6 -3
- package/dist/array/fill/all.d.ts +2 -2
- package/dist/array/filter.cjs +6 -3
- package/dist/array/filter.d.ts +6 -5
- package/dist/array/filter.mjs +6 -3
- package/dist/array/flatMap.cjs +6 -3
- package/dist/array/flatMap.d.ts +4 -3
- package/dist/array/flatMap.mjs +6 -3
- package/dist/array/index.cjs +13 -10
- package/dist/array/index.d.ts +3 -0
- package/dist/array/index.mjs +5 -4
- package/dist/array/insert.cjs +12 -0
- package/dist/array/insert.d.ts +2 -0
- package/dist/array/insert.mjs +10 -0
- package/dist/array/isLastIndex.cjs +12 -0
- package/dist/array/isLastIndex.d.ts +2 -0
- package/dist/array/isLastIndex.mjs +10 -0
- package/dist/array/map.cjs +6 -3
- package/dist/array/map.d.ts +4 -3
- package/dist/array/map.mjs +6 -3
- package/dist/array/push.cjs +3 -3
- package/dist/array/push.d.ts +2 -2
- package/dist/array/push.mjs +3 -3
- package/dist/array/reduce.cjs +22 -9
- package/dist/array/reduce.d.ts +7 -4
- package/dist/array/reduce.mjs +22 -10
- package/dist/array/reduceRight.cjs +7 -10
- package/dist/array/reduceRight.d.ts +2 -2
- package/dist/array/reduceRight.mjs +7 -10
- package/dist/array/some.cjs +6 -3
- package/dist/array/some.d.ts +4 -3
- package/dist/array/some.mjs +6 -3
- package/dist/array/types/ArrayCoalescing.d.ts +1 -1
- package/dist/clean/constraint/base.cjs +77 -0
- package/dist/clean/constraint/base.d.ts +36 -0
- package/dist/clean/constraint/base.mjs +72 -0
- package/dist/{array/sort → clean/constraint/defaultConstraint}/index.d.ts +0 -1
- package/dist/clean/constraint/defaultConstraint/number.cjs +15 -0
- package/dist/clean/constraint/defaultConstraint/number.d.ts +8 -0
- package/dist/clean/constraint/defaultConstraint/number.mjs +11 -0
- package/dist/clean/constraint/defaultConstraint/string.cjs +12 -0
- package/dist/clean/constraint/defaultConstraint/string.d.ts +6 -0
- package/dist/clean/constraint/defaultConstraint/string.mjs +9 -0
- package/dist/clean/constraint/index.d.ts +2 -0
- package/dist/clean/entity.cjs +125 -0
- package/dist/clean/entity.d.ts +74 -0
- package/dist/clean/entity.mjs +121 -0
- package/dist/clean/flag.cjs +26 -0
- package/dist/clean/flag.d.ts +16 -0
- package/dist/clean/flag.mjs +23 -0
- package/dist/clean/index.cjs +84 -0
- package/dist/clean/index.d.ts +8 -0
- package/dist/clean/index.mjs +29 -0
- package/dist/clean/kind.cjs +9 -0
- package/dist/clean/kind.d.ts +1 -0
- package/dist/clean/kind.mjs +7 -0
- package/dist/clean/newType.cjs +91 -0
- package/dist/clean/newType.d.ts +38 -0
- package/dist/clean/newType.mjs +86 -0
- package/dist/clean/primitive/base.cjs +72 -0
- package/dist/clean/primitive/base.d.ts +36 -0
- package/dist/clean/primitive/base.mjs +64 -0
- package/dist/clean/primitive/index.d.ts +2 -0
- package/dist/clean/primitive/operations/date/dateGreaterThan.cjs +15 -0
- package/dist/clean/primitive/operations/date/dateGreaterThan.d.ts +4 -0
- package/dist/clean/primitive/operations/date/dateGreaterThan.mjs +13 -0
- package/dist/clean/primitive/operations/date/dateLessThan.cjs +15 -0
- package/dist/clean/primitive/operations/date/dateLessThan.d.ts +4 -0
- package/dist/clean/primitive/operations/date/dateLessThan.mjs +13 -0
- package/dist/clean/primitive/operations/date/dateMax.cjs +15 -0
- package/dist/clean/primitive/operations/date/dateMax.d.ts +5 -0
- package/dist/clean/primitive/operations/date/dateMax.mjs +13 -0
- package/dist/clean/primitive/operations/date/dateMin.cjs +15 -0
- package/dist/clean/primitive/operations/date/dateMin.d.ts +5 -0
- package/dist/clean/primitive/operations/date/dateMin.mjs +13 -0
- package/dist/clean/primitive/operations/date/index.d.ts +8 -0
- package/dist/clean/primitive/operations/equal.cjs +14 -0
- package/dist/clean/primitive/operations/equal.d.ts +4 -0
- package/dist/clean/primitive/operations/equal.mjs +12 -0
- package/dist/clean/primitive/operations/index.d.ts +5 -0
- package/dist/clean/primitive/operations/number/add.cjs +15 -0
- package/dist/clean/primitive/operations/number/add.d.ts +3 -0
- package/dist/clean/primitive/operations/number/add.mjs +13 -0
- package/dist/clean/primitive/operations/number/divide.cjs +15 -0
- package/dist/clean/primitive/operations/number/divide.d.ts +3 -0
- package/dist/clean/primitive/operations/number/divide.mjs +13 -0
- package/dist/clean/primitive/operations/number/greaterThan.cjs +14 -0
- package/dist/clean/primitive/operations/number/greaterThan.d.ts +3 -0
- package/dist/clean/primitive/operations/number/greaterThan.mjs +12 -0
- package/dist/clean/primitive/operations/number/index.d.ts +8 -0
- package/dist/clean/primitive/operations/number/lessThan.cjs +14 -0
- package/dist/clean/primitive/operations/number/lessThan.d.ts +3 -0
- package/dist/clean/primitive/operations/number/lessThan.mjs +12 -0
- package/dist/clean/primitive/operations/number/max.cjs +10 -0
- package/dist/clean/primitive/operations/number/max.d.ts +3 -0
- package/dist/clean/primitive/operations/number/max.mjs +8 -0
- package/dist/clean/primitive/operations/number/min.cjs +10 -0
- package/dist/clean/primitive/operations/number/min.d.ts +3 -0
- package/dist/clean/primitive/operations/number/min.mjs +8 -0
- package/dist/clean/primitive/operations/number/multiply.cjs +15 -0
- package/dist/clean/primitive/operations/number/multiply.d.ts +3 -0
- package/dist/clean/primitive/operations/number/multiply.mjs +13 -0
- package/dist/clean/primitive/operations/number/subtract.cjs +15 -0
- package/dist/clean/primitive/operations/number/subtract.d.ts +3 -0
- package/dist/clean/primitive/operations/number/subtract.mjs +13 -0
- package/dist/clean/primitive/operations/sort.cjs +35 -0
- package/dist/clean/primitive/operations/sort.d.ts +9 -0
- package/dist/clean/primitive/operations/sort.mjs +33 -0
- package/dist/clean/primitive/operations/string/concat.cjs +16 -0
- package/dist/clean/primitive/operations/string/concat.d.ts +3 -0
- package/dist/clean/primitive/operations/string/concat.mjs +14 -0
- package/dist/clean/primitive/operations/string/index.d.ts +5 -0
- package/dist/clean/primitive/operations/string/length.cjs +10 -0
- package/dist/clean/primitive/operations/string/length.d.ts +2 -0
- package/dist/clean/primitive/operations/string/length.mjs +8 -0
- package/dist/clean/primitive/operations/string/lengthEqual.cjs +14 -0
- package/dist/clean/primitive/operations/string/lengthEqual.d.ts +3 -0
- package/dist/clean/primitive/operations/string/lengthEqual.mjs +12 -0
- package/dist/clean/primitive/operations/string/lengthGreaterThan.cjs +14 -0
- package/dist/clean/primitive/operations/string/lengthGreaterThan.d.ts +3 -0
- package/dist/clean/primitive/operations/string/lengthGreaterThan.mjs +12 -0
- package/dist/clean/primitive/operations/string/lengthLessThan.cjs +14 -0
- package/dist/clean/primitive/operations/string/lengthLessThan.d.ts +3 -0
- package/dist/clean/primitive/operations/string/lengthLessThan.mjs +12 -0
- package/dist/clean/repository.cjs +15 -0
- package/dist/clean/repository.d.ts +8 -0
- package/dist/clean/repository.mjs +12 -0
- package/dist/clean/useCase.cjs +25 -0
- package/dist/clean/useCase.d.ts +23 -0
- package/dist/clean/useCase.mjs +21 -0
- package/dist/common/index.d.ts +0 -1
- package/dist/common/kind.d.ts +1 -0
- package/dist/common/types/index.d.ts +1 -0
- package/dist/common/types/sortType.d.ts +1 -0
- package/dist/common/unwrap.d.ts +1 -2
- package/dist/dataParser/base.d.ts +5 -4
- package/dist/dataParser/baseExtended.d.ts +4 -4
- package/dist/dataParser/extended/array.d.ts +3 -3
- package/dist/dataParser/extended/bigint.d.ts +2 -2
- package/dist/dataParser/extended/boolean.d.ts +2 -2
- package/dist/dataParser/extended/date.d.ts +3 -2
- package/dist/dataParser/extended/empty.d.ts +2 -2
- package/dist/dataParser/extended/lazy.d.ts +3 -3
- package/dist/dataParser/extended/literal.d.ts +2 -2
- package/dist/dataParser/extended/nil.d.ts +2 -2
- package/dist/dataParser/extended/nullable.d.ts +3 -3
- package/dist/dataParser/extended/number.cjs +3 -0
- package/dist/dataParser/extended/number.d.ts +5 -2
- package/dist/dataParser/extended/number.mjs +3 -0
- package/dist/dataParser/extended/object.cjs +8 -13
- package/dist/dataParser/extended/object.d.ts +4 -2
- package/dist/dataParser/extended/object.mjs +8 -13
- package/dist/dataParser/extended/optional.d.ts +3 -3
- package/dist/dataParser/extended/pipe.d.ts +3 -3
- package/dist/dataParser/extended/record.d.ts +3 -3
- package/dist/dataParser/extended/recover.d.ts +3 -3
- package/dist/dataParser/extended/string.d.ts +2 -2
- package/dist/dataParser/extended/templateLiteral.d.ts +2 -2
- package/dist/dataParser/extended/transform.d.ts +3 -3
- package/dist/dataParser/extended/tuple.d.ts +3 -3
- package/dist/dataParser/extended/union.d.ts +3 -3
- package/dist/dataParser/extended/unknown.d.ts +2 -2
- package/dist/dataParser/identifier.d.ts +10 -160
- package/dist/dataParser/index.cjs +4 -0
- package/dist/dataParser/index.mjs +2 -0
- package/dist/dataParser/parsers/array/index.cjs +2 -2
- package/dist/dataParser/parsers/array/index.mjs +2 -2
- package/dist/dataParser/parsers/literal.d.ts +1 -1
- package/dist/dataParser/parsers/object/index.cjs +3 -3
- package/dist/dataParser/parsers/object/index.d.ts +2 -0
- package/dist/dataParser/parsers/object/index.mjs +3 -3
- package/dist/dataParser/parsers/object/partial.cjs +20 -0
- package/dist/dataParser/parsers/object/partial.d.ts +14 -0
- package/dist/dataParser/parsers/object/partial.mjs +18 -0
- package/dist/dataParser/parsers/object/required.cjs +20 -0
- package/dist/dataParser/parsers/object/required.d.ts +10 -0
- package/dist/dataParser/parsers/object/required.mjs +18 -0
- package/dist/dataParser/parsers/record/index.cjs +2 -2
- package/dist/dataParser/parsers/record/index.mjs +2 -2
- package/dist/dataParser/parsers/refine.d.ts +1 -1
- package/dist/dataParser/parsers/tuple.cjs +2 -2
- package/dist/dataParser/parsers/tuple.mjs +2 -2
- package/dist/date/index.cjs +8 -0
- package/dist/date/index.d.ts +4 -0
- package/dist/date/index.mjs +4 -0
- package/dist/date/is.cjs +9 -0
- package/dist/date/is.d.ts +2 -0
- package/dist/date/is.mjs +7 -0
- package/dist/date/max.cjs +10 -0
- package/dist/date/max.d.ts +3 -0
- package/dist/date/max.mjs +8 -0
- package/dist/date/min.cjs +10 -0
- package/dist/date/min.d.ts +3 -0
- package/dist/date/min.mjs +8 -0
- package/dist/date/sort.cjs +20 -0
- package/dist/date/sort.d.ts +4 -0
- package/dist/date/sort.mjs +18 -0
- package/dist/generator/chunk.cjs +24 -0
- package/dist/generator/chunk.d.ts +2 -0
- package/dist/generator/chunk.mjs +22 -0
- package/dist/generator/index.cjs +2 -0
- package/dist/generator/index.d.ts +1 -0
- package/dist/generator/index.mjs +1 -0
- package/dist/generator/reduce.cjs +2 -6
- package/dist/generator/reduce.d.ts +1 -0
- package/dist/generator/reduce.mjs +2 -6
- package/dist/index.cjs +3 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +3 -1
- package/dist/number/index.cjs +2 -0
- package/dist/number/index.d.ts +1 -0
- package/dist/number/index.mjs +1 -0
- package/dist/number/max.cjs +2 -7
- package/dist/number/max.d.ts +2 -2
- package/dist/number/max.mjs +2 -7
- package/dist/number/min.cjs +2 -7
- package/dist/number/min.d.ts +2 -2
- package/dist/number/min.mjs +2 -7
- package/dist/number/sort.cjs +14 -0
- package/dist/number/sort.d.ts +3 -0
- package/dist/number/sort.mjs +12 -0
- package/dist/pattern/match/index.d.ts +3 -3
- package/dist/pattern/when.d.ts +5 -5
- package/dist/string/index.cjs +2 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.mjs +1 -0
- package/dist/{array/sort/string.cjs → string/sort.cjs} +6 -6
- package/dist/string/sort.d.ts +3 -0
- package/dist/{array/sort/string.mjs → string/sort.mjs} +6 -6
- package/package.json +7 -2
- package/dist/array/sort/number.cjs +0 -14
- package/dist/array/sort/number.d.ts +0 -4
- package/dist/array/sort/number.mjs +0 -12
- package/dist/array/sort/string.d.ts +0 -4
- package/dist/common/not.cjs +0 -12
- package/dist/common/not.d.ts +0 -2
- package/dist/common/not.mjs +0 -10
- /package/dist/array/{sort/default.cjs → sort.cjs} +0 -0
- /package/dist/array/{sort/default.d.ts → sort.d.ts} +0 -0
- /package/dist/array/{sort/default.mjs → sort.mjs} +0 -0
package/dist/number/max.mjs
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
function max(
|
|
2
|
-
|
|
3
|
-
const [comparison] = args;
|
|
4
|
-
return (value) => max(value, comparison);
|
|
5
|
-
}
|
|
6
|
-
const [value, comparison] = args;
|
|
7
|
-
return Math.max(value, comparison);
|
|
1
|
+
function max(input) {
|
|
2
|
+
return Math.max(...input);
|
|
8
3
|
}
|
|
9
4
|
|
|
10
5
|
export { max };
|
package/dist/number/min.cjs
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function min(
|
|
4
|
-
|
|
5
|
-
const [comparison] = args;
|
|
6
|
-
return (value) => min(value, comparison);
|
|
7
|
-
}
|
|
8
|
-
const [value, comparison] = args;
|
|
9
|
-
return Math.min(value, comparison);
|
|
3
|
+
function min(input) {
|
|
4
|
+
return Math.min(...input);
|
|
10
5
|
}
|
|
11
6
|
|
|
12
7
|
exports.min = min;
|
package/dist/number/min.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function min<
|
|
1
|
+
import { type AnyTuple } from "../common";
|
|
2
|
+
export declare function min<GenericInput extends AnyTuple<number>>(input: GenericInput): number;
|
package/dist/number/min.mjs
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
function min(
|
|
2
|
-
|
|
3
|
-
const [comparison] = args;
|
|
4
|
-
return (value) => min(value, comparison);
|
|
5
|
-
}
|
|
6
|
-
const [value, comparison] = args;
|
|
7
|
-
return Math.min(value, comparison);
|
|
1
|
+
function min(input) {
|
|
2
|
+
return Math.min(...input);
|
|
8
3
|
}
|
|
9
4
|
|
|
10
5
|
export { min };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function sort(...args) {
|
|
4
|
+
if (args.length === 1) {
|
|
5
|
+
const [type] = args;
|
|
6
|
+
return (array) => sort(array, type);
|
|
7
|
+
}
|
|
8
|
+
const [array, type] = args;
|
|
9
|
+
return [...array].sort(type === "DSC"
|
|
10
|
+
? (first, second) => second - first
|
|
11
|
+
: (first, second) => first - second);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.sort = sort;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type SortType } from "../common";
|
|
2
|
+
export declare function sort<GenericArray extends readonly number[]>(type: SortType): (array: GenericArray) => number[];
|
|
3
|
+
export declare function sort<GenericArray extends readonly number[]>(array: GenericArray, type: SortType): number[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function sort(...args) {
|
|
2
|
+
if (args.length === 1) {
|
|
3
|
+
const [type] = args;
|
|
4
|
+
return (array) => sort(array, type);
|
|
5
|
+
}
|
|
6
|
+
const [array, type] = args;
|
|
7
|
+
return [...array].sort(type === "DSC"
|
|
8
|
+
? (first, second) => second - first
|
|
9
|
+
: (first, second) => first - second);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { sort };
|
|
@@ -4,6 +4,6 @@ import { type PatternResult } from "../result";
|
|
|
4
4
|
import { type ComplexMatchedValue, type ComplexUnMatchedValue } from "../types";
|
|
5
5
|
import { type MatchBuilder } from "./builder";
|
|
6
6
|
export * from "./builder";
|
|
7
|
-
export declare function match<GenericInput extends
|
|
8
|
-
export declare function match<GenericInput extends
|
|
9
|
-
export declare function match<GenericInput extends
|
|
7
|
+
export declare function match<GenericInput extends unknown>(input: GenericInput): MatchBuilder<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput>;
|
|
8
|
+
export declare function match<GenericInput extends unknown, GenericInputValue extends Exclude<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, const GenericPattern extends Pattern<GenericInputValue>, GenericPatternValue extends PatternValue<GenericPattern>, GenericOutput extends AnyValue | EscapeVoid, GenericMatchedValue extends Extract<ComplexMatchedValue<GenericInputValue, GenericPatternValue>, any>>(pattern: FixDeepFunctionInfer<Pattern<GenericInputValue>, GenericPattern>, theFunction: (value: Extract<ComplexMatchedValue<GenericInputValue, PatternValue<GenericPattern>>, any>) => GenericOutput): (input: GenericInput | GenericInputValue | GenericInputPatternResult) => BreakGenericLink<((IsEqual<GenericMatchedValue, never> extends true ? never : PatternResult<GenericOutput>) | GenericInputPatternResult | Extract<ComplexUnMatchedValue<GenericInputValue, GenericPatternValue>, any>)>;
|
|
9
|
+
export declare function match<GenericInput extends unknown, GenericInputValue extends Exclude<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, const GenericPattern extends Pattern<GenericInputValue>, GenericPatternValue extends PatternValue<GenericPattern>, GenericOutput extends AnyValue | EscapeVoid, GenericMatchedValue extends Extract<ComplexMatchedValue<GenericInputValue, GenericPatternValue>, any>>(input: GenericInput | GenericInputValue | GenericInputPatternResult, pattern: FixDeepFunctionInfer<Pattern<GenericInputValue>, GenericPattern>, theFunction: (value: Extract<ComplexMatchedValue<GenericInputValue, PatternValue<GenericPattern>>, any>) => GenericOutput): BreakGenericLink<(IsEqual<GenericMatchedValue, never> extends true ? never : PatternResult<GenericOutput>) | GenericInputPatternResult | Extract<ComplexUnMatchedValue<GenericInputValue, GenericPatternValue>, any>>;
|
package/dist/pattern/when.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type AnyValue, type BreakGenericLink } from "../common";
|
|
1
|
+
import { type AnyValue, type BreakGenericLink, type IsEqual, type EscapeVoid } from "../common";
|
|
2
2
|
import { type PatternResult } from "./result";
|
|
3
|
-
export declare function when<GenericInput extends
|
|
4
|
-
export declare function when<GenericInput extends
|
|
5
|
-
export declare function when<GenericInput extends
|
|
6
|
-
export declare function when<GenericInput extends
|
|
3
|
+
export declare function when<GenericInput extends unknown, GenericInputValue extends Exclude<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericPredicatedInput extends GenericInputValue, GenericOutput extends AnyValue | EscapeVoid>(predicate: (input: GenericInputValue) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput): (input: (GenericInput | GenericInputPatternResult | GenericInputValue)) => (GenericInputPatternResult | Exclude<BreakGenericLink<GenericInput>, GenericPredicatedInput | PatternResult> | PatternResult<GenericOutput>);
|
|
4
|
+
export declare function when<GenericInput extends unknown, GenericInputValue extends Exclude<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericOutput extends AnyValue | EscapeVoid>(predicate: (input: GenericInputValue) => boolean, theFunction: (predicatedInput: GenericInputValue) => GenericOutput): (input: (GenericInput | GenericInputPatternResult | GenericInputValue)) => (GenericInputPatternResult | GenericInputValue | PatternResult<GenericOutput>);
|
|
5
|
+
export declare function when<GenericInput extends unknown, GenericInputValue extends Exclude<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericPredicatedInput extends GenericInputValue, GenericOutput extends AnyValue | EscapeVoid>(input: (GenericInput | GenericInputPatternResult | GenericInputValue), predicate: (input: GenericInputValue) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput): (GenericInputPatternResult | Exclude<BreakGenericLink<GenericInput>, GenericPredicatedInput | PatternResult> | PatternResult<GenericOutput>);
|
|
6
|
+
export declare function when<GenericInput extends unknown, GenericInputValue extends Exclude<IsEqual<GenericInput, unknown> extends true ? AnyValue : GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericOutput extends AnyValue | EscapeVoid>(input: (GenericInput | GenericInputPatternResult | GenericInputValue), predicate: (input: GenericInputValue) => boolean, theFunction: (predicatedInput: GenericInputValue) => GenericOutput): (GenericInputPatternResult | GenericInputValue | PatternResult<GenericOutput>);
|
package/dist/string/index.cjs
CHANGED
|
@@ -27,6 +27,7 @@ var normalize = require('./normalize.cjs');
|
|
|
27
27
|
var test = require('./test.cjs');
|
|
28
28
|
var isIn = require('./isIn.cjs');
|
|
29
29
|
var length = require('./length.cjs');
|
|
30
|
+
var sort = require('./sort.cjs');
|
|
30
31
|
var _default = require('./at/default.cjs');
|
|
31
32
|
var first = require('./at/first.cjs');
|
|
32
33
|
var last = require('./at/last.cjs');
|
|
@@ -63,6 +64,7 @@ exports.normalize = normalize.normalize;
|
|
|
63
64
|
exports.test = test.test;
|
|
64
65
|
exports.isIn = isIn.isIn;
|
|
65
66
|
exports.length = length.length;
|
|
67
|
+
exports.sort = sort.sort;
|
|
66
68
|
exports.at = _default.at;
|
|
67
69
|
exports.first = first.first;
|
|
68
70
|
exports.last = last.last;
|
package/dist/string/index.d.ts
CHANGED
package/dist/string/index.mjs
CHANGED
|
@@ -25,6 +25,7 @@ export { normalize } from './normalize.mjs';
|
|
|
25
25
|
export { test } from './test.mjs';
|
|
26
26
|
export { isIn } from './isIn.mjs';
|
|
27
27
|
export { length } from './length.mjs';
|
|
28
|
+
export { sort } from './sort.mjs';
|
|
28
29
|
export { at } from './at/default.mjs';
|
|
29
30
|
export { first } from './at/first.mjs';
|
|
30
31
|
export { last } from './at/last.mjs';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function
|
|
3
|
+
function sort(...args) {
|
|
4
4
|
if (args.length === 1) {
|
|
5
|
-
const [
|
|
6
|
-
return (array) =>
|
|
5
|
+
const [type] = args;
|
|
6
|
+
return (array) => sort(array, type);
|
|
7
7
|
}
|
|
8
|
-
const [array,
|
|
9
|
-
return [...array].sort(
|
|
8
|
+
const [array, type] = args;
|
|
9
|
+
return [...array].sort(type === "DSC"
|
|
10
10
|
? (first, second) => {
|
|
11
11
|
if (first < second) {
|
|
12
12
|
return 1;
|
|
@@ -21,4 +21,4 @@ function sortString(...args) {
|
|
|
21
21
|
: undefined);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
exports.
|
|
24
|
+
exports.sort = sort;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type SortType } from "../common";
|
|
2
|
+
export declare function sort<GenericArray extends readonly string[]>(type: SortType): (array: GenericArray) => string[];
|
|
3
|
+
export declare function sort<GenericArray extends readonly string[]>(array: GenericArray, type: SortType): string[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function sort(...args) {
|
|
2
2
|
if (args.length === 1) {
|
|
3
|
-
const [
|
|
4
|
-
return (array) =>
|
|
3
|
+
const [type] = args;
|
|
4
|
+
return (array) => sort(array, type);
|
|
5
5
|
}
|
|
6
|
-
const [array,
|
|
7
|
-
return [...array].sort(
|
|
6
|
+
const [array, type] = args;
|
|
7
|
+
return [...array].sort(type === "DSC"
|
|
8
8
|
? (first, second) => {
|
|
9
9
|
if (first < second) {
|
|
10
10
|
return 1;
|
|
@@ -19,4 +19,4 @@ function sortString(...args) {
|
|
|
19
19
|
: undefined);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export {
|
|
22
|
+
export { sort };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duplojs/utils",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.19",
|
|
4
4
|
"author": "mathcovax",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -86,6 +86,11 @@
|
|
|
86
86
|
"import": "./dist/date/index.mjs",
|
|
87
87
|
"require": "./dist/date/index.cjs",
|
|
88
88
|
"types": "./dist/date/index.d.ts"
|
|
89
|
+
},
|
|
90
|
+
"./clean": {
|
|
91
|
+
"import": "./dist/clean/index.mjs",
|
|
92
|
+
"require": "./dist/clean/index.cjs",
|
|
93
|
+
"types": "./dist/clean/index.d.ts"
|
|
89
94
|
}
|
|
90
95
|
},
|
|
91
96
|
"files": [
|
|
@@ -107,7 +112,7 @@
|
|
|
107
112
|
"rollup-plugin-tsc-alias": "1.1.4",
|
|
108
113
|
"tslib": "2.8.1",
|
|
109
114
|
"tsx": "4.20.5",
|
|
110
|
-
"typescript": "5.9.
|
|
115
|
+
"typescript": "5.9.3",
|
|
111
116
|
"vite-tsconfig-paths": "5.1.4",
|
|
112
117
|
"vitest": "3.2.4"
|
|
113
118
|
},
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function sortNumber(...args) {
|
|
4
|
-
if (args.length === 1) {
|
|
5
|
-
const [sort] = args;
|
|
6
|
-
return (array) => sortNumber(array, sort);
|
|
7
|
-
}
|
|
8
|
-
const [array, sort] = args;
|
|
9
|
-
return [...array].sort(sort === "dsc"
|
|
10
|
-
? (first, second) => second - first
|
|
11
|
-
: (first, second) => first - second);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
exports.sortNumber = sortNumber;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
type Sort = "asc" | "dsc";
|
|
2
|
-
export declare function sortNumber<GenericArray extends readonly number[]>(sort: Sort): (array: GenericArray) => number[];
|
|
3
|
-
export declare function sortNumber<GenericArray extends readonly number[]>(array: GenericArray, sort: Sort): number[];
|
|
4
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
function sortNumber(...args) {
|
|
2
|
-
if (args.length === 1) {
|
|
3
|
-
const [sort] = args;
|
|
4
|
-
return (array) => sortNumber(array, sort);
|
|
5
|
-
}
|
|
6
|
-
const [array, sort] = args;
|
|
7
|
-
return [...array].sort(sort === "dsc"
|
|
8
|
-
? (first, second) => second - first
|
|
9
|
-
: (first, second) => first - second);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { sortNumber };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
type Sort = "asc" | "dsc";
|
|
2
|
-
export declare function sortString<GenericArray extends readonly string[]>(sort: Sort): (array: GenericArray) => string[];
|
|
3
|
-
export declare function sortString<GenericArray extends readonly string[]>(array: GenericArray, sort: Sort): string[];
|
|
4
|
-
export {};
|
package/dist/common/not.cjs
DELETED
package/dist/common/not.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare function not<GenericInput extends unknown, GenericPredicatedInput extends GenericInput>(predicate: (input: GenericInput) => input is GenericPredicatedInput): (input: GenericInput) => input is Exclude<GenericInput, GenericPredicatedInput>;
|
|
2
|
-
export declare function not<GenericInput extends unknown, GenericPredicatedInput extends GenericInput>(input: GenericInput, predicate: (input: GenericInput) => input is GenericPredicatedInput): input is Exclude<GenericInput, GenericPredicatedInput>;
|
package/dist/common/not.mjs
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|