@tsdotnet/array-utility 1.0.28 → 1.0.30
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/cjs/arrayUtility.js +21 -122
- package/dist/cjs/arrayUtility.js.map +1 -1
- package/dist/esm/arrayUtility.js +47 -145
- package/dist/esm/arrayUtility.js.map +1 -1
- package/dist/types/arrayUtility.d.ts +30 -0
- package/package.json +27 -37
- package/rollup.config.js +36 -0
- package/dist/arrayUtility.d.ts +0 -138
- package/dist/umd/arrayUtility.js +0 -340
- package/dist/umd/arrayUtility.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrayUtility.js","
|
|
1
|
+
{"version":3,"file":"arrayUtility.js","sources":["../../../src/arrayUtility.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;AAAA;;;AAGG;AAoBH,MACC,GAAG,GAAI,iBAAiB,EACxB,GAAG,GAAI,iBAAiB,EACxB,IAAI,GAAG,2BAA2B,EAClC,GAAG,GAAI,+BAA+B;AAUjC,SAAU,OAAO,CACtB,KAAmB,EACnB,IAAO,EACP,mBAA0C,QAAQ,EAAA;AAGlD,IAAA,MAAM,GAAG,GAAG,KAAK,IAAI,KAAK,CAAC,MAAM;IACjC,IAAG,GAAG,EACN;AAEC,QAAA,IAAG,gBAAgB,KAAG,QAAQ,IAAI,KAAK,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;AAChF,YAAA,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAE3B,QAAA,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAC,GAAG,EAAE,CAAC,EAAE,EACzB;AACC,YAAA,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;YAExB,IAAG,OAAO,KAAK,SAAS,IAAI,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC;AAAE,gBAAA,OAAO,CAAC;QACtE;IAC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I,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAC9D;SASgB,OAAO,CACtB,CAAQ,EACR,eAAuB,CAAC,EAAA;IAGxB,MAAM,MAAM,GAAU,EAAE;AACxB,IAAA,KAAI,IAAI,CAAC,IAAI,CAAC,EACd;AACC,QAAA,IAAG,CAAC,YAAY,KAAK,EACrB;YACC,IAAG,YAAY,GAAC,CAAC;gBAAE,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC;YACnD,KAAI,MAAM,CAAC,IAAI,CAAC;AAAE,gBAAA,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC;;AACK,YAAA,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACpB;AACA,IAAA,OAAO,MAAM;AACd;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @author electricessence / https://github.com/electricessence/
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
import { ActionWithIndex, PredicateWithIndex, SelectorWithIndex } from '@tsdotnet/common-interfaces';
|
|
6
|
+
import init from '@tsdotnet/array-init';
|
|
7
|
+
import copy, { arrayCopyTo as copyTo } from '@tsdotnet/array-copy';
|
|
8
|
+
import { EqualityComparison } from '@tsdotnet/compare';
|
|
9
|
+
export { init, copy, copyTo };
|
|
10
|
+
export interface ArrayLikeWritable<T> {
|
|
11
|
+
length: number;
|
|
12
|
+
[n: number]: T;
|
|
13
|
+
}
|
|
14
|
+
export declare function indexOf<T>(array: ArrayLike<T>, item: T, equalityComparer?: EqualityComparison<T>): number;
|
|
15
|
+
export declare function contains<T>(array: ArrayLike<T>, item: T, equalityComparer?: EqualityComparison<T>): boolean;
|
|
16
|
+
export declare function replace<T>(array: ArrayLikeWritable<T>, old: T, newValue: T, max?: number): number;
|
|
17
|
+
export declare function updateRange<T>(array: ArrayLike<T>, value: T, start?: number, stop?: number): void;
|
|
18
|
+
export declare function clearEach(array: ArrayLikeWritable<any>, start?: number, stop?: number): void;
|
|
19
|
+
export declare function register<T>(array: ArrayLikeWritable<T>, item: T, equalityComparer?: EqualityComparison<T>): boolean;
|
|
20
|
+
export declare function findIndex<T>(array: ArrayLike<T>, predicate: PredicateWithIndex<T>): number;
|
|
21
|
+
export declare function forEach<T>(source: ArrayLike<T>, action: ActionWithIndex<T> | PredicateWithIndex<T>): void;
|
|
22
|
+
export declare function applyTo<T>(target: ArrayLikeWritable<T>, fn: SelectorWithIndex<T, T>): void;
|
|
23
|
+
export declare function removeIndex<T>(array: T[], index: number): boolean;
|
|
24
|
+
export declare function remove<T>(array: T[], value: T, max?: number, equalityComparer?: EqualityComparison<T>): number;
|
|
25
|
+
export declare function repeat<T>(element: T, count: number): T[];
|
|
26
|
+
export declare function range(first: number, count: number, step?: number): number[];
|
|
27
|
+
export declare function rangeUntil(first: number, until: number, step?: number): number[];
|
|
28
|
+
export declare function distinct(source: string[] | null): string[];
|
|
29
|
+
export declare function distinct(source: number[] | null): number[];
|
|
30
|
+
export declare function flatten(a: any[], recurseDepth?: number): any[];
|
package/package.json
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsdotnet/array-utility",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"description": "A small collection of useful array functions.",
|
|
5
5
|
"author": "electricessence",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
10
|
+
"types": "./dist/types/arrayUtility.d.ts",
|
|
9
11
|
"import": "./dist/esm/arrayUtility.js",
|
|
10
|
-
"require": "./dist/cjs/arrayUtility.js"
|
|
11
|
-
"types": "./dist/arrayUtility.d.ts"
|
|
12
|
+
"require": "./dist/cjs/arrayUtility.js"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
|
-
"types": "dist/arrayUtility.d.ts",
|
|
15
|
-
"main": "dist/cjs/arrayUtility.js",
|
|
16
|
-
"module": "dist/esm/arrayUtility.js",
|
|
17
|
-
"umd:main": "dist/umd/arrayUtility.js",
|
|
18
|
-
"unpkg": "dist/umd/arrayUtility.js",
|
|
19
|
-
"jsdelivr": "dist/umd/arrayUtility.js",
|
|
15
|
+
"types": "./dist/types/arrayUtility.d.ts",
|
|
20
16
|
"keywords": [
|
|
21
17
|
"array",
|
|
22
18
|
"indexOf",
|
|
@@ -41,20 +37,19 @@
|
|
|
41
37
|
],
|
|
42
38
|
"scripts": {
|
|
43
39
|
"clean": "rimraf dist",
|
|
40
|
+
"build:types": "cpy \"src/**/*.d.ts\" dist/types --parents && tsc -p tsconfig.types.json",
|
|
41
|
+
"build:esm": "rollup -c rollup.config.js",
|
|
44
42
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
45
|
-
"build
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"build": "pnpm i && pnpm run clean && concurrently \"pnpm:build:*\"",
|
|
49
|
-
"bump": "pnpm run precommit && pnpm version patch",
|
|
50
|
-
"docs": "rimraf docs && typedoc --options typedoc.json --readme none",
|
|
43
|
+
"build": "pnpm clean && pnpm build:types && pnpm build:esm && pnpm build:cjs",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
51
46
|
"lint": "eslint src/**/*.ts",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
47
|
+
"docs": "rimraf docs && typedoc --options typedoc.json --readme none",
|
|
48
|
+
"bump": "pnpm run precommit && pnpm version patch",
|
|
49
|
+
"precommit": "pnpm build && pnpm test && pnpm lint && git status -s",
|
|
50
|
+
"preversion": "pnpm lint && pnpm test",
|
|
55
51
|
"postversion": "git push && git push --tags && pnpm run docs && git add -A && git commit -m \"Updated docs.\" docs && git push",
|
|
56
|
-
"
|
|
57
|
-
"validate": "node ./.build/validate-package.js"
|
|
52
|
+
"prepublishOnly": "pnpm build && pnpm test && pnpm lint"
|
|
58
53
|
},
|
|
59
54
|
"repository": {
|
|
60
55
|
"type": "git",
|
|
@@ -66,42 +61,37 @@
|
|
|
66
61
|
"homepage": "https://github.com/tsdotnet/array-utility#readme",
|
|
67
62
|
"devDependencies": {
|
|
68
63
|
"@eslint/js": "^9.33.0",
|
|
69
|
-
"@
|
|
70
|
-
"@types/chai": "^5.2.2",
|
|
71
|
-
"@types/mocha": "^10.0.10",
|
|
64
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
72
65
|
"@types/node": "^24.3.0",
|
|
73
|
-
"chai": "^5.2.1",
|
|
74
|
-
"concurrently": "^9.2.0",
|
|
75
66
|
"cpy-cli": "^6.0.0",
|
|
76
67
|
"eslint": "^9.33.0",
|
|
77
|
-
"mocha": "^11.7.1",
|
|
78
68
|
"rimraf": "^6.0.1",
|
|
79
|
-
"
|
|
69
|
+
"rollup": "^4.46.3",
|
|
80
70
|
"typedoc": "^0.28.10",
|
|
81
71
|
"typescript": "^5.9.2",
|
|
82
|
-
"typescript-eslint": "^8.39.1"
|
|
72
|
+
"typescript-eslint": "^8.39.1",
|
|
73
|
+
"vitest": "^3.2.4"
|
|
83
74
|
},
|
|
84
75
|
"dependencies": {
|
|
85
76
|
"@tsdotnet/array-copy": "^1.2.1",
|
|
86
|
-
"@tsdotnet/array-init": "^1.2.
|
|
87
|
-
"@tsdotnet/
|
|
88
|
-
"@tsdotnet/
|
|
89
|
-
"@tsdotnet/
|
|
90
|
-
"@tsdotnet/
|
|
77
|
+
"@tsdotnet/array-init": "^1.2.2",
|
|
78
|
+
"@tsdotnet/common-interfaces": "^1.0.5",
|
|
79
|
+
"@tsdotnet/compare": "^1.5.4",
|
|
80
|
+
"@tsdotnet/exceptions": "^1.2.4",
|
|
81
|
+
"@tsdotnet/integer": "^1.2.3",
|
|
82
|
+
"@tsdotnet/type": "^1.2.4",
|
|
91
83
|
"tslib": "^2.8.1"
|
|
92
84
|
},
|
|
93
85
|
"pnpm": {
|
|
94
86
|
"overrides": {
|
|
95
|
-
"path-parse@<1.0.7": ">=1.0.7",
|
|
96
87
|
"hosted-git-info@<2.8.9": ">=2.8.9",
|
|
97
88
|
"y18n@=4.0.0": ">=4.0.1",
|
|
98
89
|
"lodash@<4.17.20": ">=4.17.20",
|
|
99
90
|
"shell-quote@<=1.7.2": ">=1.7.3",
|
|
100
91
|
"lodash@<4.17.21": ">=4.17.21",
|
|
92
|
+
"json5@<1.0.2": ">=1.0.2",
|
|
101
93
|
"json5@>=2.0.0 <2.2.2": ">=2.2.2",
|
|
102
94
|
"minimatch@<3.0.5": ">=3.0.5",
|
|
103
|
-
"word-wrap@<1.2.4": ">=1.2.4",
|
|
104
|
-
"minimist@>=1.0.0 <1.2.6": ">=1.2.6",
|
|
105
95
|
"semver@<5.7.2": ">=5.7.2",
|
|
106
96
|
"semver@>=6.0.0 <6.3.1": ">=6.3.1",
|
|
107
97
|
"semver@>=7.0.0 <7.5.2": ">=7.5.2",
|
|
@@ -109,7 +99,7 @@
|
|
|
109
99
|
"@babel/traverse@<7.23.2": ">=7.23.2",
|
|
110
100
|
"braces@<3.0.3": ">=3.0.3"
|
|
111
101
|
},
|
|
112
|
-
"
|
|
102
|
+
"ignoredBuiltDependencies": [
|
|
113
103
|
"esbuild"
|
|
114
104
|
]
|
|
115
105
|
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { defineConfig } from 'rollup';
|
|
2
|
+
import typescript from '@rollup/plugin-typescript';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
|
|
5
|
+
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url)));
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
input: 'src/arrayUtility.ts', // Just use the main entry point
|
|
9
|
+
output: {
|
|
10
|
+
dir: 'dist/esm',
|
|
11
|
+
format: 'es',
|
|
12
|
+
preserveModules: true, // This will automatically include all imported files!
|
|
13
|
+
preserveModulesRoot: 'src',
|
|
14
|
+
entryFileNames: '[name].js',
|
|
15
|
+
sourcemap: true
|
|
16
|
+
},
|
|
17
|
+
external: [
|
|
18
|
+
// Node core modules
|
|
19
|
+
/^node:/,
|
|
20
|
+
// All dependencies and peer dependencies
|
|
21
|
+
...Object.keys(pkg.dependencies || {}),
|
|
22
|
+
...Object.keys(pkg.peerDependencies || {})
|
|
23
|
+
],
|
|
24
|
+
plugins: [
|
|
25
|
+
typescript({
|
|
26
|
+
tsconfig: './tsconfig.esm.json',
|
|
27
|
+
declaration: false, // Keep your existing types build
|
|
28
|
+
declarationMap: false,
|
|
29
|
+
sourceMap: true,
|
|
30
|
+
removeComments: true // Explicitly remove source comments
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
package/dist/arrayUtility.d.ts
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* @author electricessence / https://github.com/electricessence/
|
|
3
|
-
* @license MIT
|
|
4
|
-
*/
|
|
5
|
-
import { ActionWithIndex, PredicateWithIndex, SelectorWithIndex } from '@tsdotnet/common-interfaces';
|
|
6
|
-
import init from '@tsdotnet/array-init';
|
|
7
|
-
import copy, { arrayCopyTo as copyTo } from '@tsdotnet/array-copy';
|
|
8
|
-
import { EqualityComparison } from '@tsdotnet/compare';
|
|
9
|
-
export { init, copy, copyTo };
|
|
10
|
-
export interface ArrayLikeWritable<T> {
|
|
11
|
-
length: number;
|
|
12
|
-
[n: number]: T;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Checks to see where the provided array contains an item/value.
|
|
16
|
-
* If the array value is null, then -1 is returned.
|
|
17
|
-
* @param array
|
|
18
|
-
* @param item
|
|
19
|
-
* @param {function?} equalityComparer
|
|
20
|
-
* @returns {number}
|
|
21
|
-
*/
|
|
22
|
-
export declare function indexOf<T>(array: ArrayLike<T>, item: T, equalityComparer?: EqualityComparison<T>): number;
|
|
23
|
-
/**
|
|
24
|
-
* Checks to see if the provided array contains an item.
|
|
25
|
-
* If the array value is null, then false is returned.
|
|
26
|
-
* @param array
|
|
27
|
-
* @param item
|
|
28
|
-
* @param {function?} equalityComparer
|
|
29
|
-
* @returns {boolean}
|
|
30
|
-
*/
|
|
31
|
-
export declare function contains<T>(array: ArrayLike<T>, item: T, equalityComparer?: EqualityComparison<T>): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Finds and replaces a value from an array. Will replaces all instances unless a maximum is specified.
|
|
34
|
-
* @param array
|
|
35
|
-
* @param old
|
|
36
|
-
* @param newValue
|
|
37
|
-
* @param max
|
|
38
|
-
* @returns {number}
|
|
39
|
-
*/
|
|
40
|
-
export declare function replace<T>(array: ArrayLikeWritable<T>, old: T, newValue: T, max?: number): number;
|
|
41
|
-
/**
|
|
42
|
-
* Replaces values of an array across a range of indexes.
|
|
43
|
-
* @param array
|
|
44
|
-
* @param value
|
|
45
|
-
* @param start
|
|
46
|
-
* @param stop
|
|
47
|
-
*/
|
|
48
|
-
export declare function updateRange<T>(array: ArrayLike<T>, value: T, start?: number, stop?: number): void;
|
|
49
|
-
/**
|
|
50
|
-
* Clears (sets to null) values of an array across a range of indexes.
|
|
51
|
-
* @param array
|
|
52
|
-
* @param start
|
|
53
|
-
* @param stop
|
|
54
|
-
*/
|
|
55
|
-
export declare function clearEach(array: ArrayLikeWritable<any>, start?: number, stop?: number): void;
|
|
56
|
-
/**
|
|
57
|
-
* Ensures a value exists within an array. If not found, adds to the end.
|
|
58
|
-
* @param array
|
|
59
|
-
* @param item
|
|
60
|
-
* @param {function?} equalityComparer
|
|
61
|
-
* @returns {boolean}
|
|
62
|
-
*/
|
|
63
|
-
export declare function register<T>(array: ArrayLikeWritable<T>, item: T, equalityComparer?: EqualityComparison<T>): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Returns the first index of which the provided predicate returns true.
|
|
66
|
-
* Returns -1 if always false.
|
|
67
|
-
* @param array
|
|
68
|
-
* @param predicate
|
|
69
|
-
* @returns {number}
|
|
70
|
-
*/
|
|
71
|
-
export declare function findIndex<T>(array: ArrayLike<T>, predicate: PredicateWithIndex<T>): number;
|
|
72
|
-
/**
|
|
73
|
-
* Allows for using "false" to cause forEach to break.
|
|
74
|
-
* Can also be applied to a structure that indexes like an array, but may not be.
|
|
75
|
-
* @param source
|
|
76
|
-
* @param action
|
|
77
|
-
*/
|
|
78
|
-
export declare function forEach<T>(source: ArrayLike<T>, action: ActionWithIndex<T> | PredicateWithIndex<T>): void;
|
|
79
|
-
/**
|
|
80
|
-
* Is similar to Array.map() but instead of returning a new array, it updates the existing indexes.
|
|
81
|
-
* Can also be applied to a structure that indexes like an array, but may not be.
|
|
82
|
-
* @param target
|
|
83
|
-
* @param fn
|
|
84
|
-
*/
|
|
85
|
-
export declare function applyTo<T>(target: ArrayLikeWritable<T>, fn: SelectorWithIndex<T, T>): void;
|
|
86
|
-
/**
|
|
87
|
-
* Removes an entry at a specified index.
|
|
88
|
-
* @param array
|
|
89
|
-
* @param index
|
|
90
|
-
* @returns {boolean} True if the value was able to be removed.
|
|
91
|
-
*/
|
|
92
|
-
export declare function removeIndex<T>(array: T[], index: number): boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Finds and removes a value from an array. Will remove all instances unless a maximum is specified.
|
|
95
|
-
* @param array
|
|
96
|
-
* @param value
|
|
97
|
-
* @param max
|
|
98
|
-
* @param {function?} equalityComparer
|
|
99
|
-
* @returns {number} The number of times the value was found and removed.
|
|
100
|
-
*/
|
|
101
|
-
export declare function remove<T>(array: T[], value: T, max?: number, equalityComparer?: EqualityComparison<T>): number;
|
|
102
|
-
/**
|
|
103
|
-
* Simply repeats a value the number of times specified.
|
|
104
|
-
* @param element
|
|
105
|
-
* @param count
|
|
106
|
-
* @returns {T[]}
|
|
107
|
-
*/
|
|
108
|
-
export declare function repeat<T>(element: T, count: number): T[];
|
|
109
|
-
/**
|
|
110
|
-
* Returns a range of numbers based upon the first value and the step value.
|
|
111
|
-
* @param first
|
|
112
|
-
* @param count
|
|
113
|
-
* @param step
|
|
114
|
-
* @returns {number[]}
|
|
115
|
-
*/
|
|
116
|
-
export declare function range(first: number, count: number, step?: number): number[];
|
|
117
|
-
/**
|
|
118
|
-
* Returns a range of numbers based upon the first value and the step value excluding any numbers at or beyond the until value.
|
|
119
|
-
* @param first
|
|
120
|
-
* @param until
|
|
121
|
-
* @param step
|
|
122
|
-
* @returns {number[]}
|
|
123
|
-
*/
|
|
124
|
-
export declare function rangeUntil(first: number, until: number, step?: number): number[];
|
|
125
|
-
/**
|
|
126
|
-
* Returns a unique reduced set of values.
|
|
127
|
-
* @param source
|
|
128
|
-
*/
|
|
129
|
-
export declare function distinct(source: string[] | null): string[];
|
|
130
|
-
export declare function distinct(source: number[] | null): number[];
|
|
131
|
-
/**
|
|
132
|
-
* Takes any arrays within an array and inserts the values contained within in place of that array.
|
|
133
|
-
* For every count higher than 0 in recurseDepth it will attempt an additional pass. Passing Infinity will flatten all arrays contained.
|
|
134
|
-
* @param a
|
|
135
|
-
* @param recurseDepth
|
|
136
|
-
* @returns {any[]}
|
|
137
|
-
*/
|
|
138
|
-
export declare function flatten(a: any[], recurseDepth?: number): any[];
|