{"_id":"@anthonyalbertyn/map-expire","_rev":"1-d24cb362810f98e25a71bace934d6107","name":"@anthonyalbertyn/map-expire","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@anthonyalbertyn/map-expire","version":"1.0.0","description":"Key value data structure with keys that expire","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/anthonyalbertyn/map-expire.git"},"keywords":["node","map","key","value","expire","expiry"],"author":{"name":"Anthony Albertyn"},"license":"MIT","bugs":{"url":"https://github.com/anthonyalbertyn/map-expire/issues"},"homepage":"https://github.com/anthonyalbertyn/map-expire#readme","gitHead":"47c2d033e252e28df4c8c2758ecc3cac7952267f","_id":"@anthonyalbertyn/map-expire@1.0.0","_nodeVersion":"14.15.2","_npmVersion":"8.1.4","dist":{"integrity":"sha512-6Qj2m2vK2ULEhZdxzeNpiq5RHFccwLjXpedfLtwE93a2QsUMVRkWySlv5R6wudyE089VK5uVnEJVSH5Qk2a5ug==","shasum":"89a917e9150d9b414232bbc31d7c4c110e423734","tarball":"https://registry.npmjs.org/@anthonyalbertyn/map-expire/-/map-expire-1.0.0.tgz","fileCount":6,"unpackedSize":5883,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiFsYFACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpUtA/+LEzcWUy/4NtoE1jItfSof8d1cmTYj9f+uXdrOk6hcCvqWuYL\r\n2FPwJDa7e9Z2CKsUARrTqxeZ1Arop6GycxiVOB349wbUYzeTUiDIGgdtNsPV\r\nC0J76oihUhyImrhRm1JdJWef89nzbGW8vyEMuKq2/bvA8p9zlQNGqFWetGFx\r\nRW+MwvX1DJm6KKT/c/t7v+a4uHKNH/hajACkPxjzNl3LqIZDSsR2JekBIIi3\r\n4gUk5v7dShpgYeCHJMN2dbaqHEm8LkHoepDwZFBTXv4bHDbCixCjy8aB4RcY\r\nE6QvGfYW/ZkfPJPrz/wAIOqfiXxQ+zS7pRmPtncHEIIdv6yO/laFsXX7yE/F\r\njEb+lIVAK3A5jaK53VzD0ouoe7u1+n/80J26PtuLupFxLeWR4lU1lalMBsHp\r\nXs4Yy1MtrZgIxg3oi2pAj7qx5yh+z1lBP6kV5khNbNHulAXQvLm8QIxzIifv\r\n1MiJScNQtV1XkusdVIacM8N32URHz69sTxE1DMkyX6TJtL29zC4tkBW4No1P\r\nmPLZhCVHGJQHjthOQoi3wKygaWlCoOv4nXnl9QOfSPggd5dV78A83IeJ2lIL\r\n1H/g/YmaQnJgbyaThAbxOp2X34yuyryqRr2PMLvNX1C1G2aYKkf4bmDkFgDl\r\nE/I3cc9Pcl3KO0zf66VllHee7Lhk877fYHQ=\r\n=pokx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICKo2ksMiGqbkowYzfRqhD6ENP+6LiNdh9mZ+AZBi5UUAiEA0C/0f6WTlBlRlUrrcjcTYO7a6X+jIDPPpeTz8ZjZ8OE="}]},"_npmUser":{"name":"anthonyalbertyn","email":"anthonyalbertyn@gmail.com"},"directories":{},"maintainers":[{"name":"anthonyalbertyn","email":"anthonyalbertyn@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/map-expire_1.0.0_1645659653750_0.700681737751585"},"_hasShrinkwrap":false}},"time":{"created":"2022-02-23T23:40:53.700Z","1.0.0":"2022-02-23T23:40:53.888Z","modified":"2022-04-04T14:21:41.351Z"},"maintainers":[{"name":"anthonyalbertyn","email":"anthonyalbertyn@gmail.com"}],"description":"Key value data structure with keys that expire","homepage":"https://github.com/anthonyalbertyn/map-expire#readme","keywords":["node","map","key","value","expire","expiry"],"repository":{"type":"git","url":"git+https://github.com/anthonyalbertyn/map-expire.git"},"author":{"name":"Anthony Albertyn"},"bugs":{"url":"https://github.com/anthonyalbertyn/map-expire/issues"},"license":"MIT","readme":"# map-expire\n\nA data structure that extends JavaScript Map class (map Object) to add functionality to allow keys to expire and their key values to be automatically removed from the data structure. Set one expiry time for the data structure keys and provide an optional callback to further process removed expired items.\n\nMIT License, see LICENSE for more details\n\n## Use cases\n\n* Use case 1: A simple queue that needs to get rid of old items\n* Use case 2: A key-value store that needs to get rid of old items\n\n## Getting started\n\n```npm install @anthonyalbertyn/map-expire```\n\n``` \n    const MapExpire = require(\"@anthonyalbertyn/map-expire\");\n\n    const expireInMilliseconds = 1000;\n\n    const myOptionalCallback((key, value) => {\n        // do something with the key and value\n        // after it has automatically expired\n        // and removed from the Map\n    });\n\n    // initialise data structure\n    const myMap = new MapExpire(expireInMilliseconds, myOptionalCallback);\n\n    // add data\n    const key = \"foo\";\n    const value = \"Bar\";\n\n    myMap.set(key, value);\n\n    // alias of set\n    myMap.push(key, value);\n\n    // in this case, key will be the same as the value\n    myMap.push(value);\n\n    // iterate over data same as Map class\n    myMap.forEach((item) => {\n        console.log(item);\n    });\n\n    // get value for a key\n    const result = myMap.get(\"foo);\n\n    // alias of delete\n    myMap.remove(\"foo\");\n    myMap.delete(\"foo\"); \n\n\n    // alias of has\n    console.log(myMap.contains(\"foo\"));\n    console.log(myMap.has(\"foo\"));\n\n    // clear all value\n    myMap.clear();\n\n    // get all keys\n    const keys = myMap.keys();\n\n    // get all values\n    const values = myMap.values();\n\n    // get all key, value pairs\n    const keyValuePairs = myMap.entries();\n\n```\n\n## More information\n\nSupports all features of the Map Object. For more information about the Map Object, including available methods, see [[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map]]\n\n## Maintainers\n\nThere is currently only one maintainer, Anthony Albertyn, and the plan is to keep this module simple, lightweight and if possible, resist adding more features unless there are good reasons to do so.\n","readmeFilename":"README.md"}