Socket
Socket
Sign inDemoInstall

idhash

Package Overview
Dependencies
2
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 2.0.0

.babelrc

21

package.json
{
"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
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