@stdlib/utils-map 0.0.1 → 0.2.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.
@@ -16,19 +16,19 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
 
21
21
  /// <reference types="@stdlib/types"/>
22
22
 
23
- import { Collection } from '@stdlib/types/object';
24
- import { ndarray } from '@stdlib/types/ndarray';
23
+ import { Collection } from '@stdlib/types/array';
24
+ import { typedndarray } from '@stdlib/types/ndarray';
25
25
 
26
26
  /**
27
27
  * Callback invoked for each array element.
28
28
  *
29
29
  * @returns result
30
30
  */
31
- type Nullary = () => any;
31
+ type Nullary<U, V> = ( this: V ) => U;
32
32
 
33
33
  /**
34
34
  * Callback invoked for each array element.
@@ -36,7 +36,7 @@ type Nullary = () => any;
36
36
  * @param value - array element
37
37
  * @returns result
38
38
  */
39
- type Unary = ( value: any ) => any;
39
+ type Unary<T, U, V> = ( this: V, value: T ) => U;
40
40
 
41
41
  /**
42
42
  * Callback invoked for each array element.
@@ -45,7 +45,7 @@ type Unary = ( value: any ) => any;
45
45
  * @param index - element index
46
46
  * @returns result
47
47
  */
48
- type Binary = ( value: any, index: number ) => any;
48
+ type Binary<T, U, V> = ( this: V, value: T, index: number ) => U;
49
49
 
50
50
  /**
51
51
  * Callback invoked for each array element.
@@ -55,7 +55,7 @@ type Binary = ( value: any, index: number ) => any;
55
55
  * @param arr - array
56
56
  * @returns result
57
57
  */
58
- type Ternary = ( value: any, index: number, arr: ndarray ) => any;
58
+ type Ternary<T, U, V> = ( this: V, value: T, index: number, arr: typedndarray<T> ) => U;
59
59
 
60
60
  /**
61
61
  * Callback invoked for each array element.
@@ -65,7 +65,7 @@ type Ternary = ( value: any, index: number, arr: ndarray ) => any;
65
65
  * @param arr - array
66
66
  * @returns result
67
67
  */
68
- type ArrayTernary = ( value: any, index: number, arr: Collection ) => any;
68
+ type ArrayTernary<T, U, V> = ( this: V, value: T, index: number, arr: Collection<T> ) => U;
69
69
 
70
70
  /**
71
71
  * Callback invoked for each array element.
@@ -75,7 +75,7 @@ type ArrayTernary = ( value: any, index: number, arr: Collection ) => any;
75
75
  * @param arr - array
76
76
  * @returns result
77
77
  */
78
- type Callback = Nullary | Unary | Binary | Ternary;
78
+ type Callback<T, U, V> = Nullary<U, V> | Unary<T, U, V> | Binary<T, U, V> | Ternary<T, U, V>;
79
79
 
80
80
  /**
81
81
  * Callback invoked for each array element.
@@ -85,7 +85,7 @@ type Callback = Nullary | Unary | Binary | Ternary;
85
85
  * @param arr - array
86
86
  * @returns result
87
87
  */
88
- type ArrayCallback = Nullary | Unary | Binary | ArrayTernary;
88
+ type ArrayCallback<T, U, V> = Nullary<U, V> | Unary<T, U, V> | Binary<T, U, V> | ArrayTernary<T, U, V>;
89
89
 
90
90
  /**
91
91
  * Interface describing the main export.
@@ -110,9 +110,9 @@ interface Routine {
110
110
  * @returns output array
111
111
  *
112
112
  * @example
113
- * var naryFunction = require( `@stdlib/utils/nary-function` );
114
- * var abs = require( `@stdlib/math/base/special/abs` );
115
- * var array = require( `@stdlib/ndarray/array` );
113
+ * var naryFunction = require( '@stdlib/utils-nary-function' );
114
+ * var abs = require( '@stdlib/math-base-special-abs' );
115
+ * var array = require( '@stdlib/ndarray-array' );
116
116
  *
117
117
  * var opts = {
118
118
  * 'dtype': 'generic'
@@ -125,7 +125,7 @@ interface Routine {
125
125
  * var data = out.data;
126
126
  * // returns [ 1, 2, 3, 4, 5, 6 ]
127
127
  */
128
- ( arr: ndarray, fcn: Callback, thisArg?: any ): ndarray;
128
+ <T = unknown, U = unknown, V = unknown>( arr: typedndarray<T>, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): typedndarray<U>;
129
129
 
