# add dist

This commit is contained in:
Mario Romano
2016-04-21 11:56:31 +01:00
parent 5914688467
commit 07807e7bc3
13499 changed files with 1808930 additions and 5 deletions

View File

@@ -0,0 +1,28 @@
# zip-object
Create an object from from arrays of keys and values. (Inspired by [lodash's _.zipObject](http://devdocs.io/lodash/index#zipObject))
## Install
```
npm install zip-object --save
```
## Usage
Either takes two arrays or an array of arrays as the argument(s).
```js
var zipObject = require('zip-object');
var zipped = zipObject(['key1', 'key2'], ['value1', 'value2']);
console.log(zipped.key1); // outputs 'value1'
console.log(zipped.key2); // outputs 'value2'
```
## Run Tests
```
npm install
npm test
```

View File

@@ -0,0 +1,17 @@
var zipObject = function (keys, values) {
if (arguments.length == 1) {
values = keys[1];
keys = keys[0];
}
var result = {};
var i = 0;
for (i; i < keys.length; i += 1) {
result[keys[i]] = values[i];
}
return result;
};
module.exports = zipObject;

View File

@@ -0,0 +1,81 @@
{
"_args": [
[
"zip-object@^0.1.0",
"/Users/mromano/dev/dev-platform-webcomponents/ng2-components/ng2-alfresco-documentslist/node_modules/typings/node_modules/typings-core"
]
],
"_from": "zip-object@>=0.1.0 <0.2.0",
"_id": "zip-object@0.1.0",
"_inCache": true,
"_installable": true,
"_location": "/zip-object",
"_npmUser": {
"email": "scottcorgan@gmail.com",
"name": "scottcorgan"
},
"_npmVersion": "1.3.11",
"_phantomChildren": {},
"_requested": {
"name": "zip-object",
"raw": "zip-object@^0.1.0",
"rawSpec": "^0.1.0",
"scope": null,
"spec": ">=0.1.0 <0.2.0",
"type": "range"
},
"_requiredBy": [
"/typings/typings-core"
],
"_resolved": "https://registry.npmjs.org/zip-object/-/zip-object-0.1.0.tgz",
"_shasum": "c1a0da04c88c837756e248680a03ff902ec3f53a",
"_shrinkwrap": null,
"_spec": "zip-object@^0.1.0",
"_where": "/Users/mromano/dev/dev-platform-webcomponents/ng2-components/ng2-alfresco-documentslist/node_modules/typings/node_modules/typings-core",
"author": {
"name": "Scott Corgan"
},
"bugs": {
"url": "https://github.com/scottcorgan/zip-object/issues"
},
"dependencies": {},
"description": "Create an object from from arrays of keys and values",
"devDependencies": {
"tap-spec": "~0.1.3",
"tape": "~2.3.2"
},
"directories": {
"test": "test"
},
"dist": {
"shasum": "c1a0da04c88c837756e248680a03ff902ec3f53a",
"tarball": "https://registry.npmjs.org/zip-object/-/zip-object-0.1.0.tgz"
},
"homepage": "https://github.com/scottcorgan/zip-object#readme",
"keywords": [
"zip",
"object",
"lodash",
"array",
"object"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"email": "scottcorgan@gmail.com",
"name": "scottcorgan"
}
],
"name": "zip-object",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/scottcorgan/zip-object.git"
},
"scripts": {
"test": "node test/index.js | node_modules/.bin/tspec"
},
"version": "0.1.0"
}

View File

@@ -0,0 +1,24 @@
var zipObject = require('../');
var test = require('tape');
test('creates object from list of arrays', function (t) {
var obj = zipObject(['key1', 'key2'], ['value1', 'value2']);
var expected = {
key1: 'value1',
key2: 'value2'
};
t.deepEqual(obj, expected, 'created object');
t.end();
});
test('creates object from array of arrays', function (t) {
var obj = zipObject([['key1', 'key2'], ['value1', 'value2']]);
var expected = {
key1: 'value1',
key2: 'value2'
};
t.deepEqual(obj, expected, 'created object');
t.end();
});