UNPKG

proxyequal

Version:

A proxy based usage tracking and comparison

41 lines (34 loc) 1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.escapeKey = exports.unescapeKey = void 0; var dotReplacement = String.fromCharCode(1); // const symbolReplacement = String.fromCharCode(2); // // let escapeRefCount = 0; // const escapeReference = new WeakMap(); var unescapeRegexp = /\u0001/g; var dotRegexp = /\./g; var DOT_CHAR = '.'; var unescapeKey = function unescapeKey(key) { return key.replace(unescapeRegexp, DOT_CHAR); }; exports.unescapeKey = unescapeKey; var escapeKey = function escapeKey(key) { // if(type!=="string" || type!=="number"){ // const ref = escapeReference.get(key); // if(ref) { // return ref; // } // escapeRefCount++; // escapeReference.set(key, escapeRefCount); // const keyCode = symbolReplacement+escapeRefCount; // // return keyCode // } if (typeof key === "number") { return key; } return String(key).replace(dotRegexp, dotReplacement); }; exports.escapeKey = escapeKey;