{"id":51319253,"url":"https://github.com/echecsjs/pgn","last_synced_at":"2026-07-01T11:02:16.052Z","repository":{"id":43962515,"uuid":"254547267","full_name":"echecsjs/pgn","owner":"echecsjs","description":"PGN (Portable Game Notation) parser. Supports comments, variations, NAGs, and annotations.","archived":false,"fork":false,"pushed_at":"2026-06-30T13:04:16.000Z","size":10476,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-30T15:08:32.954Z","etag":null,"topics":["chess","parser","pgn","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@echecs/pgn","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/echecsjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null},"funding":{"github":["mormubis"]}},"created_at":"2020-04-10T04:57:06.000Z","updated_at":"2026-06-30T13:04:21.000Z","dependencies_parsed_at":"2026-03-15T02:03:37.796Z","dependency_job_id":null,"html_url":"https://github.com/echecsjs/pgn","commit_stats":{"total_commits":67,"total_committers":3,"mean_commits":"22.333333333333332","dds":0.6119402985074627,"last_synced_commit":"0c64b3129b1d5149462b7ea2d5a4309d7f7f708d"},"previous_names":["echecsjs/pgn"],"tags_count":55,"template":false,"template_full_name":null,"purl":"pkg:github/echecsjs/pgn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echecsjs%2Fpgn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echecsjs%2Fpgn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echecsjs%2Fpgn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echecsjs%2Fpgn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/echecsjs","download_url":"https://codeload.github.com/echecsjs/pgn/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echecsjs%2Fpgn/sbom","scorecard":{"id":502116,"data":{"date":"2025-08-11","repo":{"name":"github.com/mormubis/pgn","commit":"f8a86f116d023f2741617e3f5129ef314211cf49"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.9,"checks":[{"name":"Code-Review","score":-1,"reason":"Found no human activity in the last 15 changesets","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":10,"reason":"30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'contents' permission set to 'read': .github/workflows/release.yml:39","Warn: topLevel 'contents' permission set to 'write': .github/workflows/auto-merge.yml:7","Warn: no topLevel permission defined: .github/workflows/format.yml:1","Warn: no topLevel permission defined: .github/workflows/lint.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":3,"reason":"branch protection is not maximal on development and all release branches","details":["Info: 'allow deletion' disabled on branch 'main'","Info: 'force pushes' disabled on branch 'main'","Warn: 'branch protection settings apply to administrators' is disabled on branch 'main'","Warn: could not determine whether codeowners review is allowed","Warn: 'up-to-date branches' is disabled on branch 'main'","Info: status check found to merge onto on branch 'main'","Warn: PRs are not required to make changes on branch 'main'; or we don't have data to detect it.If you think it might be the latter, make sure to run Scorecard with a PAT or use Repo Rules (that are always public) instead of Branch Protection settings"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/format.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/format.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/format.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/format.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/format.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/format.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/lint.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/lint.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/test.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/test.yml/main?enable=pin","Info:   0 out of   9 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   5 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/release.yml:35"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":4,"reason":"6 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99","Warn: Project is vulnerable to: GHSA-x574-m823-4x7w","Warn: Project is vulnerable to: GHSA-4r4m-qw57-chr8","Warn: Project is vulnerable to: GHSA-xcj6-pq6g-qj4x","Warn: Project is vulnerable to: GHSA-356w-63v5-8wf4","Warn: Project is vulnerable to: GHSA-859w-5945-r5v3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T22:11:58.160Z","repository_id":43962515,"created_at":"2025-08-19T22:11:58.160Z","updated_at":"2025-08-19T22:11:58.160Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35003464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-01T02:00:05.325Z","response_time":130,"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":["chess","parser","pgn","typescript"],"created_at":"2026-07-01T11:02:15.143Z","updated_at":"2026-07-01T11:02:16.036Z","avatar_url":"https://github.com/echecsjs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/mormubis"],"categories":[],"sub_categories":[],"readme":"# PGN\n\n[![npm](https://img.shields.io/npm/v/@echecs/pgn)](https://www.npmjs.com/package/@echecs/pgn)\n[![Coverage](https://codecov.io/gh/echecsjs/pgn/branch/main/graph/badge.svg)](https://codecov.io/gh/echecsjs/pgn)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![Spec](https://img.shields.io/badge/Spec-FIDE-green.svg)](SPEC.md)\n\n**PGN** is a fast, lightweight TypeScript parser for\n[Portable Game Notation](http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm)\n— the standard format for recording chess games.\n\nIt parses PGN input into structured move objects with decomposed SAN, paired\nwhite/black moves, and full support for annotations and variations. Zero runtime\ndependencies. The smallest PGN parser on npm.\n\n| Package                | Pack size | Unpacked   |\n| ---------------------- | --------- | ---------- |\n| **`@echecs/pgn`**      | **42 KB** | **195 KB** |\n| `pgn-parser`           | 99 KB     | 606 KB     |\n| `@mliebelt/pgn-parser` | 148 KB    | 595 KB     |\n| `chess.js`             | 150 KB    | 724 KB     |\n\n## Why this library?\n\nMost PGN parsers on npm either give you raw strings with no structure, or fail\non anything beyond a plain game record. If you're building a chess engine,\nopening book, or game viewer, you need more:\n\n- **Decomposed SAN** — every move is parsed into `piece`, `from`, `to`,\n  `capture`, `promotion`, `check`, and `checkmate` fields. No regex on your\n  side.\n- **Paired move structure** — moves are returned as\n  `[moveNumber, whiteMove, blackMove]` tuples, ready to render or process\n  without further work.\n- **RAV support** — recursive annotation variations (`(...)` sub-lines) are\n  parsed into a `variants` tree on each move. Essential for opening books and\n  annotated games.\n- **NAG support** — symbolic (`!`, `?`, `!!`, `??`, `!?`, `?!`) and numeric\n  (`$1`–`$255`) annotations are surfaced as an `annotations` array. Essential\n  for Lichess and ChessBase exports.\n- **Multi-game files** — parse entire PGN databases in one call. Tested on files\n  with 3 500+ games.\n- **Fast** — built on a [Peggy](https://peggyjs.org/) PEG parser. Throughput is\n  within 1.1–1.2x of the fastest parsers on npm, which do far less work per move\n  (see [BENCHMARK_RESULTS.md](./BENCHMARK_RESULTS.md)).\n\nIf you only need raw SAN strings and a flat move list, any PGN parser will do.\nIf you need structured, engine-ready output with annotations and variations,\nthis is the one.\n\n## Installation\n\n```bash\nnpm install @echecs/pgn\n```\n\n## Quick Start\n\n```typescript\nimport parse from '@echecs/pgn';\n\nconst games = parse(`\n  [Event \"Example\"]\n  [White \"Player1\"]\n  [Black \"Player2\"]\n  [Result \"1-0\"]\n\n  1. e4 e5 2. Nf3 Nc6 3. Bb5 1-0\n`);\n\nconsole.log(games[0].moves[0]);\n// [1, { piece: 'pawn', to: 'e4', capture: false, ... }, { piece: 'pawn', to: 'e5', capture: false, ... }]\n```\n\n## Usage\n\n### `parse()`\n\nTakes a PGN string and returns an array of game objects — one per game in the\nfile.\n\n```typescript\nparse(input: string, options?: ParseOptions): PGN[]\n```\n\n### ~~`stream()`~~ (deprecated)\n\n\u003e **Deprecated.** Use `parse()` instead — it already handles multi-game input.\n\u003e `stream()` will be removed in the next major version. It emits a\n\u003e `console.warn` on first call.\n\n### `stringify()`\n\nConverts one or more parsed `PGN` objects back into a valid PGN string,\nproviding semantic round-trip fidelity.\n\n```typescript\nstringify(input: PGN | PGN[], options?: StringifyOptions): string\n```\n\nReconstructs SAN from `Notation` fields, re-serializes annotation commands\n(`[%cal]`, `[%csl]`, `[%clk]`, `[%eval]`) back into comment blocks, and\npreserves RAVs and NAGs. Pass `onWarning` to observe recoverable issues (e.g.\ninvalid castling destination, negative clock). `StringifyOptions` is a subset of\n`ParseOptions` — `onError` is not accepted since `stringify` never fails hard.\n\n```typescript\nimport parse, { stringify } from '@echecs/pgn';\n\nconst games = parse(pgnString);\nconst output = stringify(games); // valid PGN string\n```\n\n### Error handling\n\nBy default, `parse()` silently returns `[]` on parse failure. Pass an `onError`\ncallback to observe failures:\n\n```typescript\nimport parse, { type ParseError } from '@echecs/pgn';\n\nconst games = parse(input, {\n  onError(err: ParseError) {\n    console.error(\n      `Parse failed at line ${err.line}:${err.column} — ${err.message}`,\n    );\n  },\n});\n```\n\n`onError` receives a `ParseError` with:\n\n| Field     | Type     | Description                                |\n| --------- | -------- | ------------------------------------------ |\n| `message` | `string` | Human-readable description from the parser |\n| `offset`  | `number` | Character offset in the input (0-based)    |\n| `line`    | `number` | 1-based line number                        |\n| `column`  | `number` | 1-based column number                      |\n\n### Warnings\n\nPass `onWarning` to observe spec-compliance issues that do not prevent parsing:\n\n```typescript\nimport parse, { type ParseWarning } from '@echecs/pgn';\n\nconst games = parse(input, {\n  onWarning(warn: ParseWarning) {\n    console.warn(warn.message);\n  },\n});\n```\n\n`onWarning` receives a `ParseWarning` with the same fields as `ParseError`:\n`message`, `offset`, `line`, `column`.\n\nCurrently fires for:\n\n- Missing STR tags (`Black`, `Date`, `Event`, `Result`, `Round`, `Site`,\n  `White`) — emitted in alphabetical key order; position fields are nominal\n  placeholders\n- Move number mismatch (declared move number in the PGN text doesn't match the\n  move's actual position) — position fields are nominal placeholders\n- Result tag mismatch (`[Result \"...\"]` tag value differs from the game\n  termination marker) — position fields are nominal placeholders\n- Duplicate tag names — `line` and `column` point to the opening `[` of the\n  duplicate tag\n\nThe same option is accepted by `stringify()`.\n\n### PGN object\n\n```typescript\n{\n  meta:   Meta,      // tag pairs (Event, Site, Date, White, Black, …)\n  moves:  NotationList,  // paired notation list\n  result: 1 | 0 | 0.5 | '?'\n}\n```\n\n`meta` is an index of all tag pairs from the PGN header. The `Result` key is\noptional — games with no tag pairs return `meta: {}`. Use `game.result` (always\npresent) as the authoritative game outcome.\n\n### Notation object\n\n`Notation` extends `SAN` from [`@echecs/san`](https://github.com/echecsjs/san) —\nall SAN fields are always present.\n\n```typescript\n{\n  // SAN fields (always present)\n  piece:       Piece,        // 'pawn' | 'knight' | 'bishop' | 'rook' | 'queen' | 'king'\n  to:          Square | undefined, // destination square, e.g. \"e4\"; undefined for castling\n  from:        Disambiguation | undefined, // file \"e\", rank \"2\", or square \"e2\"\n  capture:     boolean,\n  castling:    boolean,\n  check:       boolean,\n  checkmate:   boolean,\n  long:        boolean,      // queenside castling\n  promotion:   PromotionPiece | undefined, // 'queen' | 'rook' | 'bishop' | 'knight'\n\n  // PGN-specific fields (optional)\n  annotations?: string[],   // e.g. [\"!\", \"$14\"]\n  comment?:    string,\n  arrows?:     Arrow[],              // from [%cal ...] command\n  squares?:    SquareAnnotation[],   // from [%csl ...] command\n  clock?:      number,               // from [%clk ...] — seconds remaining\n  eval?:       Eval,                 // from [%eval ...] — engine evaluation\n  variants?:   NotationList[],  // recursive annotation variations\n}\n```\n\nMoves are grouped into tuples: `[moveNumber, whiteMove, blackMove]`. Both move\nslots can be `undefined` — `whiteMove` when a variation begins on black's turn,\n`blackMove` when the game or variation ends on white's move.\n\n### Annotations and comments\n\n```pgn\n12. Nf3! $14 { White has a slight advantage }\n```\n\n```typescript\n{\n  piece: 'knight', to: 'f3', capture: false, castling: false,\n  check: false, checkmate: false, long: false,\n  from: undefined, promotion: undefined,\n  annotations: ['!', '14'],  // numeric NAGs stored without '$' prefix\n  comment: 'White has a slight advantage'\n}\n```\n\n### Comment annotations\n\nPGN files produced by GUIs and engines embed structured commands inside move\ncomments using the `[%cmd ...]` syntax. This library parses the four most common\ncommands and exposes them as dedicated fields on `Notation`:\n\n| Field     | Type                 | PGN command   | Description                                      |\n| --------- | -------------------- | ------------- | ------------------------------------------------ |\n| `arrows`  | `Arrow[]`            | `[%cal ...]`  | Coloured arrows drawn on the board               |\n| `squares` | `SquareAnnotation[]` | `[%csl ...]`  | Coloured square highlights                       |\n| `clock`   | `number`             | `[%clk ...]`  | Remaining time in seconds (sub-second preserved) |\n| `eval`    | `Eval`               | `[%eval ...]` | Engine evaluation (centipawns or mate-in-N)      |\n\nCommand strings are stripped from `move.comment`. Unknown `[%...]` commands are\nleft in the comment string unchanged.\n\n#### Types\n\n```typescript\ntype AnnotationColor = 'B' | 'C' | 'G' | 'O' | 'R' | 'Y'; // Blue, Cyan, Green, Orange, Red, Yellow\n\ninterface Arrow {\n  color: AnnotationColor;\n  from: Square; // e.g. \"e2\"\n  to: Square; // e.g. \"e4\"\n}\n\ninterface SquareAnnotation {\n  color: AnnotationColor;\n  square: Square; // e.g. \"e4\"\n}\n\ntype Eval =\n  | { type: 'cp'; value: number; depth?: number } // centipawn score\n  | { type: 'mate'; value: number; depth?: number }; // mate in N\n```\n\n#### Example\n\n```pgn\n1. e4 { [%cal Ge2e4,Re4e5] [%clk 0:05:00] } e5\n```\n\n```typescript\n{\n  piece: 'pawn', to: 'e4', capture: false, castling: false,\n  check: false, checkmate: false, long: false,\n  from: undefined, promotion: undefined,\n  // comment is absent — no free text remains after stripping commands\n  arrows: [\n    { color: 'G', from: 'e2', to: 'e4' },\n    { color: 'R', from: 'e4', to: 'e5' },\n  ],\n  clock: 300,    // 5 minutes in seconds\n}\n```\n\n### Variations\n\n```pgn\n5... Ba5 (5... Be7 6. d4) 6. Qb3\n```\n\nThe alternative line appears as a `variants` array on the move where it\nbranches:\n\n```typescript\n{\n  piece: 'bishop', to: 'a5', capture: false, castling: false,\n  check: false, checkmate: false, long: false,\n  from: undefined, promotion: undefined,\n  variants: [\n    [ [5, undefined, { piece: 'bishop', to: 'e7', ... }], [6, { piece: 'pawn', to: 'd4', ... }] ]\n  ]\n}\n```\n\n## Exported types\n\nAll public types are exported as named type exports:\n\n```typescript\nimport type {\n  AnnotationColor, // 'B' | 'C' | 'G' | 'O' | 'R' | 'Y'\n  Arrow, // { color, from, to }\n  Disambiguation, // Square | File | Rank\n  Eval, // { type: 'cp' | 'mate', value, depth? }\n  File, // 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h'\n  Meta, // { [key: string]: string | undefined }\n  Notation, // single parsed notation object (extends SAN)\n  NotationList, // NotationPair[]\n  NotationPair, // [number, Notation | undefined, Notation?]\n  ParseError, // { message, offset, line, column }\n  ParseOptions, // { onError?, onWarning? }\n  ParseWarning, // { message, offset, line, column }\n  PGN, // { meta, moves, result }\n  Piece, // 'pawn' | 'knight' | 'bishop' | 'rook' | 'queen' | 'king'\n  PromotionPiece, // 'knight' | 'bishop' | 'rook' | 'queen'\n  Rank, // '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8'\n  Result, // '1-0' | '0-1' | '1/2-1/2' | '?'\n  SAN, // base SAN interface from @echecs/san\n  Square, // `${File}${Rank}`, e.g. \"e4\"\n  SquareAnnotation, // { color, square }\n  StringifyOptions, // { onWarning? }\n  Variation, // NotationList[]\n} from '@echecs/pgn';\n```\n\n## Contributing\n\nContributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for\nguidelines on how to submit issues and pull requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fechecsjs%2Fpgn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fechecsjs%2Fpgn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fechecsjs%2Fpgn/lists"}