{"id":21304943,"url":"https://github.com/maximilianmairinger/fastlinkedlist","last_synced_at":"2025-03-15T19:26:33.377Z","repository":{"id":57233026,"uuid":"313042274","full_name":"maximilianMairinger/fastLinkedList","owner":"maximilianMairinger","description":"General purpose, but clean doubly Linked List implementation for the web","archived":false,"fork":false,"pushed_at":"2023-05-25T23:02:12.000Z","size":71,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-23T17:04:38.360Z","etag":null,"topics":["double","doubly","doubly-linked-list","es2015","es6","fast","frontend","linked","list","web"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/fast-linked-list","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maximilianMairinger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-15T13:54:21.000Z","updated_at":"2021-12-12T17:19:25.000Z","dependencies_parsed_at":"2025-01-22T08:42:03.623Z","dependency_job_id":"f2cec4fd-5301-4166-a1fb-b897f632ee8e","html_url":"https://github.com/maximilianMairinger/fastLinkedList","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianMairinger%2FfastLinkedList","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianMairinger%2FfastLinkedList/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianMairinger%2FfastLinkedList/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianMairinger%2FfastLinkedList/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maximilianMairinger","download_url":"https://codeload.github.com/maximilianMairinger/fastLinkedList/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243779616,"owners_count":20346744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["double","doubly","doubly-linked-list","es2015","es6","fast","frontend","linked","list","web"],"created_at":"2024-11-21T16:16:26.082Z","updated_at":"2025-03-15T19:26:33.350Z","avatar_url":"https://github.com/maximilianMairinger.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fast linked list\n\nGeneral purpose, but clean doubly Linked List implementation for the web ([3.4kB](https://bundlephobia.com/package/fast-linked-list)), performing decently well in benchmarks.\n\n\u003e Please note that the length of the list is intentionally (by default) not being computed. `Token#remove()` has no way of mutating the length of the list, as it does not have a reference to it's parent list, only it's siblings. If you need this, use the `LengthLinkedList` export, that functions analog, but provides a length attribute. This is a tradeoff between performance and functionality.\n\n## Installation\n\n```shell\n $ npm i fast-linked-list\n```\n\n## Usage\n\nFor simple usage, the Token architecture is abstracted away.\n\n```ts\nimport LinkedList from \"fast-linked-list\"\n\nconst ls = new LinkedList(\"b\", \"c\")\nconst dElem = ls.push(\"a\")\nls.toArray() // [\"b\", \"c\", \"a\"]\n\ndElem.remove() // true (meaning successfully removed)\ndElem.remove() // false\n\nconst dElem2 = ls.unshift(dElem.value)\n\nfor (const elem of ls) {\n  console.log(elem) // \"a\", \"b\", \"c\"\n}\n\nls.reverse()\n\nconst addedElems = ls.pushBulk([\"x\", \"y\", \"z\"])\nls.toArray() // [\"c\", \"b\", \"a\", \"x\", \"y\", \"z\"]\n\naddedElems[1].remove()\nls.toArray() // [\"c\", \"b\", \"a\", \"x\", \"z\"]\n\nls.pop() // \"z\"\nls.shift() // \"c\"\nls.first // \"b\"\nls.last // \"x\"\n\nls.reverse().forEach((e) =\u003e {\n  console.log(e) // \"x\", \"a\", \"b\"\n})\n\nconst clone = new LinkedList(ls)\nls.clear()\n```\n\nNote that `reverse()` does not mutate the list, but only inverts all basic i/o functions of the list. E.g.: `push()` becomes `unshift()` and `first` becomes `last`. Hence the `reverse()` call performs with a time complexity of O(1).\n\n### Working with Tokens\n\nA Token can only exsist within one LinkedList. Appending it somewhere else will remove it from the current list.\n\n```ts\nimport LinkedList, { Token } from \"fast-linked-list\"\n\nconst ls1 = new LinkedList(\"ls\", \"1\")\nconst ls2 = new LinkedList(\"ls\", \"2\")\nconst token = new Token(\"added\")\n\nls1.pushToken(token); ls1.toArray() // [\"ls\", \"1\", \"added\"]\nls2.pushToken(token); ls2.toArray() // [\"ls\", \"2\", \"added\"]\nls1.toArray() // [\"ls\", \"1\"]\n\n\ntoken.insertBefore(\"before\")\nls2.toArray() // [\"ls\", \"1\", \"before\", \"added\"] \n\n\n// Search for a value whose Token is unknown and remove it. Preferably keep a reference to the token if you plan to remove it (as this is O(n)).\nls2.forEach((val, tok) =\u003e {\n  if (val === \"ls\") tok.remove()\n})\n```\n\n## Contribute\n\nAll feedback is appreciated. Create a pull request or write an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximilianmairinger%2Ffastlinkedlist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaximilianmairinger%2Ffastlinkedlist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximilianmairinger%2Ffastlinkedlist/lists"}