All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.build.esm.memo.js.map Maven / Gradle / Ivy

The newest version!
{"version":3,"file":"memo.js","sources":["../../src/memo.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nexport type MemoFunc = [\n  // memoize\n  (obj: any) => boolean,\n  // unmemoize\n  (obj: any) => void,\n];\n\n/**\n * Helper to decycle json objects\n */\nexport function memoBuilder(): MemoFunc {\n  const hasWeakSet = typeof WeakSet === 'function';\n  const inner: any = hasWeakSet ? new WeakSet() : [];\n  function memoize(obj: any): boolean {\n    if (hasWeakSet) {\n      if (inner.has(obj)) {\n        return true;\n      }\n      inner.add(obj);\n      return false;\n    }\n    // eslint-disable-next-line @typescript-eslint/prefer-for-of\n    for (let i = 0; i < inner.length; i++) {\n      const value = inner[i];\n      if (value === obj) {\n        return true;\n      }\n    }\n    inner.push(obj);\n    return false;\n  }\n\n  function unmemoize(obj: any): void {\n    if (hasWeakSet) {\n      inner.delete(obj);\n    } else {\n      for (let i = 0; i < inner.length; i++) {\n        if (inner[i] === obj) {\n          inner.splice(i, 1);\n          break;\n        }\n      }\n    }\n  }\n  return [memoize, unmemoize];\n}\n"],"names":[],"mappings":"AAAA;AACA;;AASA;AACA;AACA;AACO,SAAS,WAAW,GAAa;AACxC,EAAE,MAAM,UAAW,GAAE,OAAO,OAAA,KAAY,UAAU;AAClD,EAAE,MAAM,KAAK,GAAQ,UAAW,GAAE,IAAI,OAAO,EAAC,GAAI,EAAE;AACpD,EAAE,SAAS,OAAO,CAAC,GAAG,EAAgB;AACtC,IAAI,IAAI,UAAU,EAAE;AACpB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AAC1B,QAAQ,OAAO,IAAI;AACnB;AACA,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;AACpB,MAAM,OAAO,KAAK;AAClB;AACA;AACA,IAAI,KAAK,IAAI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