open-index/open-npm huggingface dataset:
npm package: @mliebelt/pgn-reader
Description: A pgn reader (backend only) to read, understand and play chess games. Used mainly by pgn-viewer.
Author: mliebelt
Latest version: 1.2.30

[![GitHub Workflow Status](https://github.com/mliebelt/PgnViewerJS/actions/workflows/nodejs.yml/badge.svg)](https://github.com/mliebelt/PgnViewerJS/actions[)
[![npm (tag)](https://img.shields.io/npm/v/@mliebelt/pgn-reader)](https://www.npmjs.com/package/@mliebelt/pgn-reader)
[![npm](https://img.shields.io/npm/dm/@mliebelt/pgn-reader)](https://www.npmjs.com/package/@mliebelt/pgn-reader)
[![NPM](https://img.shields.io/npm/l/@mliebelt/pgn-reader)](https://github.com/mliebelt/PgnViewerJS/blob/main/modules/pgn-reader/LICENSE.md)

# In a Nutshell

pgn-reader is the backend for pgn-viewer, and only used by it. It should be usable by itself to read and play through a game, though. It should at least be usable to perform some checks on a game read.

## How to Install

`npm install` to get all dependencies resolved. It has as dependency the parser `pgn-parser` which is separately published on NPM.

## How to Build and Test

* `npm build`: Creates a new bundle `lib/pgn.ts`.
* `npm test`: Runs the whole test suite to check the whole API.

## How to Use

**To be written**
npm package: @mliebelt/pgn-types
Description: Provide the (type) language for all the `pgn-*` packages I am developing.
Author: Markus Liebelt
Latest version: 1.0.4

# In a nutshell
Provide the (type) language for all the `pgn-*` packages I am developing.

I have tried to develop parts of the pgn-* packages individually, and to import what is needed. By extracting now `pgn-writer` (that uses types in part defined by `pgn-parser`, part by `pgn-reader`) it gets more and more complicated.

To avoid having duplication of the  types (by doing copy and paste), I try now to eliminate duplicates and move them to the common types used in many packages. The size should be minimal (only declaration), but perhaps I gain a common model where the small glitches that are not easy to find can be avoided.

And yes, I will have additional dependencies that has to be managed, with some more changes if types / design changes. But better to have it explicit instead of subtle errors ...
npm package: @mliebelt/pgn-writer
Description: A PEG writer to write PGN (Portable Game Notation) notation.
Author: mliebelt
Latest version: 1.0.5

# In a nutshell ...
Provides base functionality (implemented in Javascript) to write PGN to a string. The input is the one produced by pgn-parser, and used as well by pgn-reader.

# Goals

* Implement the part of `modules/pgn-reader/src/pgn.js`, there `write_pgn`.
* Provide a configuration that allows different output formats / options.
* Allow to be used to do the following scenario
  1. Import a huge collection of PGN games (one file).
  1. Write info/warning/error messages on reading (not part of this library).
  1. Export those games (or a subset of it) in a standard format: This is what is provided by this library.
  1. Allow variants in writing: strip tags; strip variants; strip kind of comments (arrows and circles, time comments, ...); strip NAGs; use a different language for export (by giving the locale)
  
See the [annotated spec](https://github.com/mliebelt/pgn-spec-commented/blob/main/annotated/export.md) that should be sufficient for guiding the implementation.
    
# Usage

The following is pseudo-code, the interface is not defined completely and will change in the future. But I moved the source to typescript, and have added type annotations where necessary. Look at the annotations `PgnGame` and `PgnWriterConfiguation` which are currently the only arguments to the main function. The function `getGame(<index>)` of pgn-reader not yet exists, but will be added in the next version.

```
import {PgnReader} from '@mliebelt/pgn-reader'
import {writeGame} from '@mliebelt/pgn-writer'

let game = new PgnReader({ pgn: '1. e4 *', ... }).getGame(0)
let resultPGN = writeGame(game, { config2: 'param', ... })
```