"use strict"; // This generates stable (for the lifetime of the process) identifiers for individual values, by identity - it's useful for correlating together eg. debug logs where pretty-printing the full values is impractical // FIXME: Move this out into its own dedicated package const nanoid = require("nanoid/non-secure").customAlphabet("1234567890abcdefghklmpqrsvxyz", 6); let knownValues = new WeakMap(); module.exports = function valueID(value) { if (value == null) { return value; } else { if (!knownValues.has(value)) { knownValues.set(value, nanoid()); } return knownValues.get(value); } };