@stdlib/array-base-entries2objects
v0.1.1
Published
Convert array entries to an array of objects.
Downloads
183
Readme
entries2objects
Convert array entries to an array of objects.
Installation
npm install @stdlib/array-base-entries2objectsUsage
var entries2objects = require( '@stdlib/array-base-entries2objects' );entries2objects( arr, fields )
Converts array entries to an array of objects.
var x = [ 1, 2 ];
var fields = [ 'x', 'y' ];
var out = entries2objects( x, fields );
// returns [ { 'x': 0, 'y': 1 }, { 'x': 1, 'y': 2 } ]The function supports the following parameters:
- arr: input array.
- fields: list of field names.
- The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value.
Examples
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
var entries2objects = require( '@stdlib/array-base-entries2objects' );
var x = discreteUniform( 10, -100, 100 );
var fields = [ 'x', 'y' ];
var out = entries2objects( 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.
