|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 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 | +# zip2object |
| 22 | + |
| 23 | +> Create an object from a provided list of properties and a provided list of corresponding values. |
| 24 | +
|
| 25 | +<section class="usage"> |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```javascript |
| 30 | +var zip2object = require( '@stdlib/array/base/zip2object' ); |
| 31 | +``` |
| 32 | + |
| 33 | +#### zip2object( properties, values ) |
| 34 | + |
| 35 | +Returns an object from a provided list of properties and a provided list of corresponding values. |
| 36 | + |
| 37 | +```javascript |
| 38 | +var properties = [ 'a', 'b' ]; |
| 39 | +var values = [ 1, 2 ]; |
| 40 | + |
| 41 | +var out = zip2object( properties, values ); |
| 42 | +// returns { 'a': 1, 'b': 2 } |
| 43 | +``` |
| 44 | + |
| 45 | +The function supports the following parameters: |
| 46 | + |
| 47 | +- **properties**: list of properties. |
| 48 | +- **values**: list of values. |
| 49 | + |
| 50 | +</section> |
| 51 | + |
| 52 | +<!-- /.usage --> |
| 53 | + |
| 54 | +<section class="notes"> |
| 55 | + |
| 56 | +- The function assumes that both input arrays have the same length. |
| 57 | + |
| 58 | +</section> |
| 59 | + |
| 60 | +<!-- /.notes --> |
| 61 | + |
| 62 | +<section class="examples"> |
| 63 | + |
| 64 | +## Examples |
| 65 | + |
| 66 | +<!-- eslint no-undef: "error" --> |
| 67 | + |
| 68 | +```javascript |
| 69 | +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); |
| 70 | +var zeroTo = require( '@stdlib/array/base/zero-to' ); |
| 71 | +var zip2object = require( '@stdlib/array/base/zip2object' ); |
| 72 | + |
| 73 | +var x1 = zeroTo( 10 ); |
| 74 | +var x2 = discreteUniform( x1.length, -100, 100 ); |
| 75 | + |
| 76 | +var out = zip2object( x1, x2 ); |
| 77 | +// returns {...} |
| 78 | +``` |
| 79 | + |
| 80 | +</section> |
| 81 | + |
| 82 | +<!-- /.examples --> |
| 83 | + |
| 84 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 85 | + |
| 86 | +<section class="related"> |
| 87 | + |
| 88 | +</section> |
| 89 | + |
| 90 | +<!-- /.related --> |
| 91 | + |
| 92 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 93 | + |
| 94 | +<section class="links"> |
| 95 | + |
| 96 | +</section> |
| 97 | + |
| 98 | +<!-- /.links --> |
0 commit comments