{"_rev":"3-2eba3f4cf634d383d79fa27dd32cada9","time":{"created":"2025-01-04T19:09:48.195Z","modified":"2025-01-04T19:09:48.818Z","0.1.0":"2025-01-04T18:59:21.559Z","0.1.1":"2025-01-04T19:09:48.480Z"},"_id":"@caelus-dts/linked-list","name":"@caelus-dts/linked-list","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.1":{"name":"@caelus-dts/linked-list","version":"0.1.1","description":"A TypeScript implementation of a doubly linked list data structure","publishConfig":{"registry":"https://registry.npmjs.org/"},"main":"dist/cjs/index.js","module":"dist/es/index.js","types":"dist/types/index.d.ts","scripts":{"build":"vite build","test":"jest --detectOpenHandles"},"keywords":["doubly linked list","linked list","dt","data structure"],"author":{"name":"Caelus"},"license":"MIT","exports":{".":{"types":"./dist/types/index.d.ts","require":"./dist/cjs/index.js","import":"./dist/es/index.js","default":"./dist/es/index.js"}},"dependencies":{"@caelus-dts/iterable":"^1.0.0"},"devDependencies":{"@types/jest":"^29.5.14","jest":"^29.7.0","ts-jest":"^29.2.5","vite":"^6.0.5","node-notifier":"^10.0.1","vite-plugin-dts":"^4.4.0"},"repository":{"url":"git+https://github.com/caelus-lab/caelus-dts-linked_list.git"},"bugs":{"url":"https://github.com/caelus-lab/caelus-dts-linked_list/issues"},"homepage":"https://github.com/caelus-lab/caelus-dts-linked_list#readme","_id":"@caelus-dts/linked-list@0.1.1","gitHead":"db853bca72e322d88e569c647958d3153f624176","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-ypjj0jpRU1KmQc+ju3KiWY3YdT0QvJ9hpShq9W8H0ODnq07VMvEbrLQjbli23d3pOGWly+QkghhldkHvhFsVgg==","shasum":"24ceccbdcb75a8bd3c64d0de7431e1705b6234f9","tarball":"https://registry.npmjs.org/@caelus-dts/linked-list/-/linked-list-0.1.1.tgz","fileCount":6,"unpackedSize":23733,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSLj5PAQslGe/rrgYUJcMkCwN7W/e+bq6w7KQpr4h1jwIhAO0vKic+6Ca8yFluQ+I3R3E+2dgEGGYjb5GiVnNWsYXc"}]},"_npmUser":{"name":"caelus-lib","email":"caelus.team@hotmail.com"},"directories":{},"maintainers":[{"name":"caelus-lib","email":"caelus.team@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/linked-list_0.1.1_1736017788315_0.9586876724148463"},"_hasShrinkwrap":false}},"maintainers":[{"name":"caelus-lib","email":"caelus.team@hotmail.com"}],"description":"A TypeScript implementation of a doubly linked list data structure","homepage":"https://github.com/caelus-lab/caelus-dts-linked_list#readme","keywords":["doubly linked list","linked list","dt","data structure"],"repository":{"url":"git+https://github.com/caelus-lab/caelus-dts-linked_list.git"},"author":{"name":"Caelus"},"bugs":{"url":"https://github.com/caelus-lab/caelus-dts-linked_list/issues"},"license":"MIT","readme":"# @caelus-dts/linked-list\r\n\r\n## Overview\r\nThe `LinkedList` class provides a robust implementation of a **doubly linked list** data structure in TypeScript. It allows dynamic resizing and offers a comprehensive set of methods for managing and manipulating the list's elements. This structure is particularly efficient for scenarios requiring frequent insertions and deletions.\r\n\r\n## Features\r\n\r\n- **Doubly Linked:** Elements are linked in both directions, enabling efficient traversal in both forward and reverse order.\r\n- **Dynamic Resizing:** The list grows and shrinks as needed, accommodating varying numbers of elements.\r\n- **Type-Safe:** Built using TypeScript generics, ensuring type safety and preventing common errors.\r\n- **Comprehensive API:** Provides a wide range of methods for adding, removing, searching, and accessing elements.\r\n- **Iterable:** Supports JavaScript's iterable protocol, allowing easy traversal using loops and other iterable methods.\r\n\r\n## Installation\r\n\r\n1) Using `npm`\r\n```shell\r\nnpm install @caelus-dts/linked-list\r\n```\r\n2) Using `yarn`\r\n```shell\r\nyarn add @caelus-dts/linked-list\r\n```\r\n3) Using `pnpm`\r\n```shell\r\npnpm add @caelus-dts/linked-list\r\n```\r\n\r\n## Usage\r\n\r\n```ts\r\nimport LinkedList from '@caelus-dts/linked-list';\r\n\r\nconst list = new LinkedList<number>(); // Create a new linked list of numbers\r\n\r\nlist.push(10, 20, 30); // Add elements to the end\r\nlist.unshift(5, 0);    // Add elements to the beginning\r\n\r\nconsole.log(list.first); // Output: 0\r\nconsole.log(list.last);  // Output: 30\r\n\r\nlist.remove(2);         // Remove the element at index 2\r\nconsole.log(list.toArray()); // Output: [0, 5, 20, 30]\r\n\r\nlist.clear(); // Clear the list\r\n\r\n\r\nconst customCompareList = new LinkedList<string>(null, (a, b) => a.toLowerCase() === b.toLowerCase()); //Case insensitive comparison\r\n\r\ncustomCompareList.push(\"apple\", \"Banana\", \"ORANGE\");\r\nconsole.log(customCompareList.contains(\"Orange\")); // Output: true (because of the custom compare function)\r\n\r\n\r\nfor (const value of list) {\r\n    console.log(value); // Iterate over the list\r\n}\r\n```\r\n\r\n## API Documentation\r\n\r\n### `constructor(values?: Iterable<T> | null, compareFunc?: CompareFunc<T>)`\r\nCreates a new `LinkedList`.\r\n- `values`: Optional initial values to populate the list. Can be any iterable.\r\n- `compareFunc`: Optional custom comparison function for methods like `contains`, `indexOf`, and `count`. Defaults to strict equality.\r\n### `size: number`\r\nGets the number of elements in the list.\r\n### `isEmpty: boolean`\r\nChecks if the list is empty.\r\n### `front: ListNode<T> | undefined`\r\nGets the first node in the list.\r\n### `back: ListNode<T> | undefined`\r\nGets the last node in the list.\r\n### `first: T | undefined`\r\nGets the value of the first element.\r\n### `last: T | undefined`\r\nGets the value of the last element.\r\n### `push(...elements: T[]): number`\r\nAdds elements to the end of the list.\r\n### `unshift(...elements: T[]): number`\r\nAdds elements to the beginning of the list.\r\n### `shift(): T | undefined`\r\nRemoves and returns the first element.\r\n### `pop(): T | undefined`\r\nRemoves and returns the last element.\r\n### `toArray(): T[]`\r\nConverts the list to an array.\r\n### `clear(): void`\r\nRemoves all elements from the list.\r\n### `insert(index: number, value: T): number`\r\nInserts an element at the specified index.\r\n### `remove(index: number): boolean`\r\nRemoves the element at the specified index.\r\n### `get(index: number): T | undefined`\r\nGets the element at the specified index.\r\n### `indexOf(value: T): number`\r\nFinds the first index of a value.\r\n### `contains(value: T): boolean`\r\nChecks if the list contains a value.\r\n### `count(value: T): number`\r\nCounts the occurrences of a value\r\n\r\n## Contributing\r\nContributions are welcome! Please fork the repository and submit a pull request.\r\n\r\n## License\r\n[MIT License](LICENSE)","readmeFilename":"README.md"}