{"version":3,"file":"memoize.mjs","names":[],"sources":["../src/memoize.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n                       🗲 Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website:                  https://stormsoftware.com\n Repository:               https://github.com/storm-software/stryke\n Documentation:            https://docs.stormsoftware.com/projects/stryke\n Contact:                  https://stormsoftware.com/contact\n\n SPDX-License-Identifier:  Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Memoizes a function based on its string identifier.\n *\n * @param fn - The function to memoize.\n * @returns A memoized version of the input function.\n */\nexport const memoizeOnId = <T>(fn: (id: string) => T) => {\n  // eslint-disable-next-line ts/unbound-method\n  const hasOwnProperty = Object.prototype.hasOwnProperty;\n  const results: Record<string, T> = {};\n\n  const memoizedFn = (id: string) => {\n    if (hasOwnProperty.call(results, id)) {\n      return results[id];\n    }\n    return (results[id] = fn(id));\n  };\n\n  return memoizedFn;\n};\n"],"mappings":";;;;;;;AAwBA,MAAa,eAAkB,OAA0B;CAEvD,MAAM,iBAAiB,OAAO,UAAU;CACxC,MAAM,UAA6B,EAAE;CAErC,MAAM,cAAc,OAAe;AACjC,MAAI,eAAe,KAAK,SAAS,GAAG,CAClC,QAAO,QAAQ;AAEjB,SAAQ,QAAQ,MAAM,GAAG,GAAG;;AAG9B,QAAO"}