@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
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function chunk(...args) {
|
|
4
|
+
if (args.length === 1) {
|
|
5
|
+
const [size] = args;
|
|
6
|
+
return (input) => chunk(input, size);
|
|
7
|
+
}
|
|
8
|
+
const [input, size] = args;
|
|
9
|
+
const result = [];
|
|
10
|
+
for (let index = 0; index < input.length; index += size) {
|
|
11
|
+
result.push(input.slice(index, index + size));
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.chunk = chunk;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function chunk(...args) {
|
|
2
|
+
if (args.length === 1) {
|
|
3
|
+
const [size] = args;
|
|
4
|
+
return (input) => chunk(input, size);
|
|
5
|
+
}
|
|
6
|
+
const [input, size] = args;
|
|
7
|
+
const result = [];
|
|
8
|
+
for (let index = 0; index < input.length; index += size) {
|
|
9
|
+
result.push(input.slice(index, index + size));
|
|
10
|
+
}
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { chunk };
|
package/dist/array/every.cjs
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
function every(...args) {
|
|
4
4
|
if (args.length === 1) {
|
|
5
5
|
const [predicate] = args;
|
|
6
|
-
return (
|
|
6
|
+
return (input) => every(input, predicate);
|
|
7
7
|
}
|
|
8
|
-
const [
|
|
9
|
-
return
|
|
8
|
+
const [input, predicate] = args;
|
|
9
|
+
return input.every((element, index) => predicate(element, {
|
|
10
|
+
index,
|
|
11
|
+
self: input,
|
|
12
|
+
}));
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
exports.every = every;
|
package/dist/array/every.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
interface ArrayEveryParams {
|
|
1
|
+
interface ArrayEveryParams<GenericInputArray extends readonly unknown[]> {
|
|
2
2
|
index: number;
|
|
3
|
+
self: GenericInputArray;
|
|
3
4
|
}
|
|
4
|
-
export declare function every<
|
|
5
|
-
export declare function every<
|
|
5
|
+
export declare function every<GenericInput extends readonly unknown[]>(predicate: (element: GenericInput[number], params: ArrayEveryParams<GenericInput>) => boolean): (input: GenericInput) => boolean;
|
|
6
|
+
export declare function every<GenericInput extends readonly unknown[]>(input: GenericInput, predicate: (element: GenericInput[number], params: ArrayEveryParams<GenericInput>) => boolean): boolean;
|
|
6
7
|
export {};
|
package/dist/array/every.mjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
function every(...args) {
|
|
2
2
|
if (args.length === 1) {
|
|
3
3
|
const [predicate] = args;
|
|
4
|
-
return (
|
|
4
|
+
return (input) => every(input, predicate);
|
|
5
5
|
}
|
|
6
|
-
const [
|
|
7
|
-
return
|
|
6
|
+
const [input, predicate] = args;
|
|
7
|
+
return input.every((element, index) => predicate(element, {
|
|
8
|
+
index,
|
|
9
|
+
self: input,
|
|
10
|
+
}));
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
export { every };
|
package/dist/array/fill/all.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function fillAll<GenericElement extends unknown>(
|
|
2
|
-
export declare function fillAll<GenericElement extends unknown>(
|
|
1
|
+
export declare function fillAll<GenericElement extends unknown>(element: GenericElement): (input: readonly unknown[]) => GenericElement[];
|
|
2
|
+
export declare function fillAll<GenericElement extends unknown>(input: readonly unknown[], element: GenericElement): GenericElement[];
|
package/dist/array/filter.cjs
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
function filter(...args) {
|
|
4
4
|
if (args.length === 1) {
|
|
5
5
|
const [predicate] = args;
|
|
6
|
-
return (
|
|
6
|
+
return (input) => filter(input, predicate);
|
|
7
7
|
}
|
|
8
|
-
const [
|
|
9
|
-
return
|
|
8
|
+
const [input, predicate] = args;
|
|
9
|
+
return input.filter((item, index) => predicate(item, {
|
|
10
|
+
index,
|
|
11
|
+
self: input,
|
|
12
|
+
}));
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
exports.filter = filter;
|
package/dist/array/filter.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
interface ArrayFilterParams {
|
|
1
|
+
interface ArrayFilterParams<GenericInputArray extends readonly unknown[]> {
|
|
2
2
|
index: number;
|
|
3
|
+
self: GenericInputArray;
|
|
3
4
|
}
|
|
4
|
-
export declare function filter<
|
|
5
|
-
export declare function filter<
|
|
6
|
-
export declare function filter<
|
|
7
|
-
export declare function filter<
|
|
5
|
+
export declare function filter<GenericInput extends readonly unknown[], GenericOutput extends GenericInput[number]>(predicate: (item: GenericInput[number], params: ArrayFilterParams<GenericInput>) => item is GenericOutput): (input: GenericInput) => GenericOutput[];
|
|
6
|
+
export declare function filter<GenericInput extends readonly unknown[], GenericOutput extends GenericInput[number]>(input: GenericInput, predicate: (item: GenericInput[number], params: ArrayFilterParams<GenericInput>) => item is GenericOutput): GenericOutput[];
|
|
7
|
+
export declare function filter<GenericInput extends readonly unknown[]>(predicate: (item: GenericInput[number], params: ArrayFilterParams<GenericInput>) => boolean): (input: GenericInput) => GenericInput[number][];
|
|
8
|
+
export declare function filter<GenericInput extends readonly unknown[]>(input: GenericInput, predicate: (item: GenericInput[number], params: ArrayFilterParams<GenericInput>) => boolean): GenericInput[number][];
|
|
8
9
|
export {};
|
package/dist/array/filter.mjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
function filter(...args) {
|
|
2
2
|
if (args.length === 1) {
|
|
3
3
|
const [predicate] = args;
|
|
4
|
-
return (
|
|
4
|
+
return (input) => filter(input, predicate);
|
|
5
5
|
}
|
|
6
|
-
const [
|
|
7
|
-
return
|
|
6
|
+
const [input, predicate] = args;
|
|
7
|
+
return input.filter((item, index) => predicate(item, {
|
|
8
|
+
index,
|
|
9
|
+
self: input,
|
|
10
|
+
}));
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
export { filter };
|
package/dist/array/flatMap.cjs
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
function flatMap(...args) {
|
|
4
4
|
if (args.length === 1) {
|
|
5
5
|
const [theFunction] = args;
|
|
6
|
-
return (
|
|
6
|
+
return (input) => flatMap(input, theFunction);
|
|
7
7
|
}
|
|
8
|
-
const [
|
|
9
|
-
return
|
|
8
|
+
const [input, theFunction] = args;
|
|
9
|
+
return input.flatMap((element, index) => theFunction(element, {
|
|
10
|
+
index,
|
|
11
|
+
self: input,
|
|
12
|
+
}));
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
exports.flatMap = flatMap;
|
package/dist/array/flatMap.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface ArrayFlatMapParams<GenericInputArray extends readonly unknown[]> {
|
|
2
2
|
index: number;
|
|
3
|
+
self: GenericInputArray;
|
|
3
4
|
}
|
|
4
|
-
export declare function flatMap<
|
|
5
|
-
export declare function flatMap<
|
|
5
|
+
export declare function flatMap<GenericInput extends readonly unknown[], GenericOutput extends unknown>(theFunction: (element: GenericInput[number], params: ArrayFlatMapParams<GenericInput>) => GenericOutput): (input: GenericInput) => FlatArray<GenericOutput, 1>[];
|
|
6
|
+
export declare function flatMap<GenericInput extends readonly unknown[], GenericOutput extends unknown>(input: GenericInput, theFunction: (element: GenericInput[number], params: ArrayFlatMapParams<GenericInput>) => GenericOutput): FlatArray<GenericOutput, 1>[];
|
|
6
7
|
export {};
|
package/dist/array/flatMap.mjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
function flatMap(...args) {
|
|
2
2
|
if (args.length === 1) {
|
|
3
3
|
const [theFunction] = args;
|
|
4
|
-
return (
|
|
4
|
+
return (input) => flatMap(input, theFunction);
|
|
5
5
|
}
|
|
6
|
-
const [
|
|
7
|
-
return
|
|
6
|
+
const [input, theFunction] = args;
|
|
7
|
+
return input.flatMap((element, index) => theFunction(element, {
|
|
8
|
+
index,
|
|
9
|
+
self: input,
|
|
10
|
+
}));
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
export { flatMap };
|
package/dist/array/index.cjs
CHANGED
|
@@ -13,6 +13,7 @@ var minOf = require('./minOf.cjs');
|
|
|
13
13
|
var push = require('./push.cjs');
|
|
14
14
|
var reduce = require('./reduce.cjs');
|
|
15
15
|
var some = require('./some.cjs');
|
|
16
|
+
var sort = require('./sort.cjs');
|
|
16
17
|
var is = require('./is.cjs');
|
|
17
18
|
var findIndex = require('./findIndex.cjs');
|
|
18
19
|
var findLastIndex = require('./findLastIndex.cjs');
|
|
@@ -38,16 +39,16 @@ var length = require('./length.cjs');
|
|
|
38
39
|
var coalescing = require('./coalescing.cjs');
|
|
39
40
|
var toTuple = require('./toTuple.cjs');
|
|
40
41
|
var notIncludes = require('./notIncludes.cjs');
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
42
|
+
var chunk = require('./chunk.cjs');
|
|
43
|
+
var insert$2 = require('./insert.cjs');
|
|
44
|
+
var isLastIndex = require('./isLastIndex.cjs');
|
|
44
45
|
var _delete = require('./splice/delete.cjs');
|
|
45
46
|
var insert = require('./splice/insert.cjs');
|
|
46
47
|
var replace = require('./splice/replace.cjs');
|
|
47
|
-
var _default
|
|
48
|
+
var _default = require('./at/default.cjs');
|
|
48
49
|
var first = require('./at/first.cjs');
|
|
49
50
|
var last = require('./at/last.cjs');
|
|
50
|
-
var _default$
|
|
51
|
+
var _default$1 = require('./fill/default.cjs');
|
|
51
52
|
var all = require('./fill/all.cjs');
|
|
52
53
|
var _delete$1 = require('./findAndSplice/delete.cjs');
|
|
53
54
|
var insert$1 = require('./findAndSplice/insert.cjs');
|
|
@@ -69,7 +70,9 @@ exports.minOf = minOf.minOf;
|
|
|
69
70
|
exports.push = push.push;
|
|
70
71
|
exports.reduce = reduce.reduce;
|
|
71
72
|
exports.reduceFrom = reduce.reduceFrom;
|
|
73
|
+
exports.reduceTools = reduce.reduceTools;
|
|
72
74
|
exports.some = some.some;
|
|
75
|
+
exports.sort = sort.sort;
|
|
73
76
|
exports.is = is.is;
|
|
74
77
|
exports.findIndex = findIndex.findIndex;
|
|
75
78
|
exports.findLastIndex = findLastIndex.findLastIndex;
|
|
@@ -95,16 +98,16 @@ exports.length = length.length;
|
|
|
95
98
|
exports.coalescing = coalescing.coalescing;
|
|
96
99
|
exports.toTuple = toTuple.toTuple;
|
|
97
100
|
exports.notIncludes = notIncludes.notIncludes;
|
|
98
|
-
exports.
|
|
99
|
-
exports.
|
|
100
|
-
exports.
|
|
101
|
+
exports.chunk = chunk.chunk;
|
|
102
|
+
exports.insert = insert$2.insert;
|
|
103
|
+
exports.isLastIndex = isLastIndex.isLastIndex;
|
|
101
104
|
exports.spliceDelete = _delete.spliceDelete;
|
|
102
105
|
exports.spliceInsert = insert.spliceInsert;
|
|
103
106
|
exports.spliceReplace = replace.spliceReplace;
|
|
104
|
-
exports.at = _default
|
|
107
|
+
exports.at = _default.at;
|
|
105
108
|
exports.first = first.first;
|
|
106
109
|
exports.last = last.last;
|
|
107
|
-
exports.fill = _default$
|
|
110
|
+
exports.fill = _default$1.fill;
|
|
108
111
|
exports.fillAll = all.fillAll;
|
|
109
112
|
exports.findAndSpliceDelete = _delete$1.findAndSpliceDelete;
|
|
110
113
|
exports.findAndSpliceInsert = insert$1.findAndSpliceInsert;
|
package/dist/array/index.d.ts
CHANGED
package/dist/array/index.mjs
CHANGED
|
@@ -9,8 +9,9 @@ export { maxOf } from './maxOf.mjs';
|
|
|
9
9
|
export { minElements } from './minElements.mjs';
|
|
10
10
|
export { minOf } from './minOf.mjs';
|
|
11
11
|
export { push } from './push.mjs';
|
|
12
|
-
export { reduce, reduceFrom } from './reduce.mjs';
|
|
12
|
+
export { reduce, reduceFrom, reduceTools } from './reduce.mjs';
|
|
13
13
|
export { some } from './some.mjs';
|
|
14
|
+
export { sort } from './sort.mjs';
|
|
14
15
|
export { is } from './is.mjs';
|
|
15
16
|
export { findIndex } from './findIndex.mjs';
|
|
16
17
|
export { findLastIndex } from './findLastIndex.mjs';
|
|
@@ -36,9 +37,9 @@ export { length } from './length.mjs';
|
|
|
36
37
|
export { coalescing } from './coalescing.mjs';
|
|
37
38
|
export { toTuple } from './toTuple.mjs';
|
|
38
39
|
export { notIncludes } from './notIncludes.mjs';
|
|
39
|
-
export {
|
|
40
|
-
export {
|
|
41
|
-
export {
|
|
40
|
+
export { chunk } from './chunk.mjs';
|
|
41
|
+
export { insert } from './insert.mjs';
|
|
42
|
+
export { isLastIndex } from './isLastIndex.mjs';
|
|
42
43
|
export { spliceDelete } from './splice/delete.mjs';
|
|
43
44
|
export { spliceInsert } from './splice/insert.mjs';
|
|
44
45
|
export { spliceReplace } from './splice/replace.mjs';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare function insert<GenericElement extends unknown>(array: readonly GenericElement[]): (input: GenericElement) => GenericElement[];
|
|
2
|
+
export declare function insert<GenericElement extends unknown>(input: GenericElement, array: readonly GenericElement[]): GenericElement[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isLastIndex(...args) {
|
|
4
|
+
if (args.length === 1) {
|
|
5
|
+
const [index] = args;
|
|
6
|
+
return (input) => isLastIndex(input, index);
|
|
7
|
+
}
|
|
8
|
+
const [input, index] = args;
|
|
9
|
+
return (input.length - 1) === index;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.isLastIndex = isLastIndex;
|
package/dist/array/map.cjs
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
function map(...args) {
|
|
4
4
|
if (args.length === 1) {
|
|
5
5
|
const [theFunction] = args;
|
|
6
|
-
return (
|
|
6
|
+
return (input) => map(input, theFunction);
|
|
7
7
|
}
|
|
8
|
-
const [
|
|
9
|
-
return
|
|
8
|
+
const [input, theFunction] = args;
|
|
9
|
+
return input.map((element, index) => theFunction(element, {
|
|
10
|
+
index,
|
|
11
|
+
self: input,
|
|
12
|
+
}));
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
exports.map = map;
|
package/dist/array/map.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
interface ArrayMapParams {
|
|
1
|
+
interface ArrayMapParams<GenericInputArray extends readonly unknown[]> {
|
|
2
2
|
index: number;
|
|
3
|
+
self: GenericInputArray;
|
|
3
4
|
}
|
|
4
|
-
export declare function map<
|
|
5
|
-
export declare function map<
|
|
5
|
+
export declare function map<GenericInput extends readonly unknown[], GenericOutput extends unknown>(theFunction: (element: GenericInput[number], params: ArrayMapParams<GenericInput>) => GenericOutput): (input: GenericInput) => GenericOutput[];
|
|
6
|
+
export declare function map<GenericInput extends readonly unknown[], GenericOutput extends unknown>(input: GenericInput, theFunction: (element: GenericInput[number], params: ArrayMapParams<GenericInput>) => GenericOutput): GenericOutput[];
|
|
6
7
|
export {};
|
package/dist/array/map.mjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
function map(...args) {
|
|
2
2
|
if (args.length === 1) {
|
|
3
3
|
const [theFunction] = args;
|
|
4
|
-
return (
|
|
4
|
+
return (input) => map(input, theFunction);
|
|
5
5
|
}
|
|
6
|
-
const [
|
|
7
|
-
return
|
|
6
|
+
const [input, theFunction] = args;
|
|
7
|
+
return input.map((element, index) => theFunction(element, {
|
|
8
|
+
index,
|
|
9
|
+
self: input,
|
|
10
|
+
}));
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
export { map };
|
package/dist/array/push.cjs
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
function push(...args) {
|
|
4
4
|
if (args.length === 1) {
|
|
5
5
|
const [item] = args;
|
|
6
|
-
return (
|
|
6
|
+
return (input) => push(input, item);
|
|
7
7
|
}
|
|
8
|
-
const [
|
|
9
|
-
return [...
|
|
8
|
+
const [input, ...items] = args;
|
|
9
|
+
return [...input, ...items];
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
exports.push = push;
|
package/dist/array/push.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function push<GenericElement extends unknown>(item: NoInfer<GenericElement>): (
|
|
2
|
-
export declare function push<GenericElement extends unknown>(
|
|
1
|
+
export declare function push<GenericElement extends unknown>(item: NoInfer<GenericElement>): (input: readonly GenericElement[]) => GenericElement[];
|
|
2
|
+
export declare function push<GenericElement extends unknown>(input: readonly GenericElement[], item: NoInfer<GenericElement>, ...items: NoInfer<GenericElement>[]): GenericElement[];
|
package/dist/array/push.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
function push(...args) {
|
|
2
2
|
if (args.length === 1) {
|
|
3
3
|
const [item] = args;
|
|
4
|
-
return (
|
|
4
|
+
return (input) => push(input, item);
|
|
5
5
|
}
|
|
6
|
-
const [
|
|
7
|
-
return [...
|
|
6
|
+
const [input, ...items] = args;
|
|
7
|
+
return [...input, ...items];
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export { push };
|
package/dist/array/reduce.cjs
CHANGED
|
@@ -3,30 +3,42 @@
|
|
|
3
3
|
var kind = require('../common/kind.cjs');
|
|
4
4
|
var wrapValue = require('../common/wrapValue.cjs');
|
|
5
5
|
var unwrap = require('../common/unwrap.cjs');
|
|
6
|
+
var push = require('./push.cjs');
|
|
6
7
|
var override = require('../object/override.cjs');
|
|
7
8
|
|
|
8
9
|
const arrayReduceFromKind = kind.createKind("array-reduce-from");
|
|
9
10
|
function reduceFrom(value) {
|
|
10
11
|
return arrayReduceFromKind.setTo(wrapValue.wrapValue(value));
|
|
11
12
|
}
|
|
13
|
+
const reduceTools = {
|
|
14
|
+
exit(output) {
|
|
15
|
+
return { "-exit": output };
|
|
16
|
+
},
|
|
17
|
+
next(output) {
|
|
18
|
+
return { "-next": output };
|
|
19
|
+
},
|
|
20
|
+
nextWithObject(object1, object2) {
|
|
21
|
+
return { "-next": override.override(object1, object2) };
|
|
22
|
+
},
|
|
23
|
+
nextPush(array, ...[value, ...values]) {
|
|
24
|
+
return { "-next": push.push(array, value, ...values) };
|
|
25
|
+
},
|
|
26
|
+
};
|
|
12
27
|
function reduce(...args) {
|
|
13
28
|
if (args.length === 2) {
|
|
14
29
|
const [fromValue, theFunction] = args;
|
|
15
|
-
return (
|
|
30
|
+
return (input) => reduce(input, fromValue, theFunction);
|
|
16
31
|
}
|
|
17
|
-
const [
|
|
32
|
+
const [input, fromValue, theFunction] = args;
|
|
18
33
|
let lastValue = unwrap.unwrap(fromValue);
|
|
19
|
-
for (let index = 0; index <
|
|
20
|
-
const element =
|
|
34
|
+
for (let index = 0; index < input.length; index++) {
|
|
35
|
+
const element = input[index];
|
|
21
36
|
const result = theFunction({
|
|
22
37
|
element,
|
|
23
38
|
index,
|
|
24
39
|
lastValue,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})),
|
|
28
|
-
exit: (output) => ({ "-exit": output }),
|
|
29
|
-
next: (output) => ({ "-next": output }),
|
|
40
|
+
self: input,
|
|
41
|
+
...reduceTools,
|
|
30
42
|
});
|
|
31
43
|
if ("-exit" in result) {
|
|
32
44
|
return result["-exit"];
|
|
@@ -38,3 +50,4 @@ function reduce(...args) {
|
|
|
38
50
|
|
|
39
51
|
exports.reduce = reduce;
|
|
40
52
|
exports.reduceFrom = reduceFrom;
|
|
53
|
+
exports.reduceTools = reduceTools;
|
package/dist/array/reduce.d.ts
CHANGED
|
@@ -8,20 +8,23 @@ export interface ArrayReduceNext<GenericOutput extends unknown = unknown> {
|
|
|
8
8
|
export interface ArrayReduceExit<GenericOutput extends unknown = unknown> {
|
|
9
9
|
"-exit": GenericOutput;
|
|
10
10
|
}
|
|
11
|
-
export interface ArrayReduceFunctionParams<
|
|
12
|
-
element:
|
|
11
|
+
export interface ArrayReduceFunctionParams<GenericInputArray extends readonly unknown[] = unknown[], GenericOutput extends unknown = unknown> {
|
|
12
|
+
element: GenericInputArray[number];
|
|
13
13
|
index: number;
|
|
14
14
|
lastValue: GenericOutput;
|
|
15
15
|
nextWithObject: GenericOutput extends object ? (object1: GenericOutput, object2: Partial<GenericOutput>) => ArrayReduceNext<GenericOutput> : undefined;
|
|
16
16
|
next(output: GenericOutput): ArrayReduceNext<GenericOutput>;
|
|
17
17
|
exit<GenericExitValue extends unknown>(output: GenericExitValue): ArrayReduceExit<GenericExitValue>;
|
|
18
|
+
self: GenericInputArray;
|
|
19
|
+
nextPush: GenericOutput extends readonly any[] ? (array: GenericOutput, ...values: GenericOutput) => ArrayReduceNext<GenericOutput> : undefined;
|
|
18
20
|
}
|
|
19
21
|
declare const arrayReduceFromKind: import("../common").KindHandler<import("../common").KindDefinition<"array-reduce-from", unknown>>;
|
|
20
22
|
export interface ArrayReduceFromResult<GenericValue extends unknown = unknown> extends Kind<typeof arrayReduceFromKind.definition>, WrappedValue<GenericValue> {
|
|
21
23
|
}
|
|
22
24
|
export declare function reduceFrom<GenericValue extends unknown>(value: GenericValue): ArrayReduceFromResult<GenericValue>;
|
|
25
|
+
export declare const reduceTools: Pick<ArrayReduceFunctionParams<any, any>, "exit" | "next" | "nextWithObject" | "nextPush">;
|
|
23
26
|
export type ArrayEligibleReduceFromValue = number | string | bigint | boolean | ArrayReduceFromResult;
|
|
24
27
|
export type ArrayReduceFromValue<GenericValue extends ArrayEligibleReduceFromValue> = GenericValue extends ArrayReduceFromResult ? Unwrap<GenericValue> : ToLargeEnsemble<GenericValue>;
|
|
25
|
-
export declare function reduce<
|
|
26
|
-
export declare function reduce<
|
|
28
|
+
export declare function reduce<GenericInput extends readonly unknown[], GenericReduceFrom extends ArrayEligibleReduceFromValue, GenericExit extends ArrayReduceExit = ArrayReduceExit<never>>(startValue: GenericReduceFrom, theFunction: (params: ArrayReduceFunctionParams<GenericInput, ArrayReduceFromValue<GenericReduceFrom>>) => ArrayReduceNext<ArrayReduceFromValue<GenericReduceFrom>> | GenericExit): (input: GenericInput) => ArrayReduceFromValue<GenericReduceFrom> | (IsEqual<GenericExit, ArrayReduceExit> extends true ? never : GenericExit["-exit"]);
|
|
29
|
+
export declare function reduce<GenericInput extends readonly unknown[], GenericReduceFrom extends number | string | bigint | boolean | ArrayReduceFromResult, GenericExit extends ArrayReduceExit = ArrayReduceExit<never>>(input: GenericInput, startValue: GenericReduceFrom, theFunction: (params: ArrayReduceFunctionParams<GenericInput, ArrayReduceFromValue<GenericReduceFrom>>) => ArrayReduceNext<ArrayReduceFromValue<GenericReduceFrom>> | GenericExit): ArrayReduceFromValue<GenericReduceFrom> | (IsEqual<GenericExit, ArrayReduceExit> extends true ? never : GenericExit["-exit"]);
|
|
27
30
|
export {};
|
package/dist/array/reduce.mjs
CHANGED
|
@@ -1,30 +1,42 @@
|
|
|
1
1
|
import { createKind } from '../common/kind.mjs';
|
|
2
2
|
import { wrapValue } from '../common/wrapValue.mjs';
|
|
3
3
|
import { unwrap } from '../common/unwrap.mjs';
|
|
4
|
+
import { push } from './push.mjs';
|
|
4
5
|
import { override } from '../object/override.mjs';
|
|
5
6
|
|
|
6
7
|
const arrayReduceFromKind = createKind("array-reduce-from");
|
|
7
8
|
function reduceFrom(value) {
|
|
8
9
|
return arrayReduceFromKind.setTo(wrapValue(value));
|
|
9
10
|
}
|
|
11
|
+
const reduceTools = {
|
|
12
|
+
exit(output) {
|
|
13
|
+
return { "-exit": output };
|
|
14
|
+
},
|
|
15
|
+
next(output) {
|
|
16
|
+
return { "-next": output };
|
|
17
|
+
},
|
|
18
|
+
nextWithObject(object1, object2) {
|
|
19
|
+
return { "-next": override(object1, object2) };
|
|
20
|
+
},
|
|
21
|
+
nextPush(array, ...[value, ...values]) {
|
|
22
|
+
return { "-next": push(array, value, ...values) };
|
|
23
|
+
},
|
|
24
|
+
};
|
|
10
25
|
function reduce(...args) {
|
|
11
26
|
if (args.length === 2) {
|
|
12
27
|
const [fromValue, theFunction] = args;
|
|
13
|
-
return (
|
|
28
|
+
return (input) => reduce(input, fromValue, theFunction);
|
|
14
29
|
}
|
|
15
|
-
const [
|
|
30
|
+
const [input, fromValue, theFunction] = args;
|
|
16
31
|
let lastValue = unwrap(fromValue);
|
|
17
|
-
for (let index = 0; index <
|
|
18
|
-
const element =
|
|
32
|
+
for (let index = 0; index < input.length; index++) {
|
|
33
|
+
const element = input[index];
|
|
19
34
|
const result = theFunction({
|
|
20
35
|
element,
|
|
21
36
|
index,
|
|
22
37
|
lastValue,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})),
|
|
26
|
-
exit: (output) => ({ "-exit": output }),
|
|
27
|
-
next: (output) => ({ "-next": output }),
|
|
38
|
+
self: input,
|
|
39
|
+
...reduceTools,
|
|
28
40
|
});
|
|
29
41
|
if ("-exit" in result) {
|
|
30
42
|
return result["-exit"];
|
|
@@ -34,4 +46,4 @@ function reduce(...args) {
|
|
|
34
46
|
return lastValue;
|
|
35
47
|
}
|
|
36
48
|
|
|
37
|
-
export { reduce, reduceFrom };
|
|
49
|
+
export { reduce, reduceFrom, reduceTools };
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var unwrap = require('../common/unwrap.cjs');
|
|
4
|
-
var
|
|
4
|
+
var reduce = require('./reduce.cjs');
|
|
5
5
|
|
|
6
6
|
function reduceRight(...args) {
|
|
7
7
|
if (args.length === 2) {
|
|
8
8
|
const [fromValue, theFunction] = args;
|
|
9
|
-
return (
|
|
9
|
+
return (input) => reduceRight(input, fromValue, theFunction);
|
|
10
10
|
}
|
|
11
|
-
const [
|
|
11
|
+
const [input, fromValue, theFunction] = args;
|
|
12
12
|
let lastValue = unwrap.unwrap(fromValue);
|
|
13
|
-
for (let index =
|
|
14
|
-
const element =
|
|
13
|
+
for (let index = input.length - 1; index >= 0; index--) {
|
|
14
|
+
const element = input[index];
|
|
15
15
|
const result = theFunction({
|
|
16
16
|
element,
|
|
17
17
|
index,
|
|
18
18
|
lastValue,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
})),
|
|
22
|
-
exit: (output) => ({ "-exit": output }),
|
|
23
|
-
next: (output) => ({ "-next": output }),
|
|
19
|
+
self: input,
|
|
20
|
+
...reduce.reduceTools,
|
|
24
21
|
});
|
|
25
22
|
if ("-exit" in result) {
|
|
26
23
|
return result["-exit"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ArrayReduceFunctionParams, type ArrayReduceFromResult, type ArrayReduceFromValue, type ArrayReduceExit, type ArrayReduceNext } from "./reduce";
|
|
2
2
|
import { type IsEqual } from "../common";
|
|
3
|
-
export declare function reduceRight<
|
|
4
|
-
export declare function reduceRight<
|
|
3
|
+
export declare function reduceRight<GenericInput extends readonly unknown[], GenericReduceFrom extends number | string | bigint | boolean | ArrayReduceFromResult, GenericExit extends ArrayReduceExit = ArrayReduceExit<never>>(startValue: GenericReduceFrom, theFunction: (params: ArrayReduceFunctionParams<GenericInput, ArrayReduceFromValue<GenericReduceFrom>>) => ArrayReduceNext<ArrayReduceFromValue<GenericReduceFrom>> | GenericExit): (input: GenericInput) => ArrayReduceFromValue<GenericReduceFrom> | (IsEqual<GenericExit, ArrayReduceExit> extends true ? never : GenericExit["-exit"]);
|
|
4
|
+
export declare function reduceRight<GenericInput extends readonly unknown[], GenericReduceFrom extends number | string | bigint | boolean | ArrayReduceFromResult, GenericExit extends ArrayReduceExit = ArrayReduceExit<never>>(input: GenericInput, startValue: GenericReduceFrom, theFunction: (params: ArrayReduceFunctionParams<GenericInput, ArrayReduceFromValue<GenericReduceFrom>>) => ArrayReduceNext<ArrayReduceFromValue<GenericReduceFrom>> | GenericExit): ArrayReduceFromValue<GenericReduceFrom> | (IsEqual<GenericExit, ArrayReduceExit> extends true ? never : GenericExit["-exit"]);
|