{"_id":"@cadienvan/memoize","name":"@cadienvan/memoize","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@cadienvan/memoize","private":false,"version":"1.0.0","description":"A low footprint function which takes another function as an input and caches the result of that function based on given arguments.","main":"index.js","type":"module","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["cache","function","memoize","memoization","memoization function","async","async function"],"author":{"name":"Michael Di Prisco"},"repository":{"type":"git","url":"git://github.com/Cadienvan/memoize.git"},"license":"MIT","bugs":{"url":"https://github.com/Cadienvan/memoize/issues"},"homepage":"https://github.com/Cadienvan/memoize#readme","_id":"@cadienvan/memoize@1.0.0","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"integrity":"sha512-cr7tddSZdkVz1prNuPvahnIiH6yzrdIskJuw+R96lPvRwhum40oSy2lM1sEpPN2qFdMqE7f217WJWlkneOBWyw==","shasum":"0acc0741fb6e79c246b0ab1570742b3123531291","tarball":"https://registry.npmjs.org/@cadienvan/memoize/-/memoize-1.0.0.tgz","fileCount":3,"unpackedSize":2831,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBBkYoBOBiU7U4ihcotBmhDHK071j/Nb03kCduf2SnsyAiEAqOTiFig3oZ9vHtm9BeA2kD2rQJ/6OAyl/mv4nWGNXyo="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjQ9+CACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrTtQ/7BMkX+mOHIF6HJe3J7k62aZJ1QLCcAkestCDfuzLlYg57pZAu\r\n/T9/Ko0fX0+OaMhtzOpLXmbb/xYJW3NlpPtgURnTD/AKed6TvhANbY6J7/UW\r\nJa3cQH/xB8BuC2g92iUWRiFZBKF80ozUd1PKvJt7kx2AWZfJzzZfJSjlWgLs\r\nu5/CBY/SlbAhpkgsU5dGUFTC2SfbezQFEkQ7TeX5rHqwssXr7wzW93Mj1QtX\r\nGBEIr6kCGx+O0Ct0x183Gf88lwPAnXKCiv2LZ848IlLDrYOkRnOthOZfqA1q\r\n/LkRlMhCqjIeIMB9SAmq528z1YpnU7UNAAhMLO4N8cXjbwwUDSM11RdTLlbU\r\nC3wB8e7XkIorcliitPpvQHMi0572Y8zPgbcNqgK5EGZ8W/MW5aqiW65MatFb\r\nfRawEEOqxHGC1W7kxAurFBq48HiuAy7jyG6jDqRKkMf1ll5NY44RoQTE+NV3\r\n8bKdrZinD8vZv8S+XNMQF+2Hpo63HkEO+STDuWKcL/JfE3XKapB/zJ/qV1T5\r\nP6ON0OzgIj4td8c/SbRM1dsidcRqSmxQjEa6kvHnHScC3kiW5CVAWE3/5UIV\r\nLQpmlOQYclYWkMIQ7chWQi29Ocu/uCgiAujGv0rGCkQBfEsNt+unO6Uw9vfO\r\nqSLt/eVlnC2wwp8RlORV6vSGqtiz9/0k1Vc=\r\n=6m/Y\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"cadienvan","email":"cadienvan@gmail.com"},"directories":{},"maintainers":[{"name":"cadienvan","email":"cadienvan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/memoize_1.0.0_1665392514535_0.8990883745254106"},"_hasShrinkwrap":false}},"time":{"created":"2022-10-10T09:01:54.455Z","1.0.0":"2022-10-10T09:01:54.697Z","modified":"2022-10-10T09:01:54.846Z"},"maintainers":[{"name":"cadienvan","email":"cadienvan@gmail.com"}],"description":"A low footprint function which takes another function as an input and caches the result of that function based on given arguments.","homepage":"https://github.com/Cadienvan/memoize#readme","keywords":["cache","function","memoize","memoization","memoization function","async","async function"],"repository":{"type":"git","url":"git://github.com/Cadienvan/memoize.git"},"author":{"name":"Michael Di Prisco"},"bugs":{"url":"https://github.com/Cadienvan/memoize/issues"},"license":"MIT","readme":"# What is this?\n\nThis is a low footprint function which takes another function as an input and caches the result of that function based on given arguments.\n\n# How do I install it?\n\nYou can install it by using the following command:\n\n```bash\nnpm install @cadienvan/memoize\n```\n\n# How to use it?\n\nSimply import the module and start using it as follows:\n\n```js\nimport { memoize } from \"@cadienvan/memoize\";\nfunction testFn(n, n2) {\n  for (let i = 0; i < n * n2; i++) {}\n\n  return true;\n}\n\nconst testFnCached = memoize(testFn);\n// You can use the function as you would normally\ntestFnCached(100, 100); // Same as tesfFn(100, 100)\n```\n\nThe testFnCached will now cache the result of the testFn function based on the arguments passed to it.\n\n# Does this package support async functions?\n\nYes, it does. Just import the `memoizeAsync` function instead of the `memoize` function.\n\n```js\nimport { memoizeAsync } from \"@cadienvan/memoize\";\nasync function testFn() {\n  await new Promise((resolve) => setTimeout(resolve, 1000));\n  return true;\n}\nconst testFnCached = memoize(testFn);\nawait testFnCached(); // Same as await tesfFn()\n```\n\n# How does this work?\n\nThis package uses the `JSON.stringify` function to convert the arguments passed to the function into a string. This string is then used as a key to store the result of the function in a cache object. The next time the function is called with the same arguments, the result will be retrieved from the cache object instead of calling the function again.\n","readmeFilename":"README.md"}