Methods
(static) ariSeries(startopt, end, step)
generating the sequence of equal difference
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
start |
number |
<optional> |
0 | the start element |
end |
number | the index of end but exclude and also is the length of array | ||
step |
number | the difference |
- Source:
Example
ariSeries(5) // [0, 1, 2, 3, 4]
ariSeries(1, 3) // [1, 2, 3]
ariSeries(1, 3, 2) // [1, 3, 5]
(static) deepDefAssign()
defAssign deeply, refer to defAssign
- Source:
(static) defAssign(target, source)
mixin two array and ignore undefined
Parameters:
Name | Type | Description |
---|---|---|
target |
Array | |
source |
Array |
- Source:
Example
defAssign([], [1, 2]) // [1, 2]
defAssign([undefined, 3], [1, undefined]]) // [1, 3]
(static) fill(arr, value, start, end)
fill array by value, refer to Array.prototype.fill
Parameters:
Name | Type | Description |
---|---|---|
arr |
array | |
value |
* | if value is function, it will fill by the result of value.call(arr, start, arr) |
start |
number | the index of start |
end |
number | the index of end |
- Source:
(static) range(startopt, end, stepopt)
like the function `range` of [python](https://docs.python.org/3/library/stdtypes.html?highlight=range#range)
generating an array in the range `[start, end)` with the equal difference `step`
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
start |
number |
<optional> |
0 | |
end |
number | |||
step |
number |
<optional> |
1 |
- Source:
Example
range(5) // [0, 1, 2]
range(1, 5) // [1, 2, 3, 4, 5]
range(1, 9, 3) // [1, 4, 7]
(static) series(startopt, end, cb)
new a array using function
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
start |
number |
<optional> |
0 | the start element |
end |
number | the index of end but exclude and also is the length of array | ||
cb |
function | the callback with arguments `(idx, array, accumulator)` idx is the index of each element array is the array accumulator is the sum of the previous elements the number of parameters is indefinite: series(start, end, function) series(end, function) |
- Source:
Example
series(5, idx => idx) // [0, 1, 2, 3, 4]