Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
unique-key-js
Advanced tools
Object comparison utility that provides uniqueness information about the keys within an array of objects.
This is a 0dep JS module/class that provides 'uniqueness' information about the keys within an array of objects. Particularly useful in searching / sorting / filtering applications or for general object comparison.
user@machine> npm i unique-key-js -S
- or -
simply include UniqueKey.js
in your project and src/package/import/require it as necessary.
UniqueKey.js
exports a factory class as a module, UniqueKey
const UniqueKey = require('./UniqueKey')
console.log('More Detailed Key Info : ', UniqueKey.getInfoAboutKeys(people))
console.log('Keys with Unique Values : ', UniqueKey.getKeysWithUniqueValues(people))
const UniqueKey = require('./UniqueKey')
const people = [{
"department":"Content Management",
"deskphone" : "+1-234-456-7890",
"displayname" : "Sherell Marcusen",
"email" : "smarcusen@somedomain.com",
"employee_id" : "5819",
"firstname" : "Sherell ",
"lastname" : "Marcusen",
"location" : "LAX",
"mobile" : "+1-123-234-3456",
"picture" : "http://lorempixel.com/400/400/people/1/",
"title" : "Content Manager"
},
{
"department" : "Content Management",
"deskphone" : "+1-234-456-5678",
"displayname" : "Dian Chough",
"email" : "dchough@somedomain.com",
"employee_id" : "5790",
"firstname" : "Dian ",
"lastname" : "Chough",
"location" : "LAX",
"mobile" : "+1-123-234-5678",
"picture" : "http://lorempixel.com/400/400/people/7/",
"title" : "Content Manager"
},
{
"department": "Content Management",
"deskphone" : "+1-234-456-6789",
"displayname" : "Ernie Dangler",
"email" : "edangler@somedomain.com",
"employee_id" : "5979",
"firstname" : "Ernie ",
"lastname" : "Dangler",
"mobile" : "+1-123-234-4567",
"picture" : "http://lorempixel.com/400/400/people/3/",
"title" : "Content Management Supervisor"
}]
console.log('More Detailed Key Info : ', UniqueKey.getInfoAboutKeys(people))
console.log('Keys with Unique Values : ', UniqueKey.getKeysWithUniqueValues(people))
Example Output
Given the array of objects :
[{
"department":"Content Management",
"deskphone" : "+1-234-456-7890",
"displayname" : "Sherell Marcusen",
"email" : "smarcusen@somedomain.com",
"employee_id" : "5819",
"firstname" : "Sherell ",
"lastname" : "Marcusen",
"location" : "LAX",
"mobile" : "+1-123-234-3456",
"picture" : "http://lorempixel.com/400/400/people/1/",
"title" : "Content Manager"
},
{
"department" : "Content Management",
"deskphone" : "+1-234-456-5678",
"displayname" : "Dian Chough",
"email" : "dchough@somedomain.com",
"employee_id" : "5790",
"firstname" : "Dian ",
"lastname" : "Chough",
"location" : "LAX",
"mobile" : "+1-123-234-5678",
"picture" : "http://lorempixel.com/400/400/people/7/",
"title" : "Content Manager"
},
{
"department": "Content Management",
"deskphone" : "+1-234-456-6789",
"displayname" : "Ernie Dangler",
"email" : "edangler@somedomain.com",
"employee_id" : "5979",
"firstname" : "Ernie ",
"lastname" : "Dangler",
"mobile" : "+1-123-234-4567",
"picture" : "http://lorempixel.com/400/400/people/3/",
"title" : "Content Management Supervisor"
}]
a response would look like
{ unique_keys:
[ 'department',
'deskphone',
'displayname',
'email',
'employee_id',
'firstname',
'lastname',
'mobile',
'picture',
'title',
'location' ],
department:
{ is_unique: false,
all_values:
[ 'Content Management',
'Content Management',
'Content Management' ],
unique_values: [ 'Content Management' ] },
deskphone:
{ is_unique: true,
all_values: [ '+1-234-456-6789', '+1-234-456-5678', '+1-234-456-7890' ],
unique_values: [ '+1-234-456-6789', '+1-234-456-5678', '+1-234-456-7890' ] },
displayname:
{ is_unique: true,
all_values: [ 'Ernie Dangler', 'Dian Chough', 'Sherell Marcusen' ],
unique_values: [ 'Ernie Dangler', 'Dian Chough', 'Sherell Marcusen' ] },
email:
{ is_unique: true,
all_values:
[ 'edangler@somedomain.com',
'dchough@somedomain.com',
'smarcusen@somedomain.com' ],
unique_values:
[ 'edangler@somedomain.com',
'dchough@somedomain.com',
'smarcusen@somedomain.com' ] },
employee_id:
{ is_unique: true,
all_values: [ '5979', '5790', '5819' ],
unique_values: [ '5979', '5790', '5819' ] },
firstname:
{ is_unique: true,
all_values: [ 'Ernie ', 'Dian ', 'Sherell ' ],
unique_values: [ 'Ernie ', 'Dian ', 'Sherell ' ] },
lastname:
{ is_unique: true,
all_values: [ 'Dangler', 'Chough', 'Marcusen' ],
unique_values: [ 'Dangler', 'Chough', 'Marcusen' ] },
mobile:
{ is_unique: true,
all_values: [ '+1-123-234-4567', '+1-123-234-5678', '+1-123-234-3456' ],
unique_values: [ '+1-123-234-4567', '+1-123-234-5678', '+1-123-234-3456' ] },
picture:
{ is_unique: true,
all_values:
[ 'http://lorempixel.com/400/400/people/3/',
'http://lorempixel.com/400/400/people/7/',
'http://lorempixel.com/400/400/people/1/' ],
unique_values:
[ 'http://lorempixel.com/400/400/people/3/',
'http://lorempixel.com/400/400/people/7/',
'http://lorempixel.com/400/400/people/1/' ] },
title:
{ is_unique: false,
all_values:
[ 'Content Management Supervisor',
'Content Manager',
'Content Manager' ],
unique_values: [ 'Content Management Supervisor', 'Content Manager' ] },
location:
{ is_unique: false,
all_values: [ 'LAX', 'LAX' ],
unique_values: [ 'LAX' ] } }
FAQs
Object comparison utility that provides uniqueness information about the keys within an array of objects.
The npm package unique-key-js receives a total of 2 weekly downloads. As such, unique-key-js popularity was classified as not popular.
We found that unique-key-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.