@stdlib/array-base-nested2objects
v0.1.1
Published
Convert nested arrays to objects.
Downloads
50
Readme
nested2objects
Convert nested arrays to objects.
Installation
npm install @stdlib/array-base-nested2objectsUsage
var nested2objects = require( '@stdlib/array-base-nested2objects' );nested2objects( arr, fields )
Converts each nested array to an object.
var x = [ [ 1, 2 ], [ 3, 4 ] ];
var fields = [ 'x', 'y' ];
var out = nested2objects( x, fields );
// returns [ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ]The function supports the following parameters:
- arr: input array containing nested arrays.
- fields: list of field names.
- The function assumes that all nested arrays have the same length.
- The number of provided array labels should equal the length of each nested array.
Examples
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory;
var filled2dBy = require( '@stdlib/array-base-filled2d-by' );
var nested2objects = require( '@stdlib/array-base-nested2objects' );
var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) );
var fields = [ 'x', 'y' ];
var out = nested2objects( x, fields );
// returns [...]Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