130
130
  /**
131
131
  * Applies a function to each element in an array and assigns the result to an element in a new array.
@@ -144,15 +144,15 @@ interface Routine {
144
144
  * @returns output array
145
145
  *
146
146
  * @example
147
- * var naryFunction = require( `@stdlib/utils/nary-function` );
148
- * var abs = require( `@stdlib/math/base/special/abs` );
147
+ * var naryFunction = require( '@stdlib/utils-nary-function' );
148
+ * var abs = require( '@stdlib/math-base-special-abs' );
149
149
  *
150
150
  * var arr = [ -1, -2, -3, -4, -5, -6 ];
151
151
  *
152
152
  * var out = map( arr, naryFunction( abs, 1 ) );
153
153
  * // returns [ 1, 2, 3, 4, 5, 6 ]
154
154
  */
155
- ( arr: Collection, fcn: ArrayCallback, thisArg?: any ): Collection;
155
+ <T = unknown, U = unknown, V = unknown>( arr: Collection<T>, fcn: ArrayCallback<T, U, V>, thisArg?: ThisParameterType<ArrayCallback<T, U, V>> ): Array<U>;
156
156
 
157
157
  /**
158
158
  * Applies a function to each element in an array and assigns the result to an element in an output array.
@@ -172,9 +172,9 @@ interface Routine {
172
172
  * @returns output array
173
173
  *
174
174
  * @example
175
- * var naryFunction = require( `@stdlib/utils/nary-function` );
176
- * var abs = require( `@stdlib/math/base/special/abs` );
177
- * var array = require( `@stdlib/ndarray/array` );
175
+ * var naryFunction = require( '@stdlib/utils-nary-function' );
176
+ * var abs = require( '@stdlib/math-base-special-abs' );
177
+ * var array = require( '@stdlib/ndarray-array' );
178
178
  *
179
179
  * var opts = {
180
180
  * 'dtype': 'generic',
@@ -188,7 +188,7 @@ interface Routine {
188
188
  * var data = out.data;
189
189
  * // returns [ 1, 2, 3, 4, 5, 6 ]
190
190
  */
191
- assign( arr: ndarray, out: ndarray, fcn: Callback, thisArg?: any ): ndarray;
191
+ assign<T = unknown, U = unknown, V = unknown>( arr: typedndarray<T>, out: typedndarray<U>, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): typedndarray<U>;
192
192
 
193
193
  /**
194
194
  * Applies a function to each element in an array and assigns the result to an element in an output array.
@@ -208,8 +208,8 @@ interface Routine {
208
208
  * @returns output array
209
209
  *
210
210
  * @example
211
- * var naryFunction = require( `@stdlib/utils/nary-function` );
212
- * var abs = require( `@stdlib/math/base/special/abs` );
211
+ * var naryFunction = require( '@stdlib/utils-nary-function' );
212
+ * var abs = require( '@stdlib/math-base-special-abs' );
213
213
  *
214
214
  * var arr = [ -1, -2, -3, -4, -5, -6 ];
215
215
  * var out = [ 0, 0, 0, 0, 0, 0 ];
@@ -219,7 +219,7 @@ interface Routine {
219
219
  * console.log( out );
220
220
  * // => [ 1, 2, 3, 4, 5, 6 ]
221
221
  */
222
- assign( arr: Collection, out: Collection, fcn: ArrayCallback, thisArg?: any ): Collection; // tslint:disable-line:max-line-length
222
+ assign<T = unknown, U = unknown, V = unknown>( arr: Collection<T>, out: Collection<U>, fcn: ArrayCallback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): Collection<U>;
223
223
  }
224
224
 
