{"name":"time-ordered-set","version":"2.0.1","description":"Efficiently maintain a set of nodes ordered by the time they were added to the set","main":"index.js","devDependencies":{"brittle":"^3.0.0","standard":"^17.1.2"},"scripts":{"test":"standard && brittle test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/time-ordered-set.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/time-ordered-set/issues"},"homepage":"https://github.com/mafintosh/time-ordered-set","_id":"time-ordered-set@2.0.1","gitHead":"b518c52066b1a7b8ba5ddf1711f90fd1c87a823e","_nodeVersion":"20.11.1","_npmVersion":"10.7.0","dist":{"integrity":"sha512-VJEKmgSN2UiOLB8BpN8Sh2b9LGMHTP5OPrQRpnKjvOheOyzk0mufbjzjKTIG2gO4A+Y+vDJ+0TcLbpUmMLsg8A==","shasum":"66327419aa983a6e8c8f9e1b6832f721462c95b7","tarball":"http://registry-npm.ywwl.com/time-ordered-set/download/time-ordered-set-2.0.1.tgz","fileCount":4,"unpackedSize":4460,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCyh28boKRlrwjUg3GK8RS33Byg//EheICLJSDqD69QigIhAMR4eFuVhhoZ7umv6w5KVrbIx4ox4OAVrvNikbcad7es"}],"size":2026,"noattachment":false,"key":"/time-ordered-set/-/time-ordered-set-2.0.1.tgz"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/time-ordered-set_2.0.1_1728398534141_0.9237152725200135"},"_hasShrinkwrap":false,"readme":"# time-ordered-set\n\nEfficiently maintain a set of nodes ordered by the time they were added to the set\n\n```\nnpm install time-ordered-set\n```\n\n## Usage\n\n``` js\nconst TOS = require('time-ordered-set')\nconst s = new TOS()\n\n// add 3 nodes\n\ns.add({\n  hello: 'world'\n})\n\nconst node = s.add({\n  hello: 'welt'\n})\n\ns.add({\n  hello: 'verden'\n})\n\n// re-add the 2nd one\n\ns.add(node)\nconsole.log(s.toArray().map(node => node.hello)) // ['world', 'verden', 'welt']\n```\n\n## API\n\n#### `const s = new TOS()`\n\nCreate a new set\n\n#### `node = s.add(node)`\n\nAdd a new node to the set. Will add the properties `node.next` and `node.prev` to the node.\nRe-adding the same node will move to the latest node.\n\n#### `node = s.remove(node)`\n\nRemove a node. Will set `node.next` and `node.prev` to `null`.\n\n#### `bool = s.has(node)`\n\nCheck if a node has been added.\n\n#### `const array = s.toArray([options])`\n\nGet an ordered array out of all the nodes, ordered from oldest to newest. Use `options.reverse: true` to get from newest to oldest. Set `options.limit: number` if you only want to get a subset.\n\n#### `s.oldest`\n\nProperty containing the oldest node.\n\n#### `s.latest`\n\nProperty containing the newest node.\n\n#### `s.length`\n\nProperty containing how many nodes are in the set.\n\n## License\n\nMIT\n","publish_time":1728398534369,"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_cnpm_publish_time":1728398534369,"dist-tags":{"latest":"2.0.1"}}