
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
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 0 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
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.