{"name":"time-ordered-set","version":"2.0.0","author":{"url":"@mafintosh","name":"Mathias Buus"},"license":"MIT","_id":"time-ordered-set@2.0.0","homepage":"https://github.com/mafintosh/time-ordered-set","bugs":{"url":"https://github.com/mafintosh/time-ordered-set/issues"},"dist":{"shasum":"a6c4f57827ee23701fc122118eb71be7b3c4453a","tarball":"http://registry-npm.ywwl.com/time-ordered-set/download/time-ordered-set-2.0.0.tgz","fileCount":7,"integrity":"sha512-bW/y+G3xukNDhPcnzNujiB3uS7OInWUUegWQ0hccbCShDaMP7ftO0A0DiGZAytU8kgRSPY3ot96EAYVrp3yrnQ==","signatures":[{"sig":"MEQCIHAvM04Q/PAKbwQY+Yvc5dvmW+YskQmwHyzAO2IOh2BrAiA5SczKg4dJdwLwFResXA/S0jaP0g1MAIwhCeWUg+1FIQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7727,"size":2713,"noattachment":false,"key":"/time-ordered-set/-/time-ordered-set-2.0.0.tgz"},"main":"index.js","gitHead":"f8e507ab5a784b752dd915a0d899b952ccf7a50b","scripts":{"test":"standard && brittle test.js"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"repository":{"url":"git+https://github.com/mafintosh/time-ordered-set.git","type":"git"},"_npmVersion":"10.7.0","description":"Efficiently maintain a set of nodes ordered by the time they were added to the set","directories":{},"_nodeVersion":"20.11.1","_hasShrinkwrap":false,"devDependencies":{"brittle":"^3.0.0","standard":"^17.1.2"},"_npmOperationalInternal":{"tmp":"tmp/time-ordered-set_2.0.0_1727083357410_0.40016731758585244","host":"s3://npm-registry-packages"},"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":1727083357593,"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_cnpm_publish_time":1727083357593,"dist-tags":{"latest":"2.0.1"}}