@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
package/dist/cjs/arrayUtility.js
CHANGED
|
@@ -32,54 +32,29 @@ Object.defineProperty(exports, "copyTo", { enumerable: true, get: function () {
|
|
|
32
32
|
const integer_1 = tslib_1.__importDefault(require("@tsdotnet/integer"));
|
|
33
33
|
const compare_1 = require("@tsdotnet/compare");
|
|
34
34
|
const CBN = 'Cannot be null.', CB0 = 'Cannot be zero.', CBL0 = 'Cannot be less than zero.', VFN = 'Must be a valid finite number';
|
|
35
|
-
/**
|
|
36
|
-
* Checks to see where the provided array contains an item/value.
|
|
37
|
-
* If the array value is null, then -1 is returned.
|
|
38
|
-
* @param array
|
|
39
|
-
* @param item
|
|
40
|
-
* @param {function?} equalityComparer
|
|
41
|
-
* @returns {number}
|
|
42
|
-
*/
|
|
43
35
|
function indexOf(array, item, equalityComparer = compare_1.areEqual) {
|
|
44
36
|
const len = array && array.length;
|
|
45
37
|
if (len) {
|
|
46
|
-
// NaN NEVER evaluates its equality so be careful.
|
|
47
38
|
if (equalityComparer === compare_1.areEqual && array instanceof Array && !type_1.default.isTrueNaN(item))
|
|
48
39
|
return array.indexOf(item);
|
|
49
40
|
for (let i = 0; i < len; i++) {
|
|
50
|
-
|
|
51
|
-
if (equalityComparer(
|
|
41
|
+
const element = array[i];
|
|
42
|
+
if (element !== undefined && equalityComparer(element, item))
|
|
52
43
|
return i;
|
|
53
44
|
}
|
|
54
45
|
}
|
|
55
46
|
return -1;
|
|
56
47
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Checks to see if the provided array contains an item.
|
|
59
|
-
* If the array value is null, then false is returned.
|
|
60
|
-
* @param array
|
|
61
|
-
* @param item
|
|
62
|
-
* @param {function?} equalityComparer
|
|
63
|
-
* @returns {boolean}
|
|
64
|
-
*/
|
|
65
48
|
function contains(array, item, equalityComparer = compare_1.areEqual) {
|
|
66
49
|
return indexOf(array, item, equalityComparer) !== -1;
|
|
67
50
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Finds and replaces a value from an array. Will replaces all instances unless a maximum is specified.
|
|
70
|
-
* @param array
|
|
71
|
-
* @param old
|
|
72
|
-
* @param newValue
|
|
73
|
-
* @param max
|
|
74
|
-
* @returns {number}
|
|
75
|
-
*/
|
|
76
51
|
function replace(array, old, newValue, max = Infinity) {
|
|
77
52
|
if (!array || !array.length || max === 0)
|
|
78
53
|
return 0;
|
|
79
54
|
if (max < 0)
|
|
80
55
|
throw new exceptions_1.ArgumentOutOfRangeException('max', max, CBL0);
|
|
81
56
|
if (!max)
|
|
82
|
-
max = Infinity;
|
|
57
|
+
max = Infinity;
|
|
83
58
|
let count = 0;
|
|
84
59
|
for (let i = 0, len = array.length; i < len; i++) {
|
|
85
60
|
if (array[i] === old) {
|
|
@@ -91,13 +66,6 @@ function replace(array, old, newValue, max = Infinity) {
|
|
|
91
66
|
}
|
|
92
67
|
return count;
|
|
93
68
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Replaces values of an array across a range of indexes.
|
|
96
|
-
* @param array
|
|
97
|
-
* @param value
|
|
98
|
-
* @param start
|
|
99
|
-
* @param stop
|
|
100
|
-
*/
|
|
101
69
|
function updateRange(array, value, start = 0, stop) {
|
|
102
70
|
if (!array)
|
|
103
71
|
return;
|
|
@@ -111,38 +79,18 @@ function updateRange(array, value, start = 0, stop) {
|
|
|
111
79
|
array[i] = value;
|
|
112
80
|
}
|
|
113
81
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Clears (sets to null) values of an array across a range of indexes.
|
|
116
|
-
* @param array
|
|
117
|
-
* @param start
|
|
118
|
-
* @param stop
|
|
119
|
-
*/
|
|
120
82
|
function clearEach(array, start = 0, stop) {
|
|
121
83
|
updateRange(array, null, start, stop);
|
|
122
84
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Ensures a value exists within an array. If not found, adds to the end.
|
|
125
|
-
* @param array
|
|
126
|
-
* @param item
|
|
127
|
-
* @param {function?} equalityComparer
|
|
128
|
-
* @returns {boolean}
|
|
129
|
-
*/
|
|
130
85
|
function register(array, item, equalityComparer = compare_1.areEqual) {
|
|
131
86
|
if (!array)
|
|
132
87
|
throw new exceptions_1.ArgumentNullException('array', CBN);
|
|
133
|
-
const len = array.length;
|
|
88
|
+
const len = array.length;
|
|
134
89
|
const ok = !len || !contains(array, item, equalityComparer);
|
|
135
90
|
if (ok)
|
|
136
|
-
array[len] = item;
|
|
91
|
+
array[len] = item;
|
|
137
92
|
return ok;
|
|
138
93
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Returns the first index of which the provided predicate returns true.
|
|
141
|
-
* Returns -1 if always false.
|
|
142
|
-
* @param array
|
|
143
|
-
* @param predicate
|
|
144
|
-
* @returns {number}
|
|
145
|
-
*/
|
|
146
94
|
function findIndex(array, predicate) {
|
|
147
95
|
if (!array)
|
|
148
96
|
throw new exceptions_1.ArgumentNullException('array', CBN);
|
|
@@ -159,47 +107,31 @@ function findIndex(array, predicate) {
|
|
|
159
107
|
}
|
|
160
108
|
else {
|
|
161
109
|
for (let i = 0; i < len; i++) {
|
|
162
|
-
|
|
110
|
+
const element = array[i];
|
|
111
|
+
if (i in array && element !== undefined && predicate(element, i))
|
|
163
112
|
return i;
|
|
164
113
|
}
|
|
165
114
|
}
|
|
166
115
|
return -1;
|
|
167
116
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Allows for using "false" to cause forEach to break.
|
|
170
|
-
* Can also be applied to a structure that indexes like an array, but may not be.
|
|
171
|
-
* @param source
|
|
172
|
-
* @param action
|
|
173
|
-
*/
|
|
174
117
|
function forEach(source, action) {
|
|
175
118
|
if (source && action != null) {
|
|
176
|
-
// Don't cache the length since it is possible that the underlying array changed.
|
|
177
119
|
for (let i = 0; i < source.length; i++) {
|
|
178
|
-
|
|
179
|
-
if (action(
|
|
120
|
+
const element = source[i];
|
|
121
|
+
if (element !== undefined && action(element, i) === false)
|
|
180
122
|
break;
|
|
181
123
|
}
|
|
182
124
|
}
|
|
183
125
|
}
|
|
184
|
-
/**
|
|
185
|
-
* Is similar to Array.map() but instead of returning a new array, it updates the existing indexes.
|
|
186
|
-
* Can also be applied to a structure that indexes like an array, but may not be.
|
|
187
|
-
* @param target
|
|
188
|
-
* @param fn
|
|
189
|
-
*/
|
|
190
126
|
function applyTo(target, fn) {
|
|
191
127
|
if (target && fn != null) {
|
|
192
128
|
for (let i = 0; i < target.length; i++) {
|
|
193
|
-
|
|
129
|
+
const element = target[i];
|
|
130
|
+
if (element !== undefined)
|
|
131
|
+
target[i] = fn(element, i);
|
|
194
132
|
}
|
|
195
133
|
}
|
|
196
134
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Removes an entry at a specified index.
|
|
199
|
-
* @param array
|
|
200
|
-
* @param index
|
|
201
|
-
* @returns {boolean} True if the value was able to be removed.
|
|
202
|
-
*/
|
|
203
135
|
function removeIndex(array, index) {
|
|
204
136
|
if (!array)
|
|
205
137
|
throw new exceptions_1.ArgumentNullException('array', CBN);
|
|
@@ -211,14 +143,6 @@ function removeIndex(array, index) {
|
|
|
211
143
|
array.splice(index, 1);
|
|
212
144
|
return exists;
|
|
213
145
|
}
|
|
214
|
-
/**
|
|
215
|
-
* Finds and removes a value from an array. Will remove all instances unless a maximum is specified.
|
|
216
|
-
* @param array
|
|
217
|
-
* @param value
|
|
218
|
-
* @param max
|
|
219
|
-
* @param {function?} equalityComparer
|
|
220
|
-
* @returns {number} The number of times the value was found and removed.
|
|
221
|
-
*/
|
|
222
146
|
function remove(array, value, max = Infinity, equalityComparer = compare_1.areEqual) {
|
|
223
147
|
if (!array || !array.length || max === 0)
|
|
224
148
|
return 0;
|
|
@@ -226,19 +150,19 @@ function remove(array, value, max = Infinity, equalityComparer = compare_1.areEq
|
|
|
226
150
|
throw new exceptions_1.ArgumentOutOfRangeException('max', max, CBL0);
|
|
227
151
|
let count = 0;
|
|
228
152
|
if (!max || !isFinite(max)) {
|
|
229
|
-
// Don't track the indexes and remove in reverse.
|
|
230
153
|
for (let i = array.length - 1; i >= 0; i--) {
|
|
231
|
-
|
|
154
|
+
const element = array[i];
|
|
155
|
+
if (element !== undefined && equalityComparer(element, value)) {
|
|
232
156
|
array.splice(i, 1);
|
|
233
157
|
++count;
|
|
234
158
|
}
|
|
235
159
|
}
|
|
236
160
|
}
|
|
237
161
|
else {
|
|
238
|
-
|
|
239
|
-
const found = []; // indexes;
|
|
162
|
+
const found = [];
|
|
240
163
|
for (let i = 0, len = array.length; i < len; i++) {
|
|
241
|
-
|
|
164
|
+
const element = array[i];
|
|
165
|
+
if (element !== undefined && equalityComparer(element, value)) {
|
|
242
166
|
found.push(i);
|
|
243
167
|
++count;
|
|
244
168
|
if (count === max)
|
|
@@ -246,17 +170,13 @@ function remove(array, value, max = Infinity, equalityComparer = compare_1.areEq
|
|
|
246
170
|
}
|
|
247
171
|
}
|
|
248
172
|
for (let i = found.length - 1; i >= 0; i--) {
|
|
249
|
-
|
|
173
|
+
const index = found[i];
|
|
174
|
+
if (index !== undefined)
|
|
175
|
+
array.splice(index, 1);
|
|
250
176
|
}
|
|
251
177
|
}
|
|
252
178
|
return count;
|
|
253
179
|
}
|
|
254
|
-
/**
|
|
255
|
-
* Simply repeats a value the number of times specified.
|
|
256
|
-
* @param element
|
|
257
|
-
* @param count
|
|
258
|
-
* @returns {T[]}
|
|
259
|
-
*/
|
|
260
180
|
function repeat(element, count) {
|
|
261
181
|
integer_1.default.assert(count, 'count');
|
|
262
182
|
if (count < 0)
|
|
@@ -267,13 +187,6 @@ function repeat(element, count) {
|
|
|
267
187
|
}
|
|
268
188
|
return result;
|
|
269
189
|
}
|
|
270
|
-
/**
|
|
271
|
-
* Returns a range of numbers based upon the first value and the step value.
|
|
272
|
-
* @param first
|
|
273
|
-
* @param count
|
|
274
|
-
* @param step
|
|
275
|
-
* @returns {number[]}
|
|
276
|
-
*/
|
|
277
190
|
function range(first, count, step = 1) {
|
|
278
191
|
if (isNaN(first) || !isFinite(first))
|
|
279
192
|
throw new exceptions_1.ArgumentOutOfRangeException('first', first, VFN);
|
|
@@ -288,13 +201,6 @@ function range(first, count, step = 1) {
|
|
|
288
201
|
}
|
|
289
202
|
return result;
|
|
290
203
|
}
|
|
291
|
-
/**
|
|
292
|
-
* Returns a range of numbers based upon the first value and the step value excluding any numbers at or beyond the until value.
|
|
293
|
-
* @param first
|
|
294
|
-
* @param until
|
|
295
|
-
* @param step
|
|
296
|
-
* @returns {number[]}
|
|
297
|
-
*/
|
|
298
204
|
function rangeUntil(first, until, step = 1) {
|
|
299
205
|
if (step === 0)
|
|
300
206
|
throw new exceptions_1.ArgumentOutOfRangeException('step', step, CB0);
|
|
@@ -302,17 +208,10 @@ function rangeUntil(first, until, step = 1) {
|
|
|
302
208
|
}
|
|
303
209
|
function distinct(source) {
|
|
304
210
|
if (!source)
|
|
305
|
-
return [];
|
|
211
|
+
return [];
|
|
306
212
|
const seen = {};
|
|
307
213
|
return source.filter((e) => !(e in seen) && (seen[e] = true));
|
|
308
214
|
}
|
|
309
|
-
/**
|
|
310
|
-
* Takes any arrays within an array and inserts the values contained within in place of that array.
|
|
311
|
-
* For every count higher than 0 in recurseDepth it will attempt an additional pass. Passing Infinity will flatten all arrays contained.
|
|
312
|
-
* @param a
|
|
313
|
-
* @param recurseDepth
|
|
314
|
-
* @returns {any[]}
|
|
315
|
-
*/
|
|
316
215
|
function flatten(a, recurseDepth = 0) {
|
|
317
216
|
const result = [];
|
|
318
217
|
for (let x of a) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrayUtility.js","sourceRoot":"","sources":["../../src/arrayUtility.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAkCH,
|
|
1
|
+
{"version":3,"file":"arrayUtility.js","sourceRoot":"","sources":["../../src/arrayUtility.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAkCH,0BAsBC;AAUD,4BAOC;AAUD,0BAwBC;AASD,kCAiBC;AAQD,8BAOC;AASD,4BAWC;AASD,8BA4BC;AAQD,0BAeC;AAQD,0BAaC;AAQD,kCAaC;AAUD,wBA+CC;AAQD,wBAeC;AASD,sBAkBC;AASD,gCAQC;AAQD,4BAKC;AASD,0BAgBC;;AA7aD,qDAA2G;AAC3G,8EAAwC;AAOhC,eAPD,oBAAI,CAOC;AANZ,kEAAkC;AAClC,2EAAiE;AAKnD,eALP,oBAAI,CAKO;AAAE,uFALS,wBAAM,OAKT;AAJ1B,wEAAwC;AAExC,+CAA2C;AAW3C,MACC,GAAG,GAAI,iBAAiB,EACxB,GAAG,GAAI,iBAAiB,EACxB,IAAI,GAAG,2BAA2B,EAClC,GAAG,GAAI,+BAA+B,CAAC;AAUxC,SAAgB,OAAO,CACtB,KAAmB,EACnB,IAAO,EACP,mBAA0C,kBAAQ;IAGlD,MAAM,GAAG,GAAG,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC;IAClC,IAAG,GAAG,EACN,CAAC;QAEA,IAAG,gBAAgB,KAAG,kBAAQ,IAAI,KAAK,YAAY,KAAK,IAAI,CAAC,cAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAChF,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE5B,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAC,GAAG,EAAE,CAAC,EAAE,EACzB,CAAC;YACA,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAEzB,IAAG,OAAO,KAAK,SAAS,IAAI,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC;g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AAK,GAAG,KAAK,CAAC,GAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC;AAQD,SAAgB,QAAQ,CAAE,MAAoB;IAE7C,IAAG,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACtB,MAAM,IAAI,GAAQ,EAAE,CAAC;IACrB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAC/D,CAAC;AASD,SAAgB,OAAO,CACtB,CAAQ,EACR,eAAuB,CAAC;IAGxB,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,KAAI,IAAI,CAAC,IAAI,CAAC,EACd,CAAC;QACA,IAAG,CAAC,YAAY,KAAK,EACrB,CAAC;YACA,IAAG,YAAY,GAAC,CAAC;gBAAE,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;YACpD,KAAI,MAAM,CAAC,IAAI,CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;;YACI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC"}
|
package/dist/esm/arrayUtility.js
CHANGED
|
@@ -1,63 +1,39 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* @author electricessence / https://github.com/electricessence/
|
|
3
|
-
* @license MIT
|
|
4
|
-
*/
|
|
5
1
|
import { ArgumentOutOfRangeException, ArgumentNullException, ArgumentException } from '@tsdotnet/exceptions';
|
|
6
2
|
import init from '@tsdotnet/array-init';
|
|
3
|
+
export { default as init } from '@tsdotnet/array-init';
|
|
7
4
|
import type from '@tsdotnet/type';
|
|
8
|
-
|
|
5
|
+
export { default as copy, arrayCopyTo as copyTo } from '@tsdotnet/array-copy';
|
|
9
6
|
import integer from '@tsdotnet/integer';
|
|
10
7
|
import { areEqual } from '@tsdotnet/compare';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
* If the array value is null, then -1 is returned.
|
|
16
|
-
* @param array
|
|
17
|
-
* @param item
|
|
18
|
-
* @param {function?} equalityComparer
|
|
19
|
-
* @returns {number}
|
|
8
|
+
|
|
9
|
+
/*!
|
|
10
|
+
* @author electricessence / https://github.com/electricessence/
|
|
11
|
+
* @license MIT
|
|
20
12
|
*/
|
|
21
|
-
|
|
13
|
+
const CBN = 'Cannot be null.', CB0 = 'Cannot be zero.', CBL0 = 'Cannot be less than zero.', VFN = 'Must be a valid finite number';
|
|
14
|
+
function indexOf(array, item, equalityComparer = areEqual) {
|
|
22
15
|
const len = array && array.length;
|
|
23
16
|
if (len) {
|
|
24
|
-
// NaN NEVER evaluates its equality so be careful.
|
|
25
17
|
if (equalityComparer === areEqual && array instanceof Array && !type.isTrueNaN(item))
|
|
26
18
|
return array.indexOf(item);
|
|
27
19
|
for (let i = 0; i < len; i++) {
|
|
28
|
-
|
|
29
|
-
if (equalityComparer(
|
|
20
|
+
const element = array[i];
|
|
21
|
+
if (element !== undefined && equalityComparer(element, item))
|
|
30
22
|
return i;
|
|
31
23
|
}
|
|
32
24
|
}
|
|
33
25
|
return -1;
|
|
34
26
|
}
|
|
35
|
-
|
|
36
|
-
* Checks to see if the provided array contains an item.
|
|
37
|
-
* If the array value is null, then false is returned.
|
|
38
|
-
* @param array
|
|
39
|
-
* @param item
|
|
40
|
-
* @param {function?} equalityComparer
|
|
41
|
-
* @returns {boolean}
|
|
42
|
-
*/
|
|
43
|
-
export function contains(array, item, equalityComparer = areEqual) {
|
|
27
|
+
function contains(array, item, equalityComparer = areEqual) {
|
|
44
28
|
return indexOf(array, item, equalityComparer) !== -1;
|
|
45
29
|
}
|
|
46
|
-
|
|
47
|
-
* Finds and replaces a value from an array. Will replaces all instances unless a maximum is specified.
|
|
48
|
-
* @param array
|
|
49
|
-
* @param old
|
|
50
|
-
* @param newValue
|
|
51
|
-
* @param max
|
|
52
|
-
* @returns {number}
|
|
53
|
-
*/
|
|
54
|
-
export function replace(array, old, newValue, max = Infinity) {
|
|
30
|
+
function replace(array, old, newValue, max = Infinity) {
|
|
55
31
|
if (!array || !array.length || max === 0)
|
|
56
32
|
return 0;
|
|
57
33
|
if (max < 0)
|
|
58
34
|
throw new ArgumentOutOfRangeException('max', max, CBL0);
|
|
59
35
|
if (!max)
|
|
60
|
-
max = Infinity;
|
|
36
|
+
max = Infinity;
|
|
61
37
|
let count = 0;
|
|
62
38
|
for (let i = 0, len = array.length; i < len; i++) {
|
|
63
39
|
if (array[i] === old) {
|
|
@@ -69,14 +45,7 @@ export function replace(array, old, newValue, max = Infinity) {
|
|
|
69
45
|
}
|
|
70
46
|
return count;
|
|
71
47
|
}
|
|
72
|
-
|
|
73
|
-
* Replaces values of an array across a range of indexes.
|
|
74
|
-
* @param array
|
|
75
|
-
* @param value
|
|
76
|
-
* @param start
|
|
77
|
-
* @param stop
|
|
78
|
-
*/
|
|
79
|
-
export function updateRange(array, value, start = 0, stop) {
|
|
48
|
+
function updateRange(array, value, start = 0, stop) {
|
|
80
49
|
if (!array)
|
|
81
50
|
return;
|
|
82
51
|
integer.assertZeroOrGreater(start, 'start');
|
|
@@ -89,39 +58,19 @@ export function updateRange(array, value, start = 0, stop) {
|
|
|
89
58
|
array[i] = value;
|
|
90
59
|
}
|
|
91
60
|
}
|
|
92
|
-
|
|
93
|
-
* Clears (sets to null) values of an array across a range of indexes.
|
|
94
|
-
* @param array
|
|
95
|
-
* @param start
|
|
96
|
-
* @param stop
|
|
97
|
-
*/
|
|
98
|
-
export function clearEach(array, start = 0, stop) {
|
|
61
|
+
function clearEach(array, start = 0, stop) {
|
|
99
62
|
updateRange(array, null, start, stop);
|
|
100
63
|
}
|
|
101
|
-
|
|
102
|
-
* Ensures a value exists within an array. If not found, adds to the end.
|
|
103
|
-
* @param array
|
|
104
|
-
* @param item
|
|
105
|
-
* @param {function?} equalityComparer
|
|
106
|
-
* @returns {boolean}
|
|
107
|
-
*/
|
|
108
|
-
export function register(array, item, equalityComparer = areEqual) {
|
|
64
|
+
function register(array, item, equalityComparer = areEqual) {
|
|
109
65
|
if (!array)
|
|
110
66
|
throw new ArgumentNullException('array', CBN);
|
|
111
|
-
const len = array.length;
|
|
67
|
+
const len = array.length;
|
|
112
68
|
const ok = !len || !contains(array, item, equalityComparer);
|
|
113
69
|
if (ok)
|
|
114
|
-
array[len] = item;
|
|
70
|
+
array[len] = item;
|
|
115
71
|
return ok;
|
|
116
72
|
}
|
|
117
|
-
|
|
118
|
-
* Returns the first index of which the provided predicate returns true.
|
|
119
|
-
* Returns -1 if always false.
|
|
120
|
-
* @param array
|
|
121
|
-
* @param predicate
|
|
122
|
-
* @returns {number}
|
|
123
|
-
*/
|
|
124
|
-
export function findIndex(array, predicate) {
|
|
73
|
+
function findIndex(array, predicate) {
|
|
125
74
|
if (!array)
|
|
126
75
|
throw new ArgumentNullException('array', CBN);
|
|
127
76
|
if (!type.isFunction(predicate))
|
|
@@ -137,48 +86,32 @@ export function findIndex(array, predicate) {
|
|
|
137
86
|
}
|
|
138
87
|
else {
|
|
139
88
|
for (let i = 0; i < len; i++) {
|
|
140
|
-
|
|
89
|
+
const element = array[i];
|
|
90
|
+
if (i in array && element !== undefined && predicate(element, i))
|
|
141
91
|
return i;
|
|
142
92
|
}
|
|
143
93
|
}
|
|
144
94
|
return -1;
|
|
145
95
|
}
|
|
146
|
-
|
|
147
|
-
* Allows for using "false" to cause forEach to break.
|
|
148
|
-
* Can also be applied to a structure that indexes like an array, but may not be.
|
|
149
|
-
* @param source
|
|
150
|
-
* @param action
|
|
151
|
-
*/
|
|
152
|
-
export function forEach(source, action) {
|
|
96
|
+
function forEach(source, action) {
|
|
153
97
|
if (source && action != null) {
|
|
154
|
-
// Don't cache the length since it is possible that the underlying array changed.
|
|
155
98
|
for (let i = 0; i < source.length; i++) {
|
|
156
|
-
|
|
157
|
-
if (action(
|
|
99
|
+
const element = source[i];
|
|
100
|
+
if (element !== undefined && action(element, i) === false)
|
|
158
101
|
break;
|
|
159
102
|
}
|
|
160
103
|
}
|
|
161
104
|
}
|
|
162
|
-
|
|
163
|
-
* Is similar to Array.map() but instead of returning a new array, it updates the existing indexes.
|
|
164
|
-
* Can also be applied to a structure that indexes like an array, but may not be.
|
|
165
|
-
* @param target
|
|
166
|
-
* @param fn
|
|
167
|
-
*/
|
|
168
|
-
export function applyTo(target, fn) {
|
|
105
|
+
function applyTo(target, fn) {
|
|
169
106
|
if (target && fn != null) {
|
|
170
107
|
for (let i = 0; i < target.length; i++) {
|
|
171
|
-
|
|
108
|
+
const element = target[i];
|
|
109
|
+
if (element !== undefined)
|
|
110
|
+
target[i] = fn(element, i);
|
|
172
111
|
}
|
|
173
112
|
}
|
|
174
113
|
}
|
|
175
|
-
|
|
176
|
-
* Removes an entry at a specified index.
|
|
177
|
-
* @param array
|
|
178
|
-
* @param index
|
|
179
|
-
* @returns {boolean} True if the value was able to be removed.
|
|
180
|
-
*/
|
|
181
|
-
export function removeIndex(array, index) {
|
|
114
|
+
function removeIndex(array, index) {
|
|
182
115
|
if (!array)
|
|
183
116
|
throw new ArgumentNullException('array', CBN);
|
|
184
117
|
integer.assert(index, 'index');
|
|
@@ -189,34 +122,26 @@ export function removeIndex(array, index) {
|
|
|
189
122
|
array.splice(index, 1);
|
|
190
123
|
return exists;
|
|
191
124
|
}
|
|
192
|
-
|
|
193
|
-
* Finds and removes a value from an array. Will remove all instances unless a maximum is specified.
|
|
194
|
-
* @param array
|
|
195
|
-
* @param value
|
|
196
|
-
* @param max
|
|
197
|
-
* @param {function?} equalityComparer
|
|
198
|
-
* @returns {number} The number of times the value was found and removed.
|
|
199
|
-
*/
|
|
200
|
-
export function remove(array, value, max = Infinity, equalityComparer = areEqual) {
|
|
125
|
+
function remove(array, value, max = Infinity, equalityComparer = areEqual) {
|
|
201
126
|
if (!array || !array.length || max === 0)
|
|
202
127
|
return 0;
|
|
203
128
|
if (max < 0)
|
|
204
129
|
throw new ArgumentOutOfRangeException('max', max, CBL0);
|
|
205
130
|
let count = 0;
|
|
206
131
|
if (!max || !isFinite(max)) {
|
|
207
|
-
// Don't track the indexes and remove in reverse.
|
|
208
132
|
for (let i = array.length - 1; i >= 0; i--) {
|
|
209
|
-
|
|
133
|
+
const element = array[i];
|
|
134
|
+
if (element !== undefined && equalityComparer(element, value)) {
|
|
210
135
|
array.splice(i, 1);
|
|
211
136
|
++count;
|
|
212
137
|
}
|
|
213
138
|
}
|
|
214
139
|
}
|
|
215
140
|
else {
|
|
216
|
-
|
|
217
|
-
const found = []; // indexes;
|
|
141
|
+
const found = [];
|
|
218
142
|
for (let i = 0, len = array.length; i < len; i++) {
|
|
219
|
-
|
|
143
|
+
const element = array[i];
|
|
144
|
+
if (element !== undefined && equalityComparer(element, value)) {
|
|
220
145
|
found.push(i);
|
|
221
146
|
++count;
|
|
222
147
|
if (count === max)
|
|
@@ -224,18 +149,14 @@ export function remove(array, value, max = Infinity, equalityComparer = areEqual
|
|
|
224
149
|
}
|
|
225
150
|
}
|
|
226
151
|
for (let i = found.length - 1; i >= 0; i--) {
|
|
227
|
-
|
|
152
|
+
const index = found[i];
|
|
153
|
+
if (index !== undefined)
|
|
154
|
+
array.splice(index, 1);
|
|
228
155
|
}
|
|
229
156
|
}
|
|
230
157
|
return count;
|
|
231
158
|
}
|
|
232
|
-
|
|
233
|
-
* Simply repeats a value the number of times specified.
|
|
234
|
-
* @param element
|
|
235
|
-
* @param count
|
|
236
|
-
* @returns {T[]}
|
|
237
|
-
*/
|
|
238
|
-
export function repeat(element, count) {
|
|
159
|
+
function repeat(element, count) {
|
|
239
160
|
integer.assert(count, 'count');
|
|
240
161
|
if (count < 0)
|
|
241
162
|
throw new ArgumentOutOfRangeException('count', count, CBL0);
|
|
@@ -245,14 +166,7 @@ export function repeat(element, count) {
|
|
|
245
166
|
}
|
|
246
167
|
return result;
|
|
247
168
|
}
|
|
248
|
-
|
|
249
|
-
* Returns a range of numbers based upon the first value and the step value.
|
|
250
|
-
* @param first
|
|
251
|
-
* @param count
|
|
252
|
-
* @param step
|
|
253
|
-
* @returns {number[]}
|
|
254
|
-
*/
|
|
255
|
-
export function range(first, count, step = 1) {
|
|
169
|
+
function range(first, count, step = 1) {
|
|
256
170
|
if (isNaN(first) || !isFinite(first))
|
|
257
171
|
throw new ArgumentOutOfRangeException('first', first, VFN);
|
|
258
172
|
if (isNaN(count) || !isFinite(count))
|
|
@@ -266,32 +180,18 @@ export function range(first, count, step = 1) {
|
|
|
266
180
|
}
|
|
267
181
|
return result;
|
|
268
182
|
}
|
|
269
|
-
|
|
270
|
-
* Returns a range of numbers based upon the first value and the step value excluding any numbers at or beyond the until value.
|
|
271
|
-
* @param first
|
|
272
|
-
* @param until
|
|
273
|
-
* @param step
|
|
274
|
-
* @returns {number[]}
|
|
275
|
-
*/
|
|
276
|
-
export function rangeUntil(first, until, step = 1) {
|
|
183
|
+
function rangeUntil(first, until, step = 1) {
|
|
277
184
|
if (step === 0)
|
|
278
185
|
throw new ArgumentOutOfRangeException('step', step, CB0);
|
|
279
186
|
return range(first, (until - first) / step, step);
|
|
280
187
|
}
|
|
281
|
-
|
|
188
|
+
function distinct(source) {
|
|
282
189
|
if (!source)
|
|
283
|
-
return [];
|
|
190
|
+
return [];
|
|
284
191
|
const seen = {};
|
|
285
192
|
return source.filter((e) => !(e in seen) && (seen[e] = true));
|
|
286
193
|
}
|
|
287
|
-
|
|
288
|
-
* Takes any arrays within an array and inserts the values contained within in place of that array.
|
|
289
|
-
* For every count higher than 0 in recurseDepth it will attempt an additional pass. Passing Infinity will flatten all arrays contained.
|
|
290
|
-
* @param a
|
|
291
|
-
* @param recurseDepth
|
|
292
|
-
* @returns {any[]}
|
|
293
|
-
*/
|
|
294
|
-
export function flatten(a, recurseDepth = 0) {
|
|
194
|
+
function flatten(a, recurseDepth = 0) {
|
|
295
195
|
const result = [];
|
|
296
196
|
for (let x of a) {
|
|
297
197
|
if (x instanceof Array) {
|
|
@@ -305,4 +205,6 @@ export function flatten(a, recurseDepth = 0) {
|
|
|
305
205
|
}
|
|
306
206
|
return result;
|
|
307
207
|
}
|
|
308
|
-
|
|
208
|
+
|
|
209
|
+
export { applyTo, clearEach, contains, distinct, findIndex, flatten, forEach, indexOf, range, rangeUntil, register, remove, removeIndex, repeat, replace, updateRange };
|
|
210
|
+
//# sourceMappingURL=arrayUtility.js.map
|