@elyukai/utils 0.2.9 → 0.3.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/CHANGELOG.md +13 -0
- package/dist/src/array/transformations.d.ts +27 -0
- package/dist/src/array/transformations.js +34 -0
- package/package.json +2 -2
- package/dist/array/generators.d.ts +0 -13
- package/dist/array/generators.js +0 -17
- /package/dist/{array → src/array}/filters.d.ts +0 -0
- /package/dist/{array → src/array}/filters.js +0 -0
- /package/dist/{array → src/array}/fixed.d.ts +0 -0
- /package/dist/{array → src/array}/fixed.js +0 -0
- /package/dist/{array → src/array}/groups.d.ts +0 -0
- /package/dist/{array → src/array}/groups.js +0 -0
- /package/dist/{array → src/array}/modify.d.ts +0 -0
- /package/dist/{array → src/array}/modify.js +0 -0
- /package/dist/{array → src/array}/nonEmpty.d.ts +0 -0
- /package/dist/{array → src/array}/nonEmpty.js +0 -0
- /package/dist/{array → src/array}/reductions.d.ts +0 -0
- /package/dist/{array → src/array}/reductions.js +0 -0
- /package/dist/{array → src/array}/sets.d.ts +0 -0
- /package/dist/{array → src/array}/sets.js +0 -0
- /package/dist/{async.d.ts → src/async.d.ts} +0 -0
- /package/dist/{async.js → src/async.js} +0 -0
- /package/dist/{classList.d.ts → src/classList.d.ts} +0 -0
- /package/dist/{classList.js → src/classList.js} +0 -0
- /package/dist/{dictionary → src/dictionary}/native.d.ts +0 -0
- /package/dist/{dictionary → src/dictionary}/native.js +0 -0
- /package/dist/{dictionary.d.ts → src/dictionary.d.ts} +0 -0
- /package/dist/{dictionary.js → src/dictionary.js} +0 -0
- /package/dist/{equality.d.ts → src/equality.d.ts} +0 -0
- /package/dist/{equality.js → src/equality.js} +0 -0
- /package/dist/{function.d.ts → src/function.d.ts} +0 -0
- /package/dist/{function.js → src/function.js} +0 -0
- /package/dist/{lazy.d.ts → src/lazy.d.ts} +0 -0
- /package/dist/{lazy.js → src/lazy.js} +0 -0
- /package/dist/{maybe.d.ts → src/maybe.d.ts} +0 -0
- /package/dist/{maybe.js → src/maybe.js} +0 -0
- /package/dist/{nullable.d.ts → src/nullable.d.ts} +0 -0
- /package/dist/{nullable.js → src/nullable.js} +0 -0
- /package/dist/{number.d.ts → src/number.d.ts} +0 -0
- /package/dist/{number.js → src/number.js} +0 -0
- /package/dist/{object.d.ts → src/object.d.ts} +0 -0
- /package/dist/{object.js → src/object.js} +0 -0
- /package/dist/{ordering.d.ts → src/ordering.d.ts} +0 -0
- /package/dist/{ordering.js → src/ordering.js} +0 -0
- /package/dist/{parser.d.ts → src/parser.d.ts} +0 -0
- /package/dist/{parser.js → src/parser.js} +0 -0
- /package/dist/{range.d.ts → src/range.d.ts} +0 -0
- /package/dist/{range.js → src/range.js} +0 -0
- /package/dist/{reader.d.ts → src/reader.d.ts} +0 -0
- /package/dist/{reader.js → src/reader.js} +0 -0
- /package/dist/{result.d.ts → src/result.d.ts} +0 -0
- /package/dist/{result.js → src/result.js} +0 -0
- /package/dist/{roman.d.ts → src/roman.d.ts} +0 -0
- /package/dist/{roman.js → src/roman.js} +0 -0
- /package/dist/{state.d.ts → src/state.d.ts} +0 -0
- /package/dist/{state.js → src/state.js} +0 -0
- /package/dist/{stateParser.d.ts → src/stateParser.d.ts} +0 -0
- /package/dist/{stateParser.js → src/stateParser.js} +0 -0
- /package/dist/{string → src/string}/number.d.ts +0 -0
- /package/dist/{string → src/string}/number.js +0 -0
- /package/dist/{string → src/string}/regex.d.ts +0 -0
- /package/dist/{string → src/string}/regex.js +0 -0
- /package/dist/{string.d.ts → src/string.d.ts} +0 -0
- /package/dist/{string.js → src/string.js} +0 -0
- /package/dist/{typeSafety.d.ts → src/typeSafety.d.ts} +0 -0
- /package/dist/{typeSafety.js → src/typeSafety.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [0.3.0](https://github.com/elyukai/ts-utils/compare/v0.2.9...v0.3.0) (2026-03-06)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* intersperse as old intercalate
|
|
11
|
+
* add array intercalate and rename module
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add array intercalate and rename module ([2495638](https://github.com/elyukai/ts-utils/commit/24956389cb0fe6e867a985ab760d295cced4ba6b))
|
|
16
|
+
* intersperse as old intercalate ([2d39540](https://github.com/elyukai/ts-utils/commit/2d39540f502415f7db4d5e9227aaab4802e16148))
|
|
17
|
+
|
|
5
18
|
## [0.2.9](https://github.com/elyukai/ts-utils/compare/v0.2.8...v0.2.9) (2026-03-02)
|
|
6
19
|
|
|
7
20
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for transforming arrays.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Returns a new array with the given value interspersed between each element of the given array. An empty array is returned if the given array is empty.
|
|
7
|
+
* @param arr The array to intersperse.
|
|
8
|
+
* @param value The value to intersperse between each element of the array.
|
|
9
|
+
* @returns A new array with the given value interspersed between each element of the given array.
|
|
10
|
+
*/
|
|
11
|
+
export declare const intersperse: <T>(arr: T[], value: T) => T[];
|
|
12
|
+
/**
|
|
13
|
+
* Returns a new array with the given values intercalated between each element of the given array. An empty array is returned if the given array is empty.
|
|
14
|
+
* @param arr The array to intercalate.
|
|
15
|
+
* @param values The values to intercalate between each element of the array.
|
|
16
|
+
* @returns A new array with the given values intercalated between each element of the given array.
|
|
17
|
+
*/
|
|
18
|
+
export declare const intercalate: <T>(arr: T[][], values: T[]) => T[];
|
|
19
|
+
/**
|
|
20
|
+
* Returns the possibilities of all the combinations of nested array values.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* flatCombine([["a", "b"], ["c"]]) // [["a", "c"], ["b", "c"]]
|
|
25
|
+
* flatCombine([["a", "b"], ["c", "d"]]) // [["a", "c"], ["b", "c"], ["a", "d"], ["b", "d"]]
|
|
26
|
+
*/
|
|
27
|
+
export declare const flatCombine: <T>(arr: T[][]) => T[][];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for transforming arrays.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import { isNotEmpty } from "./nonEmpty.js";
|
|
6
|
+
/**
|
|
7
|
+
* Returns a new array with the given value interspersed between each element of the given array. An empty array is returned if the given array is empty.
|
|
8
|
+
* @param arr The array to intersperse.
|
|
9
|
+
* @param value The value to intersperse between each element of the array.
|
|
10
|
+
* @returns A new array with the given value interspersed between each element of the given array.
|
|
11
|
+
*/
|
|
12
|
+
export const intersperse = (arr, value) => !isNotEmpty(arr) ? [] : arr.slice(1).reduce((acc, elem) => [...acc, value, elem], [arr[0]]);
|
|
13
|
+
/**
|
|
14
|
+
* Returns a new array with the given values intercalated between each element of the given array. An empty array is returned if the given array is empty.
|
|
15
|
+
* @param arr The array to intercalate.
|
|
16
|
+
* @param values The values to intercalate between each element of the array.
|
|
17
|
+
* @returns A new array with the given values intercalated between each element of the given array.
|
|
18
|
+
*/
|
|
19
|
+
export const intercalate = (arr, values) => !isNotEmpty(arr)
|
|
20
|
+
? []
|
|
21
|
+
: arr.slice(1).reduce((acc, elem) => [...acc, ...values, ...elem], arr[0]);
|
|
22
|
+
/**
|
|
23
|
+
* Returns the possibilities of all the combinations of nested array values.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
*
|
|
27
|
+
* flatCombine([["a", "b"], ["c"]]) // [["a", "c"], ["b", "c"]]
|
|
28
|
+
* flatCombine([["a", "b"], ["c", "d"]]) // [["a", "c"], ["b", "c"], ["a", "d"], ["b", "d"]]
|
|
29
|
+
*/
|
|
30
|
+
export const flatCombine = (arr) => arr.length === 0
|
|
31
|
+
? []
|
|
32
|
+
: arr.slice(1).reduce((acc, elem) => elem.flatMap(elemInner => acc.map(accElem => [...accElem, elemInner])),
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- it is checked before if the array is empty
|
|
34
|
+
arr[0].map(elem => [elem]));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elyukai/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A set of JavaScript helper functions.",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"CHANGELOG.md"
|
|
10
10
|
],
|
|
11
11
|
"exports": {
|
|
12
|
-
"./*": "./dist/*.js"
|
|
12
|
+
"./*": "./dist/src/*.js"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "tsc -b",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for generating new arrays.
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Returns the possibilities of all the combinations of nested array values.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
*
|
|
10
|
-
* flatCombine([["a", "b"], ["c"]]) // [["a", "c"], ["b", "c"]]
|
|
11
|
-
* flatCombine([["a", "b"], ["c", "d"]]) // [["a", "c"], ["b", "c"], ["a", "d"], ["b", "d"]]
|
|
12
|
-
*/
|
|
13
|
-
export declare const flatCombine: <T>(arr: T[][]) => T[][];
|
package/dist/array/generators.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for generating new arrays.
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Returns the possibilities of all the combinations of nested array values.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
*
|
|
10
|
-
* flatCombine([["a", "b"], ["c"]]) // [["a", "c"], ["b", "c"]]
|
|
11
|
-
* flatCombine([["a", "b"], ["c", "d"]]) // [["a", "c"], ["b", "c"], ["a", "d"], ["b", "d"]]
|
|
12
|
-
*/
|
|
13
|
-
export const flatCombine = (arr) => arr.length === 0
|
|
14
|
-
? []
|
|
15
|
-
: arr.slice(1).reduce((acc, elem) => elem.flatMap(elemInner => acc.map(accElem => [...accElem, elemInner])),
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- it is checked before if the array is empty
|
|
17
|
-
arr[0].map(elem => [elem]));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|