{"id":20315248,"url":"https://github.com/sysread/ts-skewheap","last_synced_at":"2026-05-16T06:36:51.377Z","repository":{"id":44220806,"uuid":"163011124","full_name":"sysread/ts-skewheap","owner":"sysread","description":"A self-balancing heap with O(log n) performance written in TypeScript","archived":false,"fork":false,"pushed_at":"2022-02-11T00:30:35.000Z","size":54,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-08T06:16:03.606Z","etag":null,"topics":["heap","javascript","minheap","priority-queue","queue","skewheap","typescript"],"latest_commit_sha":null,"homepage":"","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/sysread.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-24T17:19:49.000Z","updated_at":"2021-01-29T15:31:20.000Z","dependencies_parsed_at":"2022-08-29T08:31:09.391Z","dependency_job_id":null,"html_url":"https://github.com/sysread/ts-skewheap","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sysread/ts-skewheap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2Fts-skewheap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2Fts-skewheap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2Fts-skewheap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2Fts-skewheap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sysread","download_url":"https://codeload.github.com/sysread/ts-skewheap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2Fts-skewheap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33092723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["heap","javascript","minheap","priority-queue","queue","skewheap","typescript"],"created_at":"2024-11-14T18:18:30.847Z","updated_at":"2026-05-16T06:36:51.360Z","avatar_url":"https://github.com/sysread.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nSkewHeap - a self-balancing min heap with O(log n) performance\n\n# SYNOPSIS\n\n```\nconst SkewHeap = require(\"skewheap\");\n\nconst q = new SkewHeap((a, b) =\u003e {\n  if (a \u003c b) return -1;\n  if (b \u003c a) return 1;\n  return 0;\n});\n\nfor (let i = 0; i \u003c 100; ++i) {\n  q.put(i);\n}\n\nwhile (!q.is_empty) {\n  const item = q.take();\n}\n```\n\n# DESCRIPTION\n\nA skew heap is a min heap (a priority queue) for which all destructive\noperations (`put`, `take`) are implemented in terms of a single function,\n`merge`.  Operations on a skew heap have an ammortized performance of O(log n)\n(in fact, it is slightly better than that). A skew heap's most interesting\ncharacteristic is the ability to quickly merge with another skew heap.\n\n# METHODS\n\n## new\n\nAccepts one parameter, a function taking two arguments, which it compares and\nreturns 1, 0, or -1. Returning -1 or 0 signifies that the first parameter is\nless than or equal to the second and should be ordered ahead of the second\nparameter.\n\n## size\n\nReturns the number of items in the queue.\n\n## is_empty\n\nReturns true if the queue has no items in it.\n\n## put\n\nPuts one or more items into the queue. Accepts a variable number of arguments.\nAll arguments must be comparable via the comparison function provided to the\nconstructor.\n\n```\nheap.put(42)\nheap.put(1, 2, 3, 4)\n```\n\n## take\n\nReturns the next item from the queue. If there are no items in the queue,\nreturns `undefined`.\n\n## drain\n\nDrains all items from the heap and returns them in an array.\n\n## merge\n\nNon-destructively merges another heap with this heap, returning a new heap\ncontaining all of the items in both heaps.\n\n```\nconst new_heap = one_heap.merge(another_heap);\n```\n\n## absorb\n\nDestructively absorbs all of the items in another heap. After calling this\nmethod, the other heap will be empty.\n\n```\none_heap.absorb(another_heap);\n```\n\n# AUTHOR\n\nJeff Ober \u003csysread@fastmail.fm\u003e\n\n# LICENSE\n\nCopyright 2018 Jeff Ober\n\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysread%2Fts-skewheap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysread%2Fts-skewheap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysread%2Fts-skewheap/lists"}