mliebelt/pgn-parser

Suggestion: Node 10 is End of Life - Drop support for it

MichaelLeeHobbs opened this issue · 2 comments

Node 10 is End of Life. I'd recommend dropping support for it as it would allow you to use async/await fs/promises more easily.

it('be able to filter games depending on tags', function (done) {
  fs.readFile(process.cwd() + '/test/pgn/32games.pgn', 'utf8', function (err, data) {
    if (err) {
      throw err;
    }
    let res = split_games(data);
    let found = [];
    res.forEach(function (game) {
      let tags = parser.parse(game.tags, {startRule: 'tags'});
      if (tags.Result == '1-0') {
        found.push(parser.parse(game.all, {startRule: 'game'}));
      }
    });
    should(found.length).equal(22);
    done();
  });
});

Would become

it('be able to filter games depending on tags', async (done) => {
  const data = await fs.readFile(process.cwd() + '/test/pgn/32games.pgn', 'utf8'); // this throws if error
  let res = split_games(data);
  let found = [];
  res.forEach((game) => {
    let tags = parser.parse(game.tags, {startRule: 'tags'});
    if (tags.Result === '1-0') {
      found.push(parser.parse(game.all, {startRule: 'game'}));
    }
  });
  should(found.length).equal(22);
  done();
});

Not hugely different but nice to be able to do file operations in a single line among other things.

Question: I already switched in .github/workflows/nodejs.yml to versions 12,14,16 only. What other part of the source code / package.json has to be changed to make that switch obvious? Is there some documentation what should be changed when switching to minimal version v12.x?

Thank's for the hints on making the test cases more current ... I will git it a try.

Sorry, I saw that after I made this.