225
225
  /**
@@ -239,8 +239,8 @@ interface Routine {
239
239
  * @returns output array
240
240
  *
241
241
  * @example
242
- * var naryFunction = require( `@stdlib/utils/nary-function` );
243
- * var abs = require( `@stdlib/math/base/special/abs` );
242
+ * var naryFunction = require( '@stdlib/utils-nary-function' );
243
+ * var abs = require( '@stdlib/math-base-special-abs' );
244
244
  *
245
245
  * var arr = [ -1, -2, -3, -4, -5, -6 ];
246
246
  *
@@ -248,9 +248,9 @@ interface Routine {
248
248
  * // returns [ 1, 2, 3, 4, 5, 6 ]
249
249
  *
250
250
  * @example
251
- * var naryFunction = require( `@stdlib/utils/nary-function` );
252
- * var abs = require( `@stdlib/math/base/special/abs` );
253
- * var array = require( `@stdlib/ndarray/array` );
251
+ * var naryFunction = require( '@stdlib/utils-nary-function' );
252
+ * var abs = require( '@stdlib/math-base-special-abs' );
253
+ * var array = require( '@stdlib/ndarray-array' );
254
254
  *
255
255
  * var opts = {
256
256
  * 'dtype': 'generic'
@@ -264,8 +264,8 @@ interface Routine {
264
264
  * // returns [ 1, 2, 3, 4, 5, 6 ]
265
265
  *
266
266
  * @example
267
- * var naryFunction = require( `@stdlib/utils/nary-function` );
268
- * var abs = require( `@stdlib/math/base/special/abs` );
267
+ * var naryFunction = require( '@stdlib/utils-nary-function' );
268
+ * var abs = require( '@stdlib/math-base-special-abs' );
269
269
  *
270
270
  * var arr = [ -1, -2, -3, -4, -5, -6 ];
271
271
  * var out = [ 0, 0, 0, 0, 0, 0 ];
@@ -276,9 +276,9 @@ interface Routine {
276
276
  * // => [ 1, 2, 3, 4, 5, 6 ]
277
277
  *
278
278
  * @example
279
- * var naryFunction = require( `@stdlib/utils/nary-function` );
280
- * var abs = require( `@stdlib/math/base/special/abs` );
281
- * var array = require( `@stdlib/ndarray/array` );
279
+ * var naryFunction = require( '@stdlib/utils-nary-function' );
280
+ * var abs = require( '@stdlib/math-base-special-abs' );
281
+ * var array = require( '@stdlib/ndarray-array' );
282
282
  *
283
283
  * var opts = {
284
284
  * 'dtype': 'generic',
package/lib/array.js CHANGED
@@ -26,10 +26,10 @@
26
26
  * @private
27
27
  * @param {Object} x - object containing input array data
28
28
  * @param {ArrayLikeObject} x.data - input array data
29
- * @param {Function} x.getter - callback for accessing input array data elements
29
+ * @param {Array<Function>} x.accessors - input array accessors
30
30
  * @param {Object} y - object containing output array data
31
31
  * @param {ArrayLikeObject} y.data - output array data
32
- * @param {Function} y.setter - callback for setting output array data elements
32
+ * @param {Array<Function>} y.accessors - output array accessors
33
33
  * @param {Function} fcn - function to apply
34
34
  * @param {*} thisArg - function execution context
35
35
  * @returns {void}
@@ -50,11 +50,11 @@
50
50
  * // Create the input and output array objects:
51
51
  * var x = {
52
52
  * 'data': [ -1, -2, -3, -4, -5, -6 ],
53
- * 'getter': getter
53
+ * 'accessors': [ getter, setter ]
54
54
  * };
55
55
  * var y = {
56
56
  * 'data': [ 0, 0, 0, 0, 0, 0 ],
57
- * 'setter': setter
57
+ * 'accessors': [ getter, setter ]
58
58
  * };
59
59
  *
60
60
  * map( x, y, naryFunction( abs, 1 ) );
@@ -74,8 +74,8 @@ function map( x, y, fcn, thisArg ) {
74
74
  ybuf = y.data;
75
75
 
76
76
  // Cache accessors:
77
- get = x.getter;
78
- set = y.setter;
77
+ get = x.accessors[ 0 ];
78
+ set = y.accessors[ 1 ];
79
79
 
80
80
  // Iterate over each element...
81
81
  for ( i = 0; i < xbuf.length; i++ ) {
package/lib/assign.js CHANGED
@@ -27,6 +27,7 @@ var ndarraylike2object = require( '@stdlib/ndarray-base-ndarraylike2object' );
27
27
  var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
28
28
  var broadcast = require( '@stdlib/ndarray-base-maybe-broadcast-array' );
29
29
  var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' );
30
+ var format = require( '@stdlib/string-format' );
30
31
  var ndarrayFcn = require( './ndarray.js' );
31
32
  var arrayFcn = require( './array.js' );
32
33
 
@@ -90,11 +91,11 @@ function map( arr, out, fcn, thisArg ) {
90
91
  var tmp;
91
92
  var sh;
92
93
  if ( !isFunction( fcn ) ) {
93
- throw new TypeError( 'invalid argument. Third argument must be a function. Value: `' + fcn + '`.' );
94
+ throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) );
94
95
  }
95
96
  if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like
96
97
  if ( !isndarrayLike( out ) ) {
97
- throw new TypeError( 'invalid argument. If the input array is an ndarray, the output array must also be an ndarray. Value: `' + out + '`.' );
98
+ throw new TypeError( format( 'invalid argument. If the input array is an ndarray, the output array must also be an ndarray. Value: `%s`.', out ) );
98
99
  }
99
100
  if ( isReadOnly( out ) ) {
100
101
  throw new Error( 'invalid argument. The output ndarray must be writable. Cannot write to a read-only ndarray.' );
@@ -111,7 +112,7 @@ function map( arr, out, fcn, thisArg ) {
111
112
  }
112
113
  if ( isArrayLikeObject( arr ) ) {
113
114
  if ( !isArrayLikeObject( out ) || isndarrayLike( out ) ) {
114
- throw new TypeError( 'invalid argument. If the input array is an array-like object, the output array must also be an array-like object. Value: `' + out + '`.' );
115
+ throw new TypeError( format( 'invalid argument. If the input array is an array-like object, the output array must also be an array-like object. Value: `%s`.', out ) );
115
116
  }
116
117
  if ( arr.length !== out.length ) {
117
118
  throw new RangeError( 'invalid arguments. Input and output arrays must have the same length.' );
@@ -119,7 +120,7 @@ function map( arr, out, fcn, thisArg ) {
119
120
  arrayFcn( arraylike2object( arr ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len
120
121
  return out;
121
122
  }
122
- throw new TypeError( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `' + arr + '`.' );
123
+ throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) );
123
124
  }
124
125
 
125
126
 
package/lib/main.js CHANGED
@@ -27,6 +27,7 @@ var zeros = require( '@stdlib/array-base-zeros' );
27
27
  var ndarraylike2object = require( '@stdlib/ndarray-base-ndarraylike2object' );
28
28
  var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
29
29
  var ndzeros = require( '@stdlib/ndarray-zeros' );
30
+ var format = require( '@stdlib/string-format' );
30
31
  var ndarrayFcn = require( './ndarray.js' );
31
32
  var arrayFcn = require( './array.js' );
32
33
 
@@ -79,7 +80,7 @@ var arrayFcn = require( './array.js' );
79
80
  function map( arr, fcn, thisArg ) {
80
81
  var out;
81
82
  if ( !isFunction( fcn ) ) {
82
- throw new TypeError( 'invalid argument. Second argument must be a function. Value: `' + fcn + '`.' );
83
+ throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );
83
84
  }
84
85
  if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like
85
86
  arr = ndarraylike2object( arr );
@@ -95,7 +96,7 @@ function map( arr, fcn, thisArg ) {
95
96
  arrayFcn( arraylike2object( arr ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len
96
97
  return out;
97
98
  }
98
- throw new TypeError( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `' + arr + '`.' );
99
+ throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) );
99
100
  }
100
101
 
101
102
 
package/lib/ndarray.js CHANGED
@@ -43,7 +43,7 @@ var MODE = 'throw';
43
43
  * @param {IntegerArray} x.strides - stride lengths
44
44
  * @param {NonNegativeInteger} x.offset - index offset
45
45
  * @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style)
46
- * @param {Function} x.getter - callback for accessing `x` data buffer elements
46
+ * @param {Array<Function>} x.accessors - accessors for accessing data buffer elements
47
47
  * @param {Object} y - object containing output ndarray meta data
48
48
  * @param {string} y.dtype - data type
49
49
  * @param {Collection} y.data - data buffer
@@ -52,7 +52,7 @@ var MODE = 'throw';
52
52
  * @param {IntegerArray} y.strides - stride lengths
53
53
  * @param {NonNegativeInteger} y.offset - index offset
54
54
  * @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style)
55
- * @param {Function} y.setter - callback for setting `y` data buffer elements
55
+ * @param {Array<Function>} y.accessors - accessors for accessing data buffer elements
56
56
  * @param {Function} fcn - function to apply
57
57
  * @param {*} thisArg - function execution context
58
58
  * @returns {void}
@@ -102,7 +102,7 @@ var MODE = 'throw';
102
102
  * 'strides': sx,
103
103
  * 'offset': ox,
104
104
  * 'order': 'row-major',
105
- * 'getter': getter
105
+ * 'accessors': [ getter, setter ]
106
106
  * };
107
107
  * x.ref = x;
108
108
  *
@@ -115,7 +115,7 @@ var MODE = 'throw';
115
115
  * 'strides': sy,
116
116
  * 'offset': oy,
117
117
  * 'order': 'row-major',
118
- * 'setter': setter
118
+ * 'accessors': [ getter, setter ]
119
119
  * };
120
120
  *
121
121
  * // Apply the unary function:
@@ -172,8 +172,8 @@ function map( x, y, fcn, thisArg ) {
172
172
  ordy = y.order;
173
173
 
174
174
  // Cache accessors:
175
- get = x.getter;
176
- set = y.setter;
175
+ get = x.accessors[ 0 ];
176
+ set = y.accessors[ 1 ];
177
177
 
178
178
  // Cache the reference to the original input array:
179
179
  ref = x.ref;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/utils-map",
3
- "version": "0.0.1",
3
+ "version": "0.2.0",
4
4
  "description": "Apply a function to each element in an array and assign the result to an element in an output array.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,39 +37,42 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@stdlib/array-base-arraylike2object": "^0.0.x",
41
- "@stdlib/array-base-zeros": "^0.0.x",
42
- "@stdlib/assert-is-array-like-object": "^0.0.x",
43
- "@stdlib/assert-is-function": "^0.0.x",
44
- "@stdlib/assert-is-ndarray-like": "^0.0.x",
45
- "@stdlib/ndarray-base-assert-is-read-only": "^0.0.x",
46
- "@stdlib/ndarray-base-maybe-broadcast-array": "^0.0.x",
47
- "@stdlib/ndarray-base-ndarraylike2object": "^0.0.x",
48
- "@stdlib/ndarray-base-vind2bind": "^0.0.x",
49
- "@stdlib/ndarray-zeros": "^0.0.x",
50
- "@stdlib/types": "^0.0.x",
51
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x"
40
+ "@stdlib/array-base-arraylike2object": "^0.2.0",
41
+ "@stdlib/array-base-zeros": "^0.2.0",
42
+ "@stdlib/assert-is-array-like-object": "^0.2.0",
43
+ "@stdlib/assert-is-function": "^0.2.0",
44
+ "@stdlib/assert-is-ndarray-like": "^0.2.0",
45
+ "@stdlib/ndarray-base-assert-is-read-only": "^0.2.0",
46
+ "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.0",
47
+ "@stdlib/ndarray-base-ndarraylike2object": "^0.2.0",
48
+ "@stdlib/ndarray-base-vind2bind": "^0.2.0",
49
+ "@stdlib/ndarray-zeros": "^0.2.0",
50
+ "@stdlib/string-format": "^0.2.0",
51
+ "@stdlib/types": "^0.3.1",
52
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0",
53
+ "@stdlib/error-tools-fmtprodmsg": "^0.2.0"
52
54
  },
53
55
  "devDependencies": {
54
- "@stdlib/array-base-filled": "^0.0.x",
55
- "@stdlib/array-complex64": "^0.0.x",
56
- "@stdlib/array-filled-by": "^0.0.x",
57
- "@stdlib/array-float64": "^0.0.x",
58
- "@stdlib/assert-is-array": "^0.0.x",
59
- "@stdlib/bench": "^0.0.x",
60
- "@stdlib/complex-float32": "^0.0.x",
61
- "@stdlib/complex-imagf": "^0.0.x",
62
- "@stdlib/complex-realf": "^0.0.x",
63
- "@stdlib/math-base-special-abs": "^0.0.x",
64
- "@stdlib/math-base-special-abs2": "^0.0.x",
65
- "@stdlib/math-base-special-pow": "^0.0.x",
66
- "@stdlib/ndarray-array": "^0.0.x",
67
- "@stdlib/ndarray-ctor": "^0.0.x",
68
- "@stdlib/random-base-discrete-uniform": "^0.0.x",
69
- "@stdlib/utils-nary-function": "^0.0.x",
56
+ "@stdlib/array-base-filled": "^0.2.0",
57
+ "@stdlib/array-complex64": "^0.1.0",
58
+ "@stdlib/array-filled-by": "^0.1.0",
59
+ "@stdlib/array-float64": "^0.2.0",
60
+ "@stdlib/assert-is-array": "^0.2.0",
61
+ "@stdlib/complex-float32": "^0.2.0",
62
+ "@stdlib/complex-imagf": "^0.2.0",
63
+ "@stdlib/complex-realf": "^0.2.0",
64
+ "@stdlib/math-base-special-abs": "^0.2.0",
65
+ "@stdlib/math-base-special-abs2": "^0.2.0",
66
+ "@stdlib/math-base-special-pow": "^0.2.0",
67
+ "@stdlib/ndarray-array": "^0.1.0",
68
+ "@stdlib/ndarray-ctor": "^0.1.0",
69
+ "@stdlib/random-base-discrete-uniform": "^0.1.0",
70
+ "@stdlib/utils-nary-function": "^0.2.0",
70
71
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
71
72
  "istanbul": "^0.4.1",
72
- "tap-spec": "5.x.x"
73
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git",
74
+ "@stdlib/bench-harness": "^0.2.0",
75
+ "@stdlib/bench": "^0.3.1"
73
76
  },
74
77
  "engines": {
75
78
  "node": ">=0.10.0",
@@ -112,7 +115,7 @@
112
115
  "fcn"
113
116
  ],
114
117
  "funding": {
115
- "type": "patreon",
116
- "url": "https://www.patreon.com/athan"
118
+ "type": "opencollective",
119
+ "url": "https://opencollective.com/stdlib"
117
120
  }
118
121
  }
package/docs/repl.txt DELETED
@@ -1,106 +0,0 @@
1
-
2
- {{alias}}( arr, fcn[, thisArg] )
3
- Applies a function to each element in an array and assigns the result to an
4
- element in a new array.
5
-
6
- The applied function is provided the following arguments:
7
-
8
- - value: array element.
9
- - index: element index.
10
- - arr: input array.
11
-
12
- The returned output array always has a "generic" data type. For example, if
13
- provided an array-like object, the function returns a generic array. If
14
- provided an ndarray, the function returns an ndarray having a "generic" data
15
- type.
16
-
17
- Parameters
18
- ----------
19
- arr: ArrayLikeObject|ndarray
20
- Input array.
21
-
22
- fcn: Function
23
- Function to apply.
24
-
25
- thisArg: any (optional)
26
- Input function context.
27
-
28
- Returns
29
- -------
30
- out: Array|ndarray
31
- Output array.
32
-
33
- Examples
34
- --------
35
- // array-like object:
36
- > var f = {{alias:@stdlib/utils/nary-function}}( {{alias:@stdlib/math/base/special/abs}}, 1 );
37
- > var arr = [ -1, -2, -3, -4, -5, -6 ];
38
- > var out = {{alias}}( arr, f )
39
- [ 1, 2, 3, 4, 5, 6 ]
40
-
41
- // ndarray:
42
- > arr = {{alias:@stdlib/ndarray/array}}( arr, { 'shape': [ 2, 3 ] } );
43
- > out = {{alias}}( arr, f );
44
- > var v = out.get( 1, 1 )
45
- 5
46
-
47
-
48
- {{alias}}.assign( arr, out, fcn[, thisArg] )
49
- Applies a function to each element in an array and assigns the result to an
50
- element in an output array.
51
-
52
- The applied function is provided the following arguments:
53
-
54
- - value: array element.
55
- - index: element index.
56
- - arr: input array.
57
-
58
- Input and output arrays must be either both array-like objects or both
59
- ndarray-like objects.
60
-
61
- If input and output arrays are array-like objects, the arrays must have the
62
- same number of elements.
63
-
64
- If input and output arrays are both ndarray-like objects, the arrays *must*
65
- be broadcast compatible.
66
-
67
- Parameters
68
- ----------
69
- arr: ArrayLikeObject|ndarray
70
- Input array.
71
-
72
- out: ArrayLikeObject|ndarray
73
- Output array.
74
-
75
- fcn: Function
76
- Function to apply.
77
-
78
- thisArg: any (optional)
79
- Input function context.
80
-
81
- Returns
82
- -------
83
- out: Array|ndarray
84
- Output array.
85
-
86
- Examples
87
- --------
88
- // array-like object:
89
- > var f = {{alias:@stdlib/utils/nary-function}}( {{alias:@stdlib/math/base/special/abs}}, 1 );
90
- > var arr = [ -1, -2, -3, -4, -5, -6 ];
91
- > var out = [ 0, 0, 0, 0, 0, 0 ];
92
- > {{alias}}.assign( arr, out, f );
93
- > out
94
- [ 1, 2, 3, 4, 5, 6 ]
95
-
96
- // ndarray:
97
- > var opts = { 'shape': [ 2, 3 ] };
98
- > arr = {{alias:@stdlib/ndarray/array}}( arr, opts );
99
- > out = {{alias:@stdlib/ndarray/array}}( [ 0, 0, 0, 0, 0, 0 ], opts );
100
- > {{alias}}.assign( arr, out, f );
101
- > var v = out.get( 1, 1 )
102
- 5
103
-
104
- See Also
105
- --------
106
-