{"_id":"@bluelibs/ordered-lists","_rev":"1-be920a40bad7ef0fc09838c2384071e8","name":"@bluelibs/ordered-lists","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@bluelibs/ordered-lists","version":"1.0.0","description":"Performance-focused in-memory append-only ordered lists","main":"dist/index.js","repository":{"type":"git","url":"git+https://github.com/bluelibs/bluelibs.git"},"scripts":{"build":"tsc","watch":"tsc -w","benchmark":"ts-node ./src/benchmarks/index.ts","pretest":"npm run build","test":"jest --verbose dist/__tests__/index.js","test:dev":"jest --verbose src/__tests__/index.ts --watch","test:clean":"jest --clearCache","testonly":"npm test","test:ci":"npm run coverage -- --ci --maxWorkers=2  --reporters=default --reporters=jest-junit","coverage":"npm test -- --coverage","coverage:upload":"codecov","prepublishOnly":"npm run build","gen-doc":"typedoc ./src/index.ts --exclude ./src/__tests__ --out typeDocs --tsconfig tsconfig.json"},"devDependencies":{"@types/graphql":"^0.11.3","@types/jest":"^27.0.1","@types/node":"^14.17.12","@typescript-eslint/eslint-plugin":"2.3.0","@typescript-eslint/parser":"2.3.0","eslint":"^6.6.0","eslint-config-prettier":"6.3.0","eslint-plugin-prettier":"3.1.1","jest":"^27.0.0","jest-junit":"^10.0.0","prettier":"^2.0.5","source-map-support":"^0.5.13","ts-jest":"^27.0.3","typescript":"^4.0.2"},"typings":"dist/index.d.ts","typescript":{"definition":"dist/index.d.ts"},"license":"MIT","gitHead":"fbb0f725fed3abb4db37c5b0c3119912557d96b8","bugs":{"url":"https://github.com/bluelibs/bluelibs/issues"},"homepage":"https://github.com/bluelibs/bluelibs#readme","_id":"@bluelibs/ordered-lists@1.0.0","_nodeVersion":"15.12.0","_npmVersion":"7.20.1","dist":{"integrity":"sha512-1z9r2XGtWUNxNfyJdupllasFXzFV7GsL/vAI9ZqEUiFAzNLHKcvc9jNPWXVPfMIFCiMfQyw+DE9L7viYqBx3Tw==","shasum":"f5042b21aa5e3763d18c76863e6914e5b05c4fc1","tarball":"https://registry.npmjs.org/@bluelibs/ordered-lists/-/ordered-lists-1.0.0.tgz","fileCount":27,"unpackedSize":30117,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhKiuMCRA9TVsSAnZWagAAtqsP/jsKn0De8YWnqq3cNVwv\np/UfExmxEckUVp1VcUzLoLk4b6BKdd7k1XAuzUMD98qMNDV9vrU1BJvRgtkb\nfwnkU1IMfHSrFIiTQW3FYPEJMDGPGDzQz4wpgZO1PTQW/AErAGa8o9uyq76A\nIAWuilD1BAZpsNn0BunOR1DpR5G7Wu7pfQhaNDm3E8rFQ17w51c+/7hWA2Qd\nvMONkWRFrW2u8JukiEHVpYVy6Bgyn26yDfyYvgfXbP/tOmvCLsZDJosqo8Ym\nbZLXyxzrm+53062eCJEHka/kapmpbwVzCyL3gp37gn+sxku7GXO9jxNI6wkg\nW+a+rCrPFgHCBSSetIfXmfjeelQxGT1bdXlXXd/TLcwliO/SgcAJwbrEznLW\n6FRneLqPY5aNjnWzP1cAhLt3Ypm/6oSvpvSh7NK/J7RcjyTo0BXxw6qPZeWa\nTkD4OSbwjeOsDsYMCD+o3ana30e4qlD6PNnSZwdVHLdebw62457FIrahXRY/\nquNVpKiJWRjVRU9YN2Hchk4bDqhV7aV2u4RI2uCWt9FcedTfoSz+Vr1ZEBFt\n8Zh/2fZTelPotNPS4L8aukNzFwHQOQHUryiI4J7zPPu5wk9NwNdyjBRs8v4t\nNbETtqyFmJ7ETQ/kkuDplVwjGSL8ljRmqpK3UEfNfT678RVtKWtots9dE5J5\nYgrk\r\n=KSqK\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA0TLsMsWoEJsVkfwSWGN1LpVTIQkfyGbIF0msmyfGqFAiA9Bw7Vez6rqVhz5ir/v/eJAEFo6Tl/cQ/V8BXi/02I3w=="}]},"_npmUser":{"name":"theodordiaconu","email":"diaconu.theodor@gmail.com"},"directories":{},"maintainers":[{"name":"theodordiaconu","email":"diaconu.theodor@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ordered-lists_1.0.0_1630153612333_0.5901240527402416"},"_hasShrinkwrap":false}},"time":{"created":"2021-08-28T12:26:52.295Z","1.0.0":"2021-08-28T12:26:52.671Z","modified":"2022-04-04T19:48:52.967Z"},"maintainers":[{"name":"theodordiaconu","email":"diaconu.theodor@gmail.com"}],"description":"Performance-focused in-memory append-only ordered lists","homepage":"https://github.com/bluelibs/bluelibs#readme","repository":{"type":"git","url":"git+https://github.com/bluelibs/bluelibs.git"},"bugs":{"url":"https://github.com/bluelibs/bluelibs/issues"},"license":"MIT","readme":"# Append-Only Performance-focused Ordered Lists\n\nThe application of these ordered lists (which work with any data type) which are suited when you have event-chains or functional chains that support injecting additional handlers to it in a specific order.\n\nFor example, you have an event, and to that event you attach certain handlers with a certain priority. Each event will hold its very own `OrderedList` of handlers so it knows exactly how to call them.\n\n## Install\n\n```bash\nnpm i -S @bluelibs/ordered-lists\n```\n\n## Benchmarks\n\n```ts\nnpm run benchmark\n```\n\nThe result for 1M records and `1000` orders tested on `M1` CPU:\n\n```\nTime elapsed for setting up the list: 28ms\nTime elapsed getting sorted elements: 72ms for ordering.\n```\n\n## Documentation\n\nThe `OrderedListCollection` is as performant having very little overhead over each individual collection sort.\n\nThe `OrderedList` is append-only and has two main ways of interraction `add()` and `elements()`:\n\n```ts\nimport { OrderedList, OrderedListCollection } from \"@bluelibs/ordered-lists\";\n\nconst orderedList = new OrderedList<string>();\n\norderedList.add(\"Hello\", 1);\norderedList.add(\"world!\", 2);\n\norderedList.elements().join(\" \"); // Hello world!\n```\n\nTypically `orderedList` are a sort-of \"compile-time\" built-up, as you construct your application logic. This means that after the initial configurations, you will no longer \"add\" to them. The solution is to `lock()` them so `elements()` get stored into memory in an ordered fashion and accessing it is instant.\n\n```ts\norderedList.lock();\norderedList.elements(); // instantly\n```\n\nYou can hook and watch when elements get added:\n\n```ts\norderedList.onAdd((element, order) => {\n  // Do something\n});\n```\n\nThe `OrderedListCollection` is responsible of getting your data from multiple ordered lists:\n\n```ts\nconst orderedList1 = new OrderedList<string>();\nconst orderedList2 = new OrderedList<string>();\n\nconst collection = new OrderedListCollection([orderedList1, orderedList2]);\n\ncollection.elements(); // Get all the elements ordered from both lists with their orders properly merged\n\ncollection.lock(); // This would store all elements() into memory and will no longer react to changes.\n```\n","readmeFilename":"README.md"}