0.0.4 • Published 4 years ago

obj-uuid v0.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

obj-uuid

This module is deprecated

The main reason is because the name is very misleading

Important caveat: it does generate ids in the uuid format, but it is not universal. It is unique only for the current process

This module translate any object/js value to an unique identifier (string). For objects it generate a random id and stores it in a WeakMap. So it is consistent within the same process and it can be easily garbage collected.

How to use it

const objUUID = require('obj-uuid');
const a = {};
const b = {};
objUUID.getIdFromValue(a) === objUUID.getIdFromValue(a);
objUUID.getIdFromValue(a) !== objUUID.getIdFromValue(b);

You can get an id for an array of values:

objUUID.getIdFromValues([a, b]) === objUUID.getIdFromValues([a, b]);
objUUID.getIdFromValues([a, b]) !== objUUID.getIdFromValues([b, a]);

Or for an object:

objUUID.getIdFromAttributes({ a: a, b: b }) === objUUID.getIdFromAttributes({ b: b, a: a });
objUUID.getIdFromAttributes({ a: a, b: b }) !== objUUID.getIdFromAttributes({ a: a });
0.0.4

4 years ago

0.0.3

5 years ago

0.0.2

6 years ago

0.0.1

6 years ago