{"id":27643371,"url":"https://github.com/ondras/pasta","last_synced_at":"2026-02-15T10:36:49.496Z","repository":{"id":281162683,"uuid":"944395634","full_name":"ondras/pasta","owner":"ondras","description":"Pluggable A-STAr implementation in TypeScript","archived":false,"fork":false,"pushed_at":"2025-03-12T07:26:34.000Z","size":57,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-04T23:26:55.129Z","etag":null,"topics":["library","util"],"latest_commit_sha":null,"homepage":"https://jsr.io/@ondras/pasta","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ondras.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"ondras","custom":["https://www.buymeacoffee.com/ondras","https://www.paypal.com/donate/?hosted_button_id=7WXVKF3ZJ9FZE"]}},"created_at":"2025-03-07T09:20:41.000Z","updated_at":"2025-05-24T16:57:12.000Z","dependencies_parsed_at":"2025-04-24T00:13:26.730Z","dependency_job_id":"d5730df6-55b5-4409-ba82-3046f4012635","html_url":"https://github.com/ondras/pasta","commit_stats":null,"previous_names":["ondras/pasta"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ondras/pasta","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ondras%2Fpasta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ondras%2Fpasta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ondras%2Fpasta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ondras%2Fpasta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ondras","download_url":"https://codeload.github.com/ondras/pasta/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ondras%2Fpasta/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29475765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T10:25:47.032Z","status":"ssl_error","status_checked_at":"2026-02-15T10:25:01.815Z","response_time":118,"last_error":"SSL_read: 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":["library","util"],"created_at":"2025-04-24T00:13:23.309Z","updated_at":"2026-02-15T10:36:49.483Z","avatar_url":"https://github.com/ondras.png","language":"TypeScript","funding_links":["https://github.com/sponsors/ondras","https://www.buymeacoffee.com/ondras","https://www.paypal.com/donate/?hosted_button_id=7WXVKF3ZJ9FZE"],"categories":[],"sub_categories":[],"readme":"# Pasta: a pluggable A* implementation\n\n![](pasta-screenshot.png)\n\n[Wikipedia article about A*](https://en.wikipedia.org/wiki/A*_search_algorithm)\n\n## Usage\n\nBYOC -- Bring Your Own Context. The algorithm is decoupled from the underlying (graph? grid?) pathfindable data structure. You need to provide:\n\n  - a **cost** function that computes the cost of traveling from one node to another\n  - a **heuristic** function that estimates the cost of traveling from one node to the target ()\n  - a **neighbors** function that returns a set of neighbor nodes reachable from a given node\n\nIndividual nodes can be identified by any value -- just make sure that your `neighbors` implementation generates comparable identifiers.\n\nThis algorithm is using an *h-based tie breaking* to reduce the number of visited nodes for same-cost paths. According to [Amit-the-A*-guru](https://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html#breaking-ties), this is an idea by Steven van Dijk.\n\n```ts\nimport { pasta } from \"https://cdn.jsdelivr.net/gh/ondras/pasta@main/pasta.ts\";\n\nconst N = 5; // our graph is a 5x5 grid\n\nfunction taxicab(x1, y1, x2, y2) { return Math.abs(x1-x2) + Math.abs(y1-y2); }\n\nfunction cost(from, to) {\n  let [x1, y1] = from.split(\",\").map(Number);\n  let [x2, y2] = to.split(\",\").map(Number);\n  return taxicab(x1, y1, x2, y2);\n}\n\nfunction heuristic(from, to) {\n  return cost(from, to); // often, we can re-use the cost function as heuristic\n}\n\nfunction neighbors(node) {\n  let [x, y] = node.split(\",\").map(Number);\n  return [[-1,0],[1,0],[0,-1],[0,1]]\n    .map(([dx, dy]) =\u003e [x+dx, y+dy])\n    .filter(([x, y]) =\u003e x\u003e=0 \u0026\u0026 y\u003e=0 \u0026\u0026 x\u003cN \u0026\u0026 y\u003cN)\n    .map(xy =\u003e xy.join(\",\"));\n}\n\nlet options = { cost, neighbors, heuristic };\nlet path = pasta(\"0,0\", \"4,4\", options);\nconsole.log(path); // 0,0 -\u003e 1,0 -\u003e ... -\u003e 4,0 -\u003e 4,1 -\u003e ... -\u003e 4,4\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fondras%2Fpasta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fondras%2Fpasta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fondras%2Fpasta/lists"}