uci-parser-ts
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

uci-parser-ts

npm npm bundle size Codecov

A UCI parser written in TypeScript.

install

npm

npm i uci-parser-ts

yarn

yarn add uci-parser-ts

pnpm

pnpm i uci-parser-ts

cdn

examples

stockfish.ts

import { spawn } from "child_process";
import { createInterface } from "readline";
import { tryParseOne, UciOkCommand } from "uci-parser-ts";

/**
 * Spawns a Stockfish process and initializes the UCI mode.
 */
async function main() {
  const { stdin, stdout } = spawn("stockfish");
  const lines = createInterface({ input: stdout });

  stdin.write("uci");
  stdin.end();

  for await (const line of lines) {
    const command = tryParseOne(line);
    if (!command) {
      continue;
    }

    if (command instanceof UciOkCommand) {
      break;
    }
  }
}

void main();

cdn.html

<html>
  <body>
    <script src="https://unpkg.com/uci-parser-ts@latest/umd/uci-parser-ts.production.js"></script>
    <script>
      alert(JSON.stringify(uci.parseOne("bestmove e2e4")));
    </script>
  </body>
</html>

Readme

Keywords

Package Sidebar

Install

npm i uci-parser-ts

Weekly Downloads

0

Version

0.1.4

License

MIT

Unpacked Size

293 kB

Total Files

277

Last publish

Collaborators

  • maarvin