can-cid
Utility for getting a unique identifier for an object.
cid(object, optionalObjectType)
Get a unique identifier for the object, optionally prefixed by a type name.
Once set, the unique identifier does not change, even if the type name changes on subsequent calls.
var cid = require("can-cid");
var x = {};
var y = {};
console.log(cid(x, "demo")); // -> "demo1"
console.log(cid(x, "prod")); // -> "demo1"
console.log(cid(y)); // -> "2"
Parameters
- object
{Object}
:The object to uniquely identify.
- name
{String}
:An optional type name with which to prefix the identifier
Returns
{String}
:
Returns the unique identifier