npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

unique-key-js

v1.0.0

Published

Object comparison utility that provides uniqueness information about the keys within an array of objects.

Downloads

5

Readme

JS Object Key Information

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.

Installation

user@machine> npm i unique-key-js -S

- or -

simply include UniqueKey.js in your project and src/package/import/require it as necessary.

Usage

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))

Example

const UniqueKey = require('./UniqueKey')

const people = [{
  "department":"Content Management",
  "deskphone" : "+1-234-456-7890",
  "displayname" : "Sherell Marcusen",
  "email" : "[email protected]",
  "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" : "[email protected]",
  "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" : "[email protected]",
  "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" : "[email protected]",
  "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" : "[email protected]",
  "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" : "[email protected]",
  "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:
      [ '[email protected]',
        '[email protected]',
        '[email protected]' ],
     unique_values:
      [ '[email protected]',
        '[email protected]',
        '[email protected]' ] },
  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' ] } }