This package has been deprecated

Author message:

This package has moved, please use @cryptoscamdb/array-object-dictionary instead.

array-object-dictionary

1.0.0 • Public • Published

array-object-dictionary

A simple NPM package to map an array of objects to an object of unique values.

Usage

npm install array-object-dictionary

Example

const dictionary = require('array-object-dictionary');

const cats = [{
    name: "Kitty",
    age: 4
},{
    name: "Tiger",
    age: 4
},{
    name: "Misty",
    age: 6
}]

console.log(dictionary(cats));

Which will return the following dictionary object:

{
    name: {
        Kitty: [
            {
                name: "Kitty",
                age: 4
            }
        ],
        Tiger: [
            {
                name: "Tiger",
                age: 4
            }
        ],
        Misty: [
            {
                name: "Misty",
                age: 6
            }
        ]
    },
    age: {
        4: [
            {
                name: "Kitty",
                age: 4
            },
            {
                name: "Tiger",
                age: 4
            }
        ],
        6: [
            {
                name: "Misty",
                age: 6
            }
        ]
    }
}

Notice how both Kitty and Tiger share the same age (4), and that's also how they're mapped in the dictionary.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i array-object-dictionary

      Weekly Downloads

      1

      Version

      1.0.0

      License

      MIT

      Unpacked Size

      3.78 kB

      Total Files

      5

      Last publish

      Collaborators

      • luit