11import { RESULT_TO_STR } from './parse.js' ;
22
3- import type { Eval , Meta , Move , MoveList , PGN , ParseOptions } from './types.js' ;
3+ import type {
4+ Eval ,
5+ Meta ,
6+ Move ,
7+ MoveList ,
8+ PGN ,
9+ StringifyOptions ,
10+ } from './types.js' ;
411
512const STR_TAG_ORDER = [
613 'Event' ,
@@ -52,7 +59,7 @@ function applyIndicators(san: string, move: Move): string {
5259 return san ;
5360}
5461
55- function stringifySAN ( move : Move , options ?: ParseOptions ) : string {
62+ function stringifySAN ( move : Move , options ?: StringifyOptions ) : string {
5663 if ( move . castling ) {
5764 if ( KINGSIDE_SQUARES . has ( move . to ) ) {
5865 return applyIndicators ( 'O-O' , move ) ;
@@ -132,7 +139,7 @@ function stringifyEval(evaluation: Eval): string {
132139 return `[%eval ${ evaluation . value . toFixed ( 2 ) } ${ depth } ]` ;
133140}
134141
135- function stringifyComment ( move : Move , options ?: ParseOptions ) : string {
142+ function stringifyComment ( move : Move , options ?: StringifyOptions ) : string {
136143 const parts : string [ ] = [ ] ;
137144
138145 if ( move . arrows && move . arrows . length > 0 ) {
@@ -188,7 +195,7 @@ function hasAnnotation(move: Move): boolean {
188195 ) ;
189196}
190197
191- function stringifyMoveList ( moves : MoveList , options ?: ParseOptions ) : string {
198+ function stringifyMoveList ( moves : MoveList , options ?: StringifyOptions ) : string {
192199 const tokens : string [ ] = [ ] ;
193200
194201 for ( const pair of moves ) {
@@ -252,7 +259,7 @@ function stringifyMoveList(moves: MoveList, options?: ParseOptions): string {
252259
253260// ─── Public API ───────────────────────────────────────────────────────────────
254261
255- function stringifyOne ( game : PGN , options ?: ParseOptions ) : string {
262+ function stringifyOne ( game : PGN , options ?: StringifyOptions ) : string {
256263 const tags = stringifyTags ( game . meta ) ;
257264 const movetext = stringifyMoveList ( game . moves , options ) ;
258265 const result = RESULT_TO_STR [ String ( game . result ) ] ?? '*' ;
@@ -261,7 +268,7 @@ function stringifyOne(game: PGN, options?: ParseOptions): string {
261268 return `${ header } ${ movetext } ${ separator } ${ result } \n` ;
262269}
263270
264- export function stringify ( input : PGN | PGN [ ] , options ?: ParseOptions ) : string {
271+ export function stringify ( input : PGN | PGN [ ] , options ?: StringifyOptions ) : string {
265272 if ( Array . isArray ( input ) ) {
266273 return input . map ( ( game ) => stringifyOne ( game , options ) ) . join ( '\n' ) ;
267274 }
0 commit comments