|
1 | 1 |
|
2 | | -{{alias}}( x, indices ) |
| 2 | +{{alias}}( x, indices, mode ) |
3 | 3 | Takes elements from an array. |
4 | 4 |
|
5 | 5 | If `indices` is an empty array, the function returns an empty array. |
6 | 6 |
|
7 | | - The function does *not* perform bounds checking. If an index is less than |
8 | | - zero or greater than the maximum index of `x`, the value of the |
9 | | - corresponding element in the output array is undefined. |
10 | | - |
11 | 7 | Parameters |
12 | 8 | ---------- |
13 | 9 | x: ArrayLikeObject |
|
16 | 12 | indices: ArrayLikeObject<integer> |
17 | 13 | List of element indices. |
18 | 14 |
|
| 15 | + mode: string |
| 16 | + Specifies how to handle an index outside the interval [0, max], where |
| 17 | + `max` is the maximum possible array index. If equal to 'throw', the |
| 18 | + function throws an error. If equal to 'normalize', the function throws |
| 19 | + an error if provided an out-of-bounds normalized index. If equal to |
| 20 | + 'wrap', the function wraps around an index using modulo arithmetic. If |
| 21 | + equal to 'clamp', the function sets an index to either 0 (minimum index) |
| 22 | + or the maximum index. |
| 23 | + |
19 | 24 | Returns |
20 | 25 | ------- |
21 | 26 | out: Array |
|
24 | 29 | Examples |
25 | 30 | -------- |
26 | 31 | > var x = [ 1, 2, 3, 4 ]; |
27 | | - > var y = {{alias}}( x, [ 1, 3 ] ) |
| 32 | + > var y = {{alias}}( x, [ 1, 3 ], 'throw' ) |
28 | 33 | [ 2, 4 ] |
29 | 34 |
|
| 35 | + |
| 36 | +{{alias}}.assign( x, indices, mode, out, stride, offset ) |
| 37 | + Takes elements from an array and assigns the values to elements in a |
| 38 | + provided output array. |
| 39 | + |
| 40 | + Parameters |
| 41 | + ---------- |
| 42 | + x: ArrayLikeObject |
| 43 | + Input array. |
| 44 | + |
| 45 | + indices: ArrayLikeObject<integer> |
| 46 | + List of element indices. |
| 47 | + |
| 48 | + mode: string |
| 49 | + Specifies how to handle an index outside the interval [0, max], where |
| 50 | + `max` is the maximum possible array index. If equal to 'throw', the |
| 51 | + function throws an error. If equal to 'normalize', the function throws |
| 52 | + an error if provided an out-of-bounds normalized index. If equal to |
| 53 | + 'wrap', the function wraps around an index using modulo arithmetic. If |
| 54 | + equal to 'clamp', the function sets an index to either 0 (minimum index) |
| 55 | + or the maximum index. |
| 56 | + |
| 57 | + out: ArrayLikeObject |
| 58 | + Output array. |
| 59 | + |
| 60 | + stride: integer |
| 61 | + Output array stride. |
| 62 | + |
| 63 | + offset: integer |
| 64 | + Output array offset. |
| 65 | + |
| 66 | + Returns |
| 67 | + ------- |
| 68 | + out: ArrayLikeObject |
| 69 | + Output array. |
| 70 | + |
| 71 | + Examples |
| 72 | + -------- |
| 73 | + > var x = [ 1, 2, 3, 4 ]; |
| 74 | + > var out = [ 0, 0, 0, 0 ]; |
| 75 | + > var arr = {{alias}}.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ) |
| 76 | + [ 2, 0, 4, 0 ] |
| 77 | + > var bool = ( arr === out ) |
| 78 | + true |
| 79 | + |
30 | 80 | See Also |
31 | 81 | -------- |
32 | 82 |
|
0 commit comments