{"id":30127716,"url":"https://github.com/sourceallies/javascript-data-structures","last_synced_at":"2025-08-10T17:10:04.649Z","repository":{"id":57140924,"uuid":"69260674","full_name":"sourceallies/javascript-data-structures","owner":"sourceallies","description":"A library of commonly used data structures for JavaScript interviews.","archived":false,"fork":false,"pushed_at":"2016-10-03T01:00:48.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-07T16:05:39.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sourceallies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-26T14:49:34.000Z","updated_at":"2017-12-02T18:33:26.000Z","dependencies_parsed_at":"2022-09-01T23:51:52.466Z","dependency_job_id":null,"html_url":"https://github.com/sourceallies/javascript-data-structures","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/sourceallies/javascript-data-structures","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourceallies%2Fjavascript-data-structures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourceallies%2Fjavascript-data-structures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourceallies%2Fjavascript-data-structures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourceallies%2Fjavascript-data-structures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sourceallies","download_url":"https://codeload.github.com/sourceallies/javascript-data-structures/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourceallies%2Fjavascript-data-structures/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269663702,"owners_count":24455828,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-08-10T17:10:03.376Z","updated_at":"2025-08-10T17:10:04.638Z","avatar_url":"https://github.com/sourceallies.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Since JavaScript doesn't have official implementations for any of the popular data\nstructures, this might come in handy when doing candidate interviews with JavaScript.\n\n## Installation\n\n```\nnpm i @sourceallies/data-structures --save-dev\n```\n\n## Data Structures\n\n### Stack\n\n```js\nimport {Stack} from '@sourceallies/data-structures';\n\nconst stack = new Stack();\n```\n\n| Function                 | Description                                                                                |\n|--------------------------|--------------------------------------------------------------------------------------------|\n| `stack.size()`           | Returns the size of the stack.                                                             |\n| `stack.push(element)`    | Adds `element` to the top of the stack.                                                    |\n| `stack.peek()`           | Returns the top element in the stack.  Throws an error if the stack is empty.              |\n| `stack.pop()`            | Returns and removes the top element in the stack.  Throws an error if the stack is empty.  |\n\n### Queue\n\n```js\nimport {Queue} from '@sourceallies/data-structures';\n\nconst queue = new Queue();\n```\n\n| Function                 | Description                                                                                |\n|--------------------------|--------------------------------------------------------------------------------------------|\n| `queue.size()`           | Returns the size of the queue.                                                             |\n| `queue.enqueue(element)` | Adds `element` to the back of the queue.                                                   |\n| `queue.peek()`           | Returns the next element in the queue.  Throws an error if the queue is empty.             |\n| `queue.dequeue()`        | Returns and removes the next element in the queue.  Throws an error if the queue is empty. |\n\n### Hashmap\n\n```js\nimport {Hashmap} from '@sourceallies/data-structures';\n\nconst hashmap = new Hashmap();\n```\n\n| Function                       | Description                                                                      |\n|--------------------------------|----------------------------------------------------------------------------------|\n| `hashmap.size()`               | Returns the number of key-value pairs in this map                                |\n| `hashmap.put(key, value)`      | Associates the given value with the given key in this map                        |\n| `hashmap.get(key)`             | Returns the value associated with this key, or `undefined` if it doesn't exist   |\n| `hashmap.getKeys()`            | Returns an array of all keys in this map                                         |\n| `hashmap.containsKey(key)`     | Returns `true` if the given key is present in this map                           |\n| `hashmap.containsValue(value)` | Returns `true` if this map contains one or more keys that map to the given value |\n| `hashmap.remove(key)`          | Removes the key-value pair, if present                                           |                                        |\n\n## License\n\n[Apache Public License v2.0](https://github.com/sourceallies/javascript-data-structures/blob/master/LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourceallies%2Fjavascript-data-structures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourceallies%2Fjavascript-data-structures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourceallies%2Fjavascript-data-structures/lists"}