@stdlib/ndarray-base-to-array 0.0.3 → 0.0.7

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/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2021 The Stdlib Authors.
1
+ Copyright (c) 2016-2022 The Stdlib Authors.
package/README.md CHANGED
@@ -20,7 +20,7 @@ limitations under the License.
20
20
 
21
21
  # ndarray2array
22
22
 
23
- [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url]
23
+ [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
24
24
 
25
25
  > Convert an ndarray buffer to a generic array.
26
26
 
@@ -116,7 +116,7 @@ var arr = ndarray2array( buffer, shape, strides, offset, order );
116
116
  ```javascript
117
117
  var shape2strides = require( '@stdlib/ndarray-base-shape2strides' );
118
118
  var strides2offset = require( '@stdlib/ndarray-base-strides2offset' );
119
- var dicreteUniform = require( '@stdlib/random-base-discrete-uniform' );
119
+ var discreteUniform = require( '@stdlib/random-base-discrete-uniform' );
120
120
  var ndarray2array = require( '@stdlib/ndarray-base-to-array' );
121
121
 
122
122
  // Create a data buffer:
@@ -143,7 +143,7 @@ console.log( 'Dims: %s', shape.join( 'x' ) );
143
143
  var arr;
144
144
  var j;
145
145
  for ( i = 0; i < 20; i++ ) {
146
- j = dicreteUniform( 0, ndims-1 );
146
+ j = discreteUniform( 0, ndims-1 );
147
147
  strides[ j ] *= -1;
148
148
  offset = strides2offset( shape, strides );
149
149
 
@@ -168,6 +168,14 @@ for ( i = 0; i < 20; i++ ) {
168
168
 
169
169
  <!-- /.references -->
170
170
 
171
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
172
+
173
+ <section class="related">
174
+
175
+ </section>
176
+
177
+ <!-- /.related -->
178
+
171
179
  <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
172
180
 
173
181
 
@@ -181,6 +189,10 @@ This package is part of [stdlib][stdlib], a standard library for JavaScript and
181
189
 
182
190
  For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
183
191
 
192
+ #### Community
193
+
194
+ [![Chat][chat-image]][chat-url]
195
+
184
196
  ---
185
197
 
186
198
  ## License
@@ -190,7 +202,7 @@ See [LICENSE][stdlib-license].
190
202
 
191
203
  ## Copyright
192
204
 
193
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
205
+ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
194
206
 
195
207
  </section>
196
208
 
@@ -209,9 +221,23 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
209
221
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-base-to-array/main.svg
210
222
  [coverage-url]: https://codecov.io/github/stdlib-js/ndarray-base-to-array?branch=main
211
223
 
212
- [dependencies-image]: https://img.shields.io/david/stdlib-js/ndarray-base-to-array
224
+ <!--
225
+
226
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/ndarray-base-to-array.svg
213
227
  [dependencies-url]: https://david-dm.org/stdlib-js/ndarray-base-to-array/main
214
228
 
229
+ -->
230
+
231
+ [umd]: https://github.com/umdjs/umd
232
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
233
+
234
+ [deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno
235
+ [umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd
236
+ [esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm
237
+
238
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
239
+ [chat-url]: https://gitter.im/stdlib-js/stdlib/
240
+
215
241
  [stdlib]: https://github.com/stdlib-js/stdlib
216
242
 
217
243
  [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
package/lib/main.js CHANGED
@@ -20,6 +20,7 @@
20
20
 
21
21
  // MODULES //
22
22
 
23
+ var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
23
24
  var recurse = require( './recurse.js' );
24
25
 
25
26
 
@@ -55,7 +56,7 @@ function ndarray2array( buffer, shape, strides, offset, order ) {
55
56
  return [];
56
57
  }
57
58
  }
58
- return recurse( buffer, shape, strides, offset, order, 0 );
59
+ return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len
59
60
  }
60
61
 
61
62
 
package/lib/recurse.js CHANGED
@@ -24,7 +24,9 @@
24
24
  * Recursively converts an ndarray to a generic array.
25
25
  *
26
26
  * @private
27
- * @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer
27
+ * @param {Object} obj - array object
28
+ * @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer
29
+ * @param {Function} obj.getter - element accessor
28
30
  * @param {NonNegativeIntegerArray} shape - array shape
29
31
  * @param {IntegerArray} strides - array strides
30
32
  * @param {NonNegativeInteger} offset - index offset
@@ -32,7 +34,7 @@
32
34
  * @param {NonNegativeInteger} dim - dimension
33
35
  * @returns {(Array|Array<Array>)} output array
34
36
  */
35
- function recurse( buffer, shape, strides, offset, order, dim ) {
37
+ function recurse( obj, shape, strides, offset, order, dim ) {
36
38
  var stride;
37
39
  var item;
38
40
  var out;
@@ -40,7 +42,7 @@ function recurse( buffer, shape, strides, offset, order, dim ) {
40
42
  var i;
41
43
 
42
44
  if ( dim >= shape.length ) {
43
- return buffer[ offset ];
45
+ return obj.getter( obj.data, offset );
44
46
  }
45
47
  out = [];
46
48
 
@@ -48,7 +50,7 @@ function recurse( buffer, shape, strides, offset, order, dim ) {
48
50
  stride = strides[ dim ];
49
51
 
50
52
  for ( i = 0; i < n; i++ ) {
51
- item = recurse( buffer, shape, strides, offset, order, dim+1 );
53
+ item = recurse( obj, shape, strides, offset, order, dim+1 );
52
54
  out.push( item );
53
55
  offset += stride;
54
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/ndarray-base-to-array",
3
- "version": "0.0.3",
3
+ "version": "0.0.7",
4
4
  "description": "Convert an ndarray buffer to a generic array.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -28,7 +28,7 @@
28
28
  "examples": "make examples",
29
29
  "benchmark": "make benchmark"
30
30
  },
31
- "homepage": "https://github.com/stdlib-js/stdlib",
31
+ "homepage": "https://stdlib.io",
32
32
  "repository": {
33
33
  "type": "git",
34
34
  "url": "git://github.com/stdlib-js/ndarray-base-to-array.git"
@@ -37,12 +37,16 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
+ "@stdlib/array-base-arraylike2object": "^0.0.x",
40
41
  "@stdlib/types": "^0.0.x"
41
42
  },
42
43
  "devDependencies": {
44
+ "@stdlib/array-complex64": "^0.0.x",
43
45
  "@stdlib/assert-is-array": "^0.0.x",
44
46
  "@stdlib/assert-is-array-array": "^0.0.x",
45
47
  "@stdlib/bench": "^0.0.x",
48
+ "@stdlib/complex-imagf": "^0.0.x",
49
+ "@stdlib/complex-realf": "^0.0.x",
46
50
  "@stdlib/ndarray-base-numel": "^0.0.x",
47
51
  "@stdlib/ndarray-base-shape2strides": "^0.0.x",
48
52
  "@stdlib/ndarray-base-strides2offset": "^0.0.x",
package/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- # CHANGELOG
2
-
3
- > Package changelog.
4
-
5
- See [GitHub Releases](https://github.com/stdlib-js/ndarray-base-to-array/releases) for the changelog.