df-script 1.5.0 → 1.6.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/README.md +124 -8
- package/dist/api.d.ts +1 -1
- package/dist/columnExpressions/ColumnExpr.d.ts +2 -2
- package/dist/columnExpressions/functions/coalesce.d.ts +2 -2
- package/dist/columnExpressions/functions/element.d.ts +1 -1
- package/dist/columnExpressions/functions/when.d.ts +2 -2
- package/dist/columnExpressions/index.d.ts +1 -1
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +2 -2
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +11 -10
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +39 -0
- package/dist/columnExpressions/mixins/ListExpr.d.ts +2 -2
- package/dist/columnExpressions/mixins/StringExpr.d.ts +2 -2
- package/dist/columnExpressions/types.d.ts +1 -0
- package/dist/constants.d.ts +11 -0
- package/dist/dataframe/dataframe.d.ts +1 -1
- package/dist/datatypes/index.d.ts +3 -2
- package/dist/datatypes/types.d.ts +7 -7
- package/dist/index.js +6 -6
- package/dist/types.d.ts +4 -2
- package/dist/utils/array.d.ts +217 -0
- package/dist/utils/binary.d.ts +3 -0
- package/dist/utils/date.d.ts +21 -35
- package/dist/utils/guards.d.ts +11 -10
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/list.d.ts +23 -1
- package/dist/utils/number.d.ts +14 -29
- package/dist/utils/object.d.ts +26 -0
- package/dist/utils/string.d.ts +3 -5
- package/package.json +2 -2
- package/dist/api.js +0 -26
- package/dist/bundle.min.js +0 -1
- package/dist/columnExpressions/ColumnExpr.js +0 -219
- package/dist/columnExpressions/ExprBase.js +0 -92
- package/dist/columnExpressions/constants.js +0 -7
- package/dist/columnExpressions/functions/all.js +0 -11
- package/dist/columnExpressions/functions/coalesce.js +0 -44
- package/dist/columnExpressions/functions/element.js +0 -11
- package/dist/columnExpressions/functions/exclude.js +0 -13
- package/dist/columnExpressions/functions/implode.js +0 -7
- package/dist/columnExpressions/functions/lit.js +0 -17
- package/dist/columnExpressions/functions/repeat.d.ts +0 -47
- package/dist/columnExpressions/functions/repeat.js +0 -131
- package/dist/columnExpressions/functions/seq_range.js +0 -91
- package/dist/columnExpressions/functions/when.js +0 -85
- package/dist/columnExpressions/index.js +0 -38
- package/dist/columnExpressions/mixins/AggregationExpr.js +0 -76
- package/dist/columnExpressions/mixins/ArithmeticExpr.js +0 -131
- package/dist/columnExpressions/mixins/BooleanExpr.d.ts +0 -40
- package/dist/columnExpressions/mixins/BooleanExpr.js +0 -67
- package/dist/columnExpressions/mixins/ComparisonExpr.js +0 -250
- package/dist/columnExpressions/mixins/ListExpr.js +0 -224
- package/dist/columnExpressions/mixins/LogicalExpr.js +0 -53
- package/dist/columnExpressions/mixins/ManipulationExpr.js +0 -71
- package/dist/columnExpressions/mixins/NumericExpr.d.ts +0 -92
- package/dist/columnExpressions/mixins/NumericExpr.js +0 -259
- package/dist/columnExpressions/mixins/StringExpr.js +0 -237
- package/dist/columnExpressions/mixins/StructExpr.js +0 -139
- package/dist/columnExpressions/mixins/TemporalExpr.js +0 -126
- package/dist/columnExpressions/mixins/WindowExpr.js +0 -151
- package/dist/columnExpressions/types.js +0 -2
- package/dist/columnExpressions/utils.js +0 -45
- package/dist/dataframe/constants.js +0 -7
- package/dist/dataframe/dataframe.js +0 -990
- package/dist/dataframe/grouped/grouped.js +0 -114
- package/dist/dataframe/index.js +0 -20
- package/dist/dataframe/types.js +0 -2
- package/dist/dataframe/utils.js +0 -307
- package/dist/datatypes/DataType.js +0 -76
- package/dist/datatypes/index.js +0 -46
- package/dist/datatypes/types/Binary.d.ts +0 -9
- package/dist/datatypes/types/Binary.js +0 -18
- package/dist/datatypes/types/Boolean.d.ts +0 -9
- package/dist/datatypes/types/Boolean.js +0 -19
- package/dist/datatypes/types/Date.d.ts +0 -8
- package/dist/datatypes/types/Date.js +0 -21
- package/dist/datatypes/types/Datetime.d.ts +0 -8
- package/dist/datatypes/types/Datetime.js +0 -17
- package/dist/datatypes/types/Decimal.d.ts +0 -10
- package/dist/datatypes/types/Decimal.js +0 -28
- package/dist/datatypes/types/Duration.d.ts +0 -8
- package/dist/datatypes/types/Duration.js +0 -17
- package/dist/datatypes/types/Float32.d.ts +0 -8
- package/dist/datatypes/types/Float32.js +0 -17
- package/dist/datatypes/types/Float64.d.ts +0 -8
- package/dist/datatypes/types/Float64.js +0 -17
- package/dist/datatypes/types/Int16.d.ts +0 -8
- package/dist/datatypes/types/Int16.js +0 -17
- package/dist/datatypes/types/Int32.d.ts +0 -8
- package/dist/datatypes/types/Int32.js +0 -17
- package/dist/datatypes/types/Int64.d.ts +0 -8
- package/dist/datatypes/types/Int64.js +0 -17
- package/dist/datatypes/types/Int8.d.ts +0 -8
- package/dist/datatypes/types/Int8.js +0 -17
- package/dist/datatypes/types/List.d.ts +0 -10
- package/dist/datatypes/types/List.js +0 -31
- package/dist/datatypes/types/Null.d.ts +0 -9
- package/dist/datatypes/types/Null.js +0 -17
- package/dist/datatypes/types/Object.d.ts +0 -9
- package/dist/datatypes/types/Object.js +0 -17
- package/dist/datatypes/types/Struct.d.ts +0 -14
- package/dist/datatypes/types/Struct.js +0 -39
- package/dist/datatypes/types/Time.d.ts +0 -8
- package/dist/datatypes/types/Time.js +0 -29
- package/dist/datatypes/types/UInt16.d.ts +0 -8
- package/dist/datatypes/types/UInt16.js +0 -17
- package/dist/datatypes/types/UInt32.d.ts +0 -8
- package/dist/datatypes/types/UInt32.js +0 -17
- package/dist/datatypes/types/UInt64.d.ts +0 -8
- package/dist/datatypes/types/UInt64.js +0 -17
- package/dist/datatypes/types/UInt8.d.ts +0 -8
- package/dist/datatypes/types/UInt8.js +0 -17
- package/dist/datatypes/types/Utf8.d.ts +0 -10
- package/dist/datatypes/types/Utf8.js +0 -20
- package/dist/datatypes/types.js +0 -290
- package/dist/exceptions/index.js +0 -46
- package/dist/exceptions/utils.js +0 -28
- package/dist/functions/concat.js +0 -260
- package/dist/functions/index.js +0 -9
- package/dist/functions/read_csv.js +0 -53
- package/dist/functions/read_json.js +0 -21
- package/dist/functions/transpose.d.ts +0 -7
- package/dist/functions/transpose.js +0 -84
- package/dist/types.js +0 -2
- package/dist/utils/boolean.d.ts +0 -1
- package/dist/utils/boolean.js +0 -18
- package/dist/utils/csv.js +0 -313
- package/dist/utils/date.js +0 -348
- package/dist/utils/guards.js +0 -112
- package/dist/utils/index.js +0 -23
- package/dist/utils/json.js +0 -217
- package/dist/utils/list.js +0 -361
- package/dist/utils/number.js +0 -401
- package/dist/utils/string.js +0 -209
package/dist/utils/list.js
DELETED
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toValidArray = toValidArray;
|
|
4
|
-
exports.toValidStringArray = toValidStringArray;
|
|
5
|
-
exports.isArrayOfType = isArrayOfType;
|
|
6
|
-
exports.sortList = sortList;
|
|
7
|
-
exports.getListStats = getListStats;
|
|
8
|
-
exports.getUniqueListStats = getUniqueListStats;
|
|
9
|
-
exports.stepSliceList = stepSliceList;
|
|
10
|
-
exports.joinList = joinList;
|
|
11
|
-
exports.fillSequence = fillSequence;
|
|
12
|
-
const guards_1 = require("./guards");
|
|
13
|
-
const date_1 = require("./date");
|
|
14
|
-
const number_1 = require("./number");
|
|
15
|
-
const string_1 = require("./string");
|
|
16
|
-
function toValidArray(val) {
|
|
17
|
-
if (val == null)
|
|
18
|
-
return [];
|
|
19
|
-
if (Array.isArray(val))
|
|
20
|
-
return [...val];
|
|
21
|
-
if ((0, guards_1.isTypedArray)(val))
|
|
22
|
-
return Array.from(val);
|
|
23
|
-
return [val];
|
|
24
|
-
}
|
|
25
|
-
function toValidStringArray(val) {
|
|
26
|
-
const arr = toValidArray(val);
|
|
27
|
-
const len = arr.length;
|
|
28
|
-
const res = new Array(len);
|
|
29
|
-
for (let i = 0; i < len; i++) {
|
|
30
|
-
res[i] = String(arr[i]);
|
|
31
|
-
}
|
|
32
|
-
return res;
|
|
33
|
-
}
|
|
34
|
-
function isArrayOfType(arr, type, { mode = "every", allowNulls = false, allowEmpty = true } = {}) {
|
|
35
|
-
if (!(0, guards_1.isArrayOrTypedArray)(arr))
|
|
36
|
-
return false;
|
|
37
|
-
const len = arr.length;
|
|
38
|
-
if (len === 0) {
|
|
39
|
-
if (!allowEmpty)
|
|
40
|
-
return false;
|
|
41
|
-
return mode === "every";
|
|
42
|
-
}
|
|
43
|
-
const list = arr;
|
|
44
|
-
let check;
|
|
45
|
-
if (typeof type === "function") {
|
|
46
|
-
const isC = (0, guards_1.isClass)(type);
|
|
47
|
-
check = isC
|
|
48
|
-
? (v) => v instanceof type
|
|
49
|
-
: type;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
switch (type) {
|
|
53
|
-
case "null":
|
|
54
|
-
check = (v) => v === null;
|
|
55
|
-
break;
|
|
56
|
-
case "undefined":
|
|
57
|
-
check = (v) => v === undefined;
|
|
58
|
-
break;
|
|
59
|
-
case "nullish":
|
|
60
|
-
check = (v) => v == null;
|
|
61
|
-
break;
|
|
62
|
-
case "any":
|
|
63
|
-
check = () => true;
|
|
64
|
-
break;
|
|
65
|
-
case "date":
|
|
66
|
-
check = date_1.isValidDateObj;
|
|
67
|
-
break;
|
|
68
|
-
case "object":
|
|
69
|
-
check = guards_1.isObj;
|
|
70
|
-
break;
|
|
71
|
-
case "plainObject":
|
|
72
|
-
check = guards_1.isPlainObj;
|
|
73
|
-
break;
|
|
74
|
-
case "number":
|
|
75
|
-
check = number_1.isValidNumber;
|
|
76
|
-
break;
|
|
77
|
-
default:
|
|
78
|
-
check = (v) => typeof v === type;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (allowNulls) {
|
|
83
|
-
const baseCheck = check;
|
|
84
|
-
check = (v) => v == null || baseCheck(v);
|
|
85
|
-
}
|
|
86
|
-
if (mode === "every") {
|
|
87
|
-
for (let i = 0; i < len; i++) {
|
|
88
|
-
if (!check(list[i]))
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
for (let i = 0; i < len; i++) {
|
|
95
|
-
if (check(list[i]))
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function sortList(arr, descending = false) {
|
|
102
|
-
if (!(0, guards_1.isArrayOrTypedArray)(arr))
|
|
103
|
-
return [];
|
|
104
|
-
const list = Array.from(arr);
|
|
105
|
-
list.sort((a, b) => {
|
|
106
|
-
if (a == null && b == null)
|
|
107
|
-
return 0;
|
|
108
|
-
if (a == null)
|
|
109
|
-
return 1;
|
|
110
|
-
if (b == null)
|
|
111
|
-
return -1;
|
|
112
|
-
if (a < b)
|
|
113
|
-
return descending ? 1 : -1;
|
|
114
|
-
if (a > b)
|
|
115
|
-
return descending ? -1 : 1;
|
|
116
|
-
return 0;
|
|
117
|
-
});
|
|
118
|
-
return list;
|
|
119
|
-
}
|
|
120
|
-
const DEFAULT_STATS = { sum: null, count: 0, min: null, max: null, mean: null, variance: 0, std: 0, nullCount: 0, len: 0, hasNulls: false, isNumeric: false };
|
|
121
|
-
function getListStats(arr) {
|
|
122
|
-
if (!(0, guards_1.isArrayOrTypedArray)(arr)) {
|
|
123
|
-
return { ...DEFAULT_STATS };
|
|
124
|
-
}
|
|
125
|
-
const len = arr.length;
|
|
126
|
-
if (len === 0) {
|
|
127
|
-
return { ...DEFAULT_STATS };
|
|
128
|
-
}
|
|
129
|
-
let minVal = null;
|
|
130
|
-
let maxVal = null;
|
|
131
|
-
let count = 0;
|
|
132
|
-
let nullCount = 0;
|
|
133
|
-
let total = 0;
|
|
134
|
-
let sumCompensation = 0;
|
|
135
|
-
let mean = 0;
|
|
136
|
-
let M2 = 0;
|
|
137
|
-
for (let i = 0; i < len; i++) {
|
|
138
|
-
const val = arr[i];
|
|
139
|
-
if (val == null) {
|
|
140
|
-
nullCount++;
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (minVal == null || val < minVal)
|
|
144
|
-
minVal = val;
|
|
145
|
-
if (maxVal == null || val > maxVal)
|
|
146
|
-
maxVal = val;
|
|
147
|
-
const n = (0, number_1.toValidNumber)(val);
|
|
148
|
-
if (n !== null) {
|
|
149
|
-
// Neumaier sum
|
|
150
|
-
const t = total + n;
|
|
151
|
-
if (Math.abs(total) >= Math.abs(n)) {
|
|
152
|
-
sumCompensation += (total - t) + n;
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
sumCompensation += (n - t) + total;
|
|
156
|
-
}
|
|
157
|
-
total = t;
|
|
158
|
-
count++;
|
|
159
|
-
const delta = n - mean;
|
|
160
|
-
mean += delta / count;
|
|
161
|
-
const delta2 = n - mean;
|
|
162
|
-
M2 += delta * delta2;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
const variance = count > 1 ? M2 / (count - 1) : 0;
|
|
166
|
-
return {
|
|
167
|
-
sum: count > 0 ? total + sumCompensation : null,
|
|
168
|
-
count,
|
|
169
|
-
min: minVal,
|
|
170
|
-
max: maxVal,
|
|
171
|
-
mean: count > 0 ? (total + sumCompensation) / count : null,
|
|
172
|
-
variance,
|
|
173
|
-
std: Math.sqrt(variance),
|
|
174
|
-
nullCount,
|
|
175
|
-
len,
|
|
176
|
-
hasNulls: nullCount > 0,
|
|
177
|
-
isNumeric: count > 0 && count === (len - nullCount)
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
function getUniqueListStats(arr, { strict = false, keySelector } = {}) {
|
|
181
|
-
const list = Array.from(arr);
|
|
182
|
-
const frequencies = new Map();
|
|
183
|
-
if (strict) {
|
|
184
|
-
const selector = keySelector ?? string_1.toCanonicalString;
|
|
185
|
-
const seen = new Map();
|
|
186
|
-
const len = list.length;
|
|
187
|
-
for (let i = 0; i < len; i++) {
|
|
188
|
-
const val = list[i];
|
|
189
|
-
const key = selector(val);
|
|
190
|
-
const entry = seen.get(key);
|
|
191
|
-
if (entry === undefined) {
|
|
192
|
-
seen.set(key, { val, count: 1 });
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
entry.count++;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
const values = [];
|
|
199
|
-
for (const entry of seen.values()) {
|
|
200
|
-
values.push(entry.val);
|
|
201
|
-
}
|
|
202
|
-
for (let i = 0; i < len; i++) {
|
|
203
|
-
const val = list[i];
|
|
204
|
-
const key = selector(val);
|
|
205
|
-
const entry = seen.get(key);
|
|
206
|
-
frequencies.set(val, entry.count);
|
|
207
|
-
}
|
|
208
|
-
return {
|
|
209
|
-
values,
|
|
210
|
-
count: values.length,
|
|
211
|
-
frequencies
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
const len = list.length;
|
|
215
|
-
for (let i = 0; i < len; i++) {
|
|
216
|
-
const val = list[i];
|
|
217
|
-
frequencies.set(val, (frequencies.get(val) ?? 0) + 1);
|
|
218
|
-
}
|
|
219
|
-
return {
|
|
220
|
-
values: Array.from(frequencies.keys()),
|
|
221
|
-
count: frequencies.size,
|
|
222
|
-
frequencies
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function stepSliceList(arr, { step = 1, offsetStart = 0, offsetEnd, maxItemsGathered, null_on_oob = true } = {}) {
|
|
226
|
-
if (arr == null) {
|
|
227
|
-
return null;
|
|
228
|
-
}
|
|
229
|
-
if (maxItemsGathered !== undefined && maxItemsGathered <= 0) {
|
|
230
|
-
return [];
|
|
231
|
-
}
|
|
232
|
-
if (step === 0) {
|
|
233
|
-
throw new Error("Step size step cannot be zero");
|
|
234
|
-
}
|
|
235
|
-
const len = arr.length;
|
|
236
|
-
const isOob = len === 0
|
|
237
|
-
? (offsetStart !== 0)
|
|
238
|
-
: (offsetStart >= len || offsetStart < -len);
|
|
239
|
-
if (isOob) {
|
|
240
|
-
if (!null_on_oob) {
|
|
241
|
-
throw new Error(`Start offset ${offsetStart} is out of bounds for list of length ${len}`);
|
|
242
|
-
}
|
|
243
|
-
return null;
|
|
244
|
-
}
|
|
245
|
-
const start = offsetStart < 0 ? len + offsetStart : offsetStart;
|
|
246
|
-
const end = offsetEnd !== undefined
|
|
247
|
-
? (offsetEnd < 0 ? len + offsetEnd : offsetEnd)
|
|
248
|
-
: (step > 0 ? len : -1);
|
|
249
|
-
const res = [];
|
|
250
|
-
if (step > 0) {
|
|
251
|
-
for (let i = start; i < end && i < len; i += step) {
|
|
252
|
-
if (i >= 0) {
|
|
253
|
-
res.push(arr[i]);
|
|
254
|
-
if (maxItemsGathered !== undefined && res.length >= maxItemsGathered) {
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
for (let i = start; i > end && i >= 0; i += step) {
|
|
262
|
-
if (i < len) {
|
|
263
|
-
res.push(arr[i]);
|
|
264
|
-
if (maxItemsGathered !== undefined && res.length >= maxItemsGathered) {
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return res;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Joins the elements of an array-like structure into a string using a separator.
|
|
274
|
-
* Excludes nullish checks and formats nested arrays cleanly.
|
|
275
|
-
*/
|
|
276
|
-
function joinList(arr, separator = ",", { ignoreNulls = false, nullValue = "", prefix = "", suffix = "", limit, truncationMarker = "...", valueFormatter } = {}) {
|
|
277
|
-
const len = arr.length;
|
|
278
|
-
const strList = [];
|
|
279
|
-
const maxLimit = limit !== undefined ? Math.max(0, limit) : len;
|
|
280
|
-
let truncated = false;
|
|
281
|
-
for (let i = 0; i < len; i++) {
|
|
282
|
-
if (strList.length >= maxLimit) {
|
|
283
|
-
truncated = true;
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
const x = arr[i];
|
|
287
|
-
if (x != null) {
|
|
288
|
-
strList.push(valueFormatter ? valueFormatter(x, i) : String(x));
|
|
289
|
-
}
|
|
290
|
-
else if (!ignoreNulls) {
|
|
291
|
-
strList.push(nullValue);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return prefix + strList.join(separator) + (truncated ? truncationMarker : "") + suffix;
|
|
295
|
-
}
|
|
296
|
-
function fillSequence(targetArray, initialValue, options = {}) {
|
|
297
|
-
const len = targetArray.length;
|
|
298
|
-
const { mode = "cumulative", step = 1, coerce = (v) => v, condition, reverse = false, startIndex = reverse ? len - 1 : 0, endIndex = reverse ? -1 : len } = options;
|
|
299
|
-
const increment = reverse ? -1 : 1;
|
|
300
|
-
const start = startIndex;
|
|
301
|
-
const end = endIndex;
|
|
302
|
-
const writeVal = (idx, val) => {
|
|
303
|
-
if (!condition || condition(targetArray[idx], idx, targetArray)) {
|
|
304
|
-
targetArray[idx] = coerce(val);
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
if (mode === "constant") {
|
|
308
|
-
const finalVal = coerce(initialValue);
|
|
309
|
-
for (let i = start; reverse ? i > end : i < end; i += increment) {
|
|
310
|
-
writeVal(i, finalVal);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
else if (mode === "independent") {
|
|
314
|
-
if (typeof step === "function") {
|
|
315
|
-
let relativeIdx = 0;
|
|
316
|
-
for (let i = start; reverse ? i > end : i < end; i += increment) {
|
|
317
|
-
writeVal(i, step({
|
|
318
|
-
index: relativeIdx,
|
|
319
|
-
initialValue,
|
|
320
|
-
originalValue: targetArray[i],
|
|
321
|
-
absoluteIndex: i,
|
|
322
|
-
targetArray
|
|
323
|
-
}));
|
|
324
|
-
relativeIdx++;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
for (let i = start; reverse ? i > end : i < end; i += increment) {
|
|
329
|
-
writeVal(i, initialValue + i * step);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
// cumulative mode
|
|
335
|
-
let current = initialValue;
|
|
336
|
-
let isFirst = true;
|
|
337
|
-
let relativeIdx = 0;
|
|
338
|
-
for (let i = start; reverse ? i > end : i < end; i += increment) {
|
|
339
|
-
if (isFirst) {
|
|
340
|
-
writeVal(i, current);
|
|
341
|
-
isFirst = false;
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
if (typeof step === "function") {
|
|
345
|
-
current = step({
|
|
346
|
-
prev: current,
|
|
347
|
-
index: relativeIdx,
|
|
348
|
-
originalValue: targetArray[i],
|
|
349
|
-
absoluteIndex: i,
|
|
350
|
-
targetArray
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
else {
|
|
354
|
-
current = current + step;
|
|
355
|
-
}
|
|
356
|
-
writeVal(i, current);
|
|
357
|
-
}
|
|
358
|
-
relativeIdx++;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|