1.2.0 • Published 5 months ago

@sineverba/unique-keys v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Unique Keys

CI / CDStatus
NPMnpm version
Semaphore CIBuild Status
Circle CICircleCI
CoverallCoverage Status
SonarCloudQuality Gate Status

Generates unique keys for an array.

uniqueKeys adds unique ID to an object.

Why is it useful?

I use it when I need to iterate on an array, to fix the warning "Each Child in a List Should Have a Unique 'key' Prop"

Installation

npm install @sineverba/unique-keys

Usage

import { uniqueKeys } from "@sineverba/unique-keys";

const data = [
    {
        key: "fooKey",
        value: "fooValue"
    },
    {
        key: "barKey",
        value: "barValue"
    }
];

const newData = uniqueKeys(data);

console.log(newData);

/**
 * It prints
 * 
 * [
    {
        key: "fooKey",
        value: "fooValue",
        uniqueKey: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
    },
    {
        key: "barKey",
        value: "barValue",
        uniqueKey: "710b962e-041c-11e1-9234-0123456789ab"
    }
];
 */

Tests

npm run test for simple test

npm run cover for coverage

1.2.0

5 months ago

1.1.0

10 months ago

1.0.0

1 year ago