README.md (1756B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # objectFromEntries 22 23 > Create an object from key-value pairs. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var objectFromEntries = require( '@stdlib/utils/from-entries' ); 31 ``` 32 33 #### objectFromEntries( entries ) 34 35 Returns an `object` created from `[key, value]` pairs. 36 37 ```javascript 38 var entries = [ ['a', 1], ['b', 2] ]; 39 40 var obj = objectFromEntries( entries ); 41 // returns { 'a': 1, 'b': 2 } 42 ``` 43 44 </section> 45 46 <!-- /.usage --> 47 48 <section class="notes"> 49 50 </section> 51 52 <!-- /.notes --> 53 54 <section class="examples"> 55 56 ## Examples 57 58 <!-- eslint no-undef: "error" --> 59 60 ```javascript 61 var objectEntries = require( '@stdlib/utils/entries' ); 62 var objectFromEntries = require( '@stdlib/utils/from-entries' ); 63 64 var obj1 = { 65 'beep': 'boop', 66 'a': { 67 'b': 'c' 68 }, 69 'foo': [ 'bar' ] 70 }; 71 72 var entries = objectEntries( obj1 ); 73 // e.g., returns [ ['beep', 'boop'], ['a', {'b':'c'}], ['foo', [ 'bar' ]] ] 74 75 var obj2 = objectFromEntries( entries ); 76 /* returns 77 { 78 'beep': 'boop', 79 'a': { 80 'b': 'c' 81 }, 82 'foo': [ 'bar' ] 83 } 84 */ 85 ``` 86 87 </section> 88 89 <!-- /.examples --> 90 91 <section class="links"> 92 93 </section> 94 95 <!-- /.links -->