{"_id":"@starryinternet/map-memo","_rev":"6-2269f185c8eb6a57a84527c2e75b6ca7","name":"@starryinternet/map-memo","dist-tags":{"latest":"2.1.2"},"versions":{"2.1.1":{"name":"@starryinternet/map-memo","version":"2.1.1","description":"Generic memoization with Map and WeakMap","author":{"name":"Kevin Ennis"},"scripts":{"test":"grunt"},"main":"lib/map-memo.js","repository":{"type":"git","url":"git+https://github.com/StarryInternet/map-memo.git"},"bugs":{"url":"https://github.com/StarryInternet/map-memo/issues"},"keywords":["memoize","map","weakmap","es6"],"license":"MIT","engines":{"node":">= 4.0.0"},"devDependencies":{"eslint-config-starry":"2.0.0","eslint-plugin-starry":"2.0.0","grunt":"1.0.1","grunt-contrib-jshint":"1.0.0","grunt-eslint":"18.1.0","grunt-mocha-istanbul":"4.0.2","istanbul":"0.4.3","mocha":"2.5.3"},"gitHead":"199f259310de2f642ad4bb387ba900f61107cff9","homepage":"https://github.com/StarryInternet/map-memo#readme","_id":"@starryinternet/map-memo@2.1.1","_nodeVersion":"12.15.0","_npmVersion":"6.13.4","_npmUser":{"name":"kevincennis","email":"kennis84@gmail.com"},"dist":{"integrity":"sha512-oud8CtCi31GHCl7ZKBpz/s8PUbz3hcJWLX6Tw63jdfR8ggKZeocrxiOf8QdeC6jINYfV0L8rY4vQ5A/KrNd0pA==","shasum":"5ab42f20aea6e893d6a578668cc061504bcd5cc2","tarball":"https://registry.npmjs.org/@starryinternet/map-memo/-/map-memo-2.1.1.tgz","fileCount":9,"unpackedSize":9659,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRBZsCRA9TVsSAnZWagAAgPQQAJB2L38ye4KTlzBpOupn\n0Doye0l3aRi+OSBVpqUif9ZwCLtLUn8r//xqtJ3sDu/t3wrH0uprs6vQHQc8\nJXUAK+N65OvCm78Bu+fYqbRB96uvzZGVFdGGrdcgbe4XPh5yB1cf5jTpg0+w\nKoGPWxnkiD/6Z3ZPd9Sba14pVVTtNjoGg4+R5PW0LwpfpmTcNNMWCmW+jiGw\nfyukOnC97QvMN/NQ6S9a2ly+OHz6Y4ATt3bQOpm3PRNHvrnw1932ttdBRw89\nYgtroXhu2oVqLujqXzio3fuZGG2M3/Wkv1hUS5HMdvm+EavJOzpuvPJ+euZc\ng+XFNjI5TUZE3TPHE0t7M7SdSwSGb+cskJzzj5X5qWcouFfqXQy7VhCAvSwh\nnHvNOgEcLrvE5Hdz1Pzddp/UD/Nwho3B36DC7NRrMu9bR7iFKZh7clXupzOB\nFzwBAlDzfY6vb11gqlPwxJiIFMxN0ZaLFhcR6vY9zh0w7IkvW+hCBoJMSp9k\nBA/fv0+Z3Y8oHIhM24spcoELbK1ShIwxLBIDb/89pw72OSdsIt7zhoTk9F0k\n+I+LPhdx3FEoOgz+q//sL1dJPr/NkEphE1NOu87kIN1vpZ9H5q+r02jOp03/\nZxe3vvd2t6gDRZeoll6doSbkWMT2iAWctL8U23cwwTN9wYS2f/OrMeSZ6xet\ns52E\r\n=xtXf\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDYBgVpC3Gdf+RnfpU7m0LCPcq60oMJiDXtNoFsZKnU+gIgEW5TR0pjfVTFQAKpVJK3W96UsPav5Cm04i5UbS578DM="}]},"maintainers":[{"name":"spmurrayzzz","email":"stephen.patrick.murray@gmail.com"},{"name":"kevincennis","email":"kennis84@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/map-memo_2.1.1_1581520491835_0.810762076931256"},"_hasShrinkwrap":false},"2.1.2":{"name":"@starryinternet/map-memo","version":"2.1.2","description":"Generic memoization with Map and WeakMap","author":{"name":"Kevin Ennis"},"scripts":{"test":"grunt"},"main":"lib/map-memo.js","repository":{"type":"git","url":"git+https://github.com/StarryInternet/map-memo.git"},"bugs":{"url":"https://github.com/StarryInternet/map-memo/issues"},"keywords":["memoize","map","weakmap","es6"],"license":"MIT","engines":{"node":">= 4.0.0"},"devDependencies":{"eslint-config-starry":"2.0.0","eslint-plugin-starry":"2.0.0","grunt":"1.0.1","grunt-contrib-jshint":"1.0.0","grunt-eslint":"18.1.0","grunt-mocha-istanbul":"4.0.2","istanbul":"0.4.3","mocha":"2.5.3"},"gitHead":"199f259310de2f642ad4bb387ba900f61107cff9","homepage":"https://github.com/StarryInternet/map-memo#readme","_id":"@starryinternet/map-memo@2.1.2","_nodeVersion":"12.13.0","_npmVersion":"6.12.0","_npmUser":{"name":"kevincennis","email":"kennis84@gmail.com"},"dist":{"integrity":"sha512-wm1cKdawu6f+RCWF2Dtng9DfyhNA1edjmalE2LpFkZ+tC5qQG/qhl/W9qq8VTxeeVPmqkBboqqAQ0x0CoOZJxw==","shasum":"e83e0f24450de520ee135c08c84e05f67bba8256","tarball":"https://registry.npmjs.org/@starryinternet/map-memo/-/map-memo-2.1.2.tgz","fileCount":9,"unpackedSize":9723,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRBwmCRA9TVsSAnZWagAAWHsP/0S+MFyLiNOByq8dNk1j\nEoLJhPM4HsV3vGicWks6mErKsxNhw5/3eRNqFtibAfvfzBSel6jqixuH3O6P\nv2uxYC8xvOFqZdOmfplr4ar5bOERdAp2I0l1UxcY7RHcGHhmD6nuLLDjkRsR\n3fVn1dggCpMcoNYWLdqvHnSIP42EiDvCqBLa2rZNUG7r6/zZOeu4Wz5dFROg\n2KdPUl57Ha5RaHV/7ZRhLecmkSqCMtvP4f4CR5G3/1iq5mepfMTWJ4xZ+10j\nPEZoUxTQc8pCPQ4/Q8rpzV9ulkVCwrp6FwzLXelGU+OXph5y9tyy5ntys0SH\ncASe5FiPBqd2B2JLMvei0KSvBE+6xPYojU0o2cKzRzaiPB6/UWRcd57rkPww\n/U2LW7hV3xYWA57KESv1jajop23fQdJfoBNZiFdGbwMVgpj/C5ajMN9zxHyU\nsTzG9O1YqdHkotdUFy41FaUuELlcukkHuCoSLoEgKNJaJGW+mvLrY2X1aYhL\ncHOq3Un1hquQWyWduWdnwm8ft7Gc3nli8el1rZX2vJjrQamQl08KoaGfFvkd\nFZOjtK/FRxANoAmNNr26EUmn2tW836ofPFIOsx0ObHLLbcFudgP/nf9jO2Ja\nR7sDuEPjpoE0XH9qAIEjm/bbR12iXQH8wx6vkgusqi2ED/xEShLim1FNABo1\ndzn+\r\n=NON6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCBrdzJMKCN47HsWk3heoFQQByxp0cYLVbzbas+GnKPeAIhAPEKMWS4fh7b8xzcgrku/mztiYA0SMbBWRrgHp0ftTuF"}]},"maintainers":[{"name":"kevincennis","email":"kennis84@gmail.com"},{"name":"spmurrayzzz","email":"stephen.patrick.murray@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/map-memo_2.1.2_1581521958431_0.8651838780106607"},"_hasShrinkwrap":false}},"time":{"created":"2020-02-12T15:14:51.507Z","2.1.1":"2020-02-12T15:14:51.940Z","modified":"2022-04-07T02:13:58.789Z","2.1.2":"2020-02-12T15:39:18.536Z"},"maintainers":[{"email":"stephen.patrick.murray@gmail.com","name":"spmurrayzzz"},{"email":"kennis84@gmail.com","name":"kevincennis"}],"description":"Generic memoization with Map and WeakMap","homepage":"https://github.com/StarryInternet/map-memo#readme","keywords":["memoize","map","weakmap","es6"],"repository":{"type":"git","url":"git+https://github.com/StarryInternet/map-memo.git"},"author":{"name":"Kevin Ennis"},"bugs":{"url":"https://github.com/StarryInternet/map-memo/issues"},"license":"MIT","readme":"# map-memo\n\n[![Build Status](https://travis-ci.org/StarryInternet/map-memo.svg?branch=master)](https://travis-ci.org/StarryInternet/map-memo)\n\nGeneric memoization using `Map` and `WeakMap`.\n\n---\n\n### Installing\n\n```\nnpm install --save @starryinternet/map-memo\n```\n\n---\n\n### What/Why?\n\nMemoization in JavaScript has typically been limited to arguments\nwith primitive values, or by utilizing hacks such as stringifying objects.\n\nBy storing arguments using a series of nested cache objects backed by `Map`\nand `WeakMap`, `map-memo` is able to memoize functions with *any*\nargument types.\n\n---\n\n### Example\n\n```js\n'use strict';\n\nconst memoize = require('@starryinternet/map-memo');\n\nfunction loop( fn, n ) {\n  let v;\n\n  for ( let i = 0; i < n; ++i ) {\n    v = fn( i );\n  }\n\n  return v;\n}\n\nlet mem = memoize( loop );\n\nconsole.log( mem( Math.sqrt, 1e9 ) ); // slow\nconsole.log( mem( Math.sqrt, 1e9 ) ); // fast!\n```\n\n### Example with expire time in milliseconds\n\n```js\n'use strict';\n\nconst memoize = require('@starryinternet/map-memo');\n\nfunction getRandom() {\n  return Math.random();\n}\n\nlet mem = memoize( getRandom, { ttl: 1000 } );\nconsole.log( mem() );\nconsole.log( mem() ); // Same value as above\n\nsetTimeout( function() {\n  console.log( mem() ); // Different value\n}, 1001 );\n```\n\n### Example with asynchronous function\n\n```js\n'use strict';\n\nconst memoize = require('@starryinternet/map-memo');\n\nfunction loopAsync( fn, n ) {\n  return new Promise( ( resolve, reject ) => {\n    let v;\n\n    for ( let i = 0; i < n; ++i ) {\n      v = fn( i );\n    }\n\n    resolve( v );\n  });\n}\n\nlet mem = memoize( loopAsync );\n\nmem( Math.sqrt, 1e9 ).then( result => {\n  console.log( result ); // slow\n  mem( Math.sqrt, 1e9 ).then( console.log ); // fast!\n});\n```\n","readmeFilename":"README.md"}