Skip to content

Instantly share code, notes, and snippets.

@andeemarks
Created May 8, 2019 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andeemarks/60d8ba409a5c7809ef4ff7df38e4c8d4 to your computer and use it in GitHub Desktop.
Save andeemarks/60d8ba409a5c7809ef4ff7df38e4c8d4 to your computer and use it in GitHub Desktop.
Adam Woods' implementation of FEN formatting using match.length to reduce consecutive spaces to numbers
export default board =>
`${chunk(board, 8)
.map(row => row.join(''))
.map(str => str.replace(/\.+/g, match => match.length))
.join('/')} w - - 0 1`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment