{"id":16252979,"url":"https://github.com/neki-dev/pathfinding-worker","last_synced_at":"2025-03-19T20:31:41.810Z","repository":{"id":249946914,"uuid":"832966014","full_name":"neki-dev/pathfinding-worker","owner":"neki-dev","description":"🧩 Fast node.js pathfinding on workers for grid-based games","archived":false,"fork":false,"pushed_at":"2024-09-13T10:42:20.000Z","size":476,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T11:09:04.691Z","etag":null,"topics":["astar","dijkstra","find","grid","navigation","node","path","pathfinding","way","worker"],"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/neki-dev.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":"2024-07-24T05:10:56.000Z","updated_at":"2024-11-01T17:22:36.000Z","dependencies_parsed_at":"2024-08-08T11:25:28.580Z","dependency_job_id":"07a85a06-294a-4f92-a3f4-d3ab571a237a","html_url":"https://github.com/neki-dev/pathfinding-worker","commit_stats":null,"previous_names":["neki-dev/pathfinding-worker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fpathfinding-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fpathfinding-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fpathfinding-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fpathfinding-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neki-dev","download_url":"https://codeload.github.com/neki-dev/pathfinding-worker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244501416,"owners_count":20462856,"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":["astar","dijkstra","find","grid","navigation","node","path","pathfinding","way","worker"],"created_at":"2024-10-10T15:15:34.638Z","updated_at":"2025-03-19T20:31:38.331Z","avatar_url":"https://github.com/neki-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 🧩 Pathfinding Worker\n[![Version](https://badgen.net/npm/v/pathfinding-worker)](https://npmjs.com/package/pathfinding-worker)\n[![Small size](https://img.badgesize.io/neki-dev/pathfinding-worker/main/dist/index.js)](https://github.com/neki-dev/pathfinding-worker/blob/main/dist/index.js)\n[![Build](https://github.com/neki-dev/pathfinding-worker/actions/workflows/build.yml/badge.svg)](https://github.com/neki-dev/pathfinding-worker/actions/workflows/build.yml)\n[![Test](https://github.com/neki-dev/pathfinding-worker/actions/workflows/test.yml/badge.svg)](https://github.com/neki-dev/pathfinding-worker/actions/workflows/test.yml)\n\nFast node.js pathfinding on workers for grid-based games.\n\n.\n\nDocumentation\n\n* [Install](https://github.com/neki-dev/pathfinding-worker?tab=readme-ov-file#install)\n* [General](https://github.com/neki-dev/pathfinding-worker?tab=readme-ov-file#general)\n* [Layers](https://github.com/neki-dev/pathfinding-worker?tab=readme-ov-file#layers)\n* [Finding](https://github.com/neki-dev/pathfinding-worker?tab=readme-ov-file#finding)\n* [Tile walkable](https://github.com/neki-dev/pathfinding-worker?tab=readme-ov-file#tile-walkable)\n* [Tile weight](https://github.com/neki-dev/pathfinding-worker?tab=readme-ov-file#tile-weight)\n* [Example](https://github.com/neki-dev/pathfinding-worker?tab=readme-ov-file#example)\n\n.\n\n## Install\n\n```sh\nnpm i pathfinding-worker\n```\n\n.\n\n## General\n\n### ⚡️ Create worker thread\n```ts\nconst pathfinding = new Pathfinding(\n  config: PathfindingConfig\n)\n```\n* `config` - _Pathfinding configuration_\n \n| Prop | Description | Default |\n| ---- | ----------- | ------- | \n| loopRate | Finding loop rate | 200 ms |\n| resourceLimits | Worker resource limits | - |\n\n### ⚡️ Terminate worker thread\n```ts\npathfinding.destroy()\n```\n\n.\n\n## Layers\n\n### ⚡️ Create a new layer of grid\n```ts\nconst layer = pathfinding.createLayer(\n  grid: PathfindingGrid,\n)\n```\n* `grid` - _Grid with walkable tiles_\n\n### ⚡️ Remove exist layer of grid\n```ts\nlayer.remove()\n```\n\n.\n\n## Finding\n\n### ⚡️ Create pathfinder task\n```ts\nconst idTask = layer.findPath(\n  config: PathfindingTaskConfig,\n  callback: PathfindingTaskCallback,\n)\n```\n* `config` - _Task configuration_\n \n| Prop | Description | Default |\n| ---- | ----------- | ------- |\n| from | Begin tile position | |\n| to | End tile position | |\n| diagonals | Allow diagonal directions | true |\n\n* `callback` - _Callback with result_\n\n### ⚡️ Cancel pathfinder task\n```ts\nlayer.cancel(id: number)\n```\n* `id` - _Task id_\n\n.\n\n## Tile walkable\n\n### ⚡️ Set walkable state\n```ts\nlayer.setWalkable(\n  position: PathfindingPosition,\n  value: number,\n)\n```\n* `position` - _Tile position_\n* `state` - _Walkable state_\n\n### ⚡️ Get walkable state\n```ts\nconst walkable = pathfinder.isWalkable(\n  position: PathfindingPosition,\n)\n```\n* `position` - _Tile position_\n\n.\n\n## Tile weight\n\n### ⚡️ Set weight\n```ts\nlayer.setWeight(\n  position: PathfindingPosition,\n  value: number,\n)\n```\n* `position` - _Tile position_\n* `value` - _New weight_\n\n### ⚡️ Reset weight\n```ts\nlayer.resetWeight(\n  position: PathfindingPosition,\n)\n```\n* `position` - _Tile position_\n\n### ⚡️ Get weight\n```ts\nconst weight = layer.getWeight(\n  position: PathfindingPosition,\n)\n```\n* `position` - _Tile position_\n\n.\n\n## Example\n\n```ts\nconst pathfinding = new Pathfinding({\n  loopRate: 500,\n});\n\nconst layer = pathfinding.createLayer([\n  [true, true,  true,  true],\n  [true, true,  false, true],\n  [true, false, false, true],\n  [true, false, false, false],\n]);\n\nlayer.findPath({\n  from: { x: 0, y: 0 },\n  to: { x: 3, y: 2 },\n}, ({ path, cost }) =\u003e {\n  console.log('Result path:', path);\n  console.log('Total cost:', cost);\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneki-dev%2Fpathfinding-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneki-dev%2Fpathfinding-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneki-dev%2Fpathfinding-worker/lists"}