idhash
Advanced tools
Comparing version 1.1.2 to 2.0.0
{ | ||
"name": "idhash", | ||
"version": "1.1.2", | ||
"version": "2.0.0", | ||
"description": "Create object hash from array of objects and their ids", | ||
"main": "src/index.js", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"prepare": "npm run build", | ||
"build": "rm -rf ./lib && ./node_modules/.bin/babel -e 0 ./src --out-dir ./lib" | ||
}, | ||
@@ -13,9 +14,3 @@ "repository": { | ||
}, | ||
"keywords": [ | ||
"id", | ||
"hash", | ||
"objects", | ||
"reduce", | ||
"map" | ||
], | ||
"keywords": ["id", "hash", "objects", "reduce", "map"], | ||
"author": "@jsifalda", | ||
@@ -29,3 +24,9 @@ "license": "ISC", | ||
"is-plain-object": "2.0.1" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-plugin-transform-decorators-legacy": "^1.3.4", | ||
"babel-preset-es2015": "^6.24.1", | ||
"babel-preset-stage-0": "^6.24.1" | ||
} | ||
} |
var isPlainObject = require('is-plain-object') | ||
var ID = '_id' | ||
var modifiedID = false | ||
var create = (array, id) => { | ||
if (id) { | ||
modifiedID = true | ||
} | ||
id = id || ID | ||
var idhash = (array, id = '_id') => { | ||
if (Array.isArray(array)) { | ||
@@ -19,8 +10,2 @@ return array | ||
.reduce((obj, item) => { | ||
if (!modifiedID) { | ||
if (!item[id]) { | ||
id = 'id' | ||
} | ||
} | ||
obj[item[id]] = item | ||
@@ -34,2 +19,2 @@ return obj | ||
module.exports = create | ||
module.exports = idhash |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
1796
5
29
0
4