UNPKG

@stdlib/array

Version:
41 lines (30 loc) 1.13 kB
{{alias}}( x, indices[, options] ) Takes elements from an array. If `indices` is an empty array, the function returns an empty array. Parameters ---------- x: Array|TypedArray|Object Input array. indices: ArrayLikeObject<integer> List of element indices. options: Object (optional) Function options. options.mode: string (optional) Specifies how to handle an index outside the interval [0, max], where `max` is the maximum possible array index. If equal to 'throw', the function throws an error. If equal to 'normalize', the function throws an error if provided an out-of-bounds normalized index. If equal to 'wrap', the function wraps around an index using modulo arithmetic. If equal to 'clamp', the function sets an index to either 0 (minimum index) or the maximum index. Default: 'normalize'. Returns ------- out: Array|TypedArray Output array. Examples -------- > var x = [ 1, 2, 3, 4 ]; > var y = {{alias}}( x, [ 1, 3 ] ) [ 2, 4 ] See Also --------