{"_id":"15puzzle-utils","_rev":"2-23c78cd105a36bc8a4b382feab7f00a0","name":"15puzzle-utils","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"15puzzle-utils","version":"1.0.0","keywords":["15-puzzle","nxm-puzzles"],"author":{"name":"ebrancati"},"license":"MIT","_id":"15puzzle-utils@1.0.0","maintainers":[{"name":"ebrancati","email":"enzobrancati04@gmail.com"}],"homepage":"https://ebrancati.github.io/15puzzle-utils/","bugs":{"url":"https://github.com/ebrancati/15puzzle-utils/issues/"},"dist":{"shasum":"1229ab34fbe39ddcf6fbd92322f749e074faa55f","tarball":"https://registry.npmjs.org/15puzzle-utils/-/15puzzle-utils-1.0.0.tgz","fileCount":18,"integrity":"sha512-DC1f1aAjjVa9+uNTfu51ZM0DVcNzqTuPytGyqVwmP+GKunlNG1Z2tOMnn50AII5eYYuhTx+GCdb9BVJKQ1ALnw==","signatures":[{"sig":"MEQCIHJtzWPTMJ6u5UmS01mbhhv0vC67Q8GPMqkIVSkvy19NAiAxJKvB/s6BKNJyBOdWVTBVRcniWKbAt9oNUepKym0Deg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":41240},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"c147729e09d2d37a622c79e3c53212dae3169c78","scripts":{"test":"vitest run","build":"tsc","build:docs":"esbuild docs/script.ts --bundle --minify --outfile=docs/assets/script.js --format=esm","prepublishOnly":"npm run build && npm test"},"_npmUser":{"name":"ebrancati","email":"enzobrancati04@gmail.com"},"repository":{"url":"git+https://github.com/ebrancati/15puzzle-utils.git","type":"git"},"_npmVersion":"11.12.1","description":"Sliding puzzle utility library","directories":{},"_nodeVersion":"22.16.0","_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.0.18","esbuild":"^0.27.4","typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/15puzzle-utils_1.0.0_1774983661414_0.5643389423145668","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"15puzzle-utils","version":"1.0.1","description":"Sliding puzzle utility library","keywords":["15-puzzle","nxm-puzzles"],"author":{"name":"ebrancati"},"license":"MIT","homepage":"https://ebrancati.github.io/15puzzle-utils/","repository":{"type":"git","url":"git+https://github.com/ebrancati/15puzzle-utils.git"},"bugs":{"url":"https://github.com/ebrancati/15puzzle-utils/issues/"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsc","build:docs":"esbuild docs/script.ts --bundle --minify --outfile=docs/assets/script.js --format=esm","test":"vitest run","prepublishOnly":"npm run build && npm test"},"devDependencies":{"esbuild":"^0.27.4","typescript":"^5.9.3","vitest":"^4.0.18"},"gitHead":"a793e7e55ef3c8fdd1d6cf82c048321af8dc7beb","_id":"15puzzle-utils@1.0.1","_nodeVersion":"22.16.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-KKhEflMAAdBGSYy/g4X7mK3+xAqSoOuEiZXn000MQuogSHshXO2sM+QczGE6mLhIRX/DVFGK77pgdttauZjw8w==","shasum":"9ead6c36c0a9712f6d780a0fae3b39e26a40484e","tarball":"https://registry.npmjs.org/15puzzle-utils/-/15puzzle-utils-1.0.1.tgz","fileCount":18,"unpackedSize":41299,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIG4J8PVqz4p3ZXHIP3XGDXdKB1TXX9uYyS7+e/4kCitsAiEAnzAqH/v4Yo7kn7URfqBNwsuV4iGd9yAyCv5lqeNHKcI="}]},"_npmUser":{"name":"ebrancati","email":"enzobrancati04@gmail.com"},"directories":{},"maintainers":[{"name":"ebrancati","email":"enzobrancati04@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/15puzzle-utils_1.0.1_1775501540712_0.43726319404055225"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-31T19:01:01.283Z","modified":"2026-04-06T18:52:21.258Z","1.0.0":"2026-03-31T19:01:01.574Z","1.0.1":"2026-04-06T18:52:20.861Z"},"bugs":{"url":"https://github.com/ebrancati/15puzzle-utils/issues/"},"author":{"name":"ebrancati"},"license":"MIT","homepage":"https://ebrancati.github.io/15puzzle-utils/","keywords":["15-puzzle","nxm-puzzles"],"repository":{"type":"git","url":"git+https://github.com/ebrancati/15puzzle-utils.git"},"description":"Sliding puzzle utility library","maintainers":[{"name":"ebrancati","email":"enzobrancati04@gmail.com"}],"readme":"# 15puzzle-utils\n\nUtility library for creating and manipulating sliding puzzles\n\n## Installation\n\n```bash\nnpm install 15puzzle-utils\n```\n\n## Usage\n\n```ts\nimport { Puzzle } from '15puzzle-utils';\n\n// Pick one of these constructors:\nconst puzzle = new Puzzle();     // 4x4, randomly shuffled\nconst puzzle = new Puzzle(3, 5); // custom size, randomly shuffled\nconst puzzle = new Puzzle([\n    [1, 2, 3],\n    [4, 5, 6],\n    [7, 8, 0]\n]); \n\n// Methods\npuzzle.isSolved()         // true when puzzle is complete\npuzzle.isSolvable()       // true when puzzle can be solved\npuzzle.canSlide(row, col) // check if tile can slide\npuzzle.slide(row, col)    // slide tile toward empty space\npuzzle.getGrid()          // current state as number[][]\npuzzle.getWidth()         // number of columns\npuzzle.getHeight()        // number of rows\npuzzle.getValue(row, col) // value at a specific cell\npuzzle.getEmptyPosition() // { row, col } of the empty tile\npuzzle.toAsciiString()    // text representation\n```\n\n## Error Handling\n\nAll errors extend `PuzzleError`, so you can catch them generically or handle specific cases:\n\n```ts\nimport { Puzzle, PuzzleError, BlockedPathError } from '15puzzle-utils';\n\n// Catch any puzzle error\ntry {\n    puzzle.slide(row, col);\n} catch (e) {\n    if (e instanceof PuzzleError) { ... }\n}\n\n// Or handle specific cases\ntry {\n    puzzle.slide(row, col);\n} catch (e) {\n    if (e instanceof BlockedPathError) { ... }\n}\n```\n\n| Error | Thrown by |\n|---|---|\n| `InvalidDimensionError` | `constructor(width, height)`, `constructor(grid)` invalid width/height |\n| `InvalidGridContentError` | `constructor(grid)` duplicate or out-of-range tile values |\n| `InvalidPositionError` | `slide(row, col)`, `getValue(row, col)` row/col out of bounds |\n| `EmptyTileSlideError` | `slide(row, col)` target cell is the empty tile |\n| `BlockedPathError` | `slide(row, col)` tile not in same row or column as empty space |\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md"}