Socket
Socket
Sign inDemoInstall

array-to-object

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

23

index.js

@@ -1,14 +0,19 @@

module.exports = arrToObj;
// array-to-object
module.exports = arrToObj
function arrToObj (array, values) {
if (!Array.isArray(array) || !Array.isArray(values))
return null;
if (!Array.isArray(array) || !Array.isArray(values)) {
return
}
var res = {};
var res = {}
array.forEach(function (ele) {
if (!values.length) return;
res[ele] = values.shift();
});
return res;
if (!values.length) {
return
}
res[ele] = values.shift()
})
return res
}
{
"name": "array-to-object",
"version": "1.0.0",
"description": "Converts arrays into objects",
"version": "1.1.0",
"description": "Transform two arrays into an object",
"main": "index.js",
"dependencies": {},
"files": [
"LICENSE",
"README.md",
"index.js"
],
"devDependencies": {
"tape": "^2.13.1"
"is-js-object": "^1.0.0",
"istanbul": "^0.3.17",
"jscs": "^2.0.0",
"jshint": "^2.8.0",
"pre-commit": "^1.0.10",
"tape": "^4.0.1"
},
"scripts": {
"test": "node test"
"test": "istanbul cover tape test.js",
"check-coverage": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"open-coverage": "open coverage/lcov-report/index.html",
"jshint": "jshint -c .jshintrc *.js",
"code-style": "jscs index.js"
},

@@ -20,3 +33,4 @@ "repository": {

"object",
"convert"
"convert",
"transform"
],

@@ -28,3 +42,9 @@ "author": "@joaquimserafim",

},
"homepage": "https://github.com/joaquimserafim/array-to-object"
"homepage": "https://github.com/joaquimserafim/array-to-object",
"pre-commit": [
"jshint",
"code-style",
"test",
"check-coverage"
]
}

@@ -11,15 +11,15 @@ # array-to-object

**V1**
####API
####API
var arrToObj = require('array-to-object');
var array = ['moe', 'larry', 'curly', 2014];
var values = [30, 40, 50, {month: 'May', day: 17}];
var object = arrToObj(array, values);
output:
{ '2014': { month: 'May', day: 17 }, moe: 30, larry: 40, curly: 50 }
```js
var arrToObj = require('array-to-object');
var keys = ['moe', 'larry', 'curly', 2014];
var values = [30, 40, 50, {month: 'May', day: 17}];
var object = arrToObj(keys, values);
// output:
{ '2014': { month: 'May', day: 17 }, moe: 30, larry: 40, curly: 50 }
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc