The callback code in TeamValidator and the functions that use it have
been refactored to use Promises.
Pretty much all signatures have been changed, for instance:
TeamValidator.validateTeamSync(format, team)
-> TeamValidator(format).validateTeam(team)
TeamValidator.validateTeam(format, team, callback)
-> TeamValidator(format).prepTeam(team) // returns a Promise
Validators are no longer cached since they're really lightweight. They
contain a format and a Tools instance, and Tools instances are already
cached in Tools anyway. This saves a tiny bit of RAM in exchange for a
tiny bit of CPU time, but more importantly makes the code more
readable.
I'm introducing a new pattern/API for managing the parts of code with
child processes - their process managers are now at .PM and are now
opt-in, so you can use them synchronously without needing to spawn
any processes.
Fixes#2448
Implements Tools#toTimeStamp to support Node.js builds without ICU support,
which are currently the default. If/when that changes, we should be able to
use Date#toLocaleDateString, given that appropriate locale options are used.
Now that nodejs/node#3072 is mostly fixed, we can finally start using
Node 4+ features.
This refactor:
- uses arrow functions where appropriate
Note that arrow functions still aren't used in Mocha, where `this`
is sometimes meaningful.
This also removes the need for .bind() nearly everywhere, as well
as the `self = this` trick.
- refactors Validator and Connection into ES6 classes
- no longer uses Array#forEach for iterating arrays
We strongly prefer for (let i = 0; i < arr.length; i++) because of
performance reasons. Most forEaches have been replaced with for..of,
though, which is 5x slower than the long-form loop but 2x faster
than forEach, which is good enough outside of most inner loops.
The only exception is tournaments, which is due for a more invasive
refactor soon anyway.
Joim's previous code apparently already did, but this implementation
does it correctly with the set-intersect system.
As an added bonus of correctly using the set-intersect system, it now
shows up properly in /gsclearn
`Tools.includeMods()` is unfortunately still massively broken and
unable to be loaded on-demand. This commit restores the old Tools
behavior of loading it at the beginning, which is horrible for
startup time but is the only way of fixing incorrect /learn
results in past gens.
The previous displayed message for 'sourcesBefore' in gen 1-2 was
also wrong.
This was, as far as I can tell, a mistaken interpretation of what
'sourcesBefore' means; possibly due to a past bug in its
implementation.
!statcalc gardevoir, spe 252+ scarf
Base 80 at level 100 with 31 IVs, 252+ EVs at +1: 427. (should be 246)
!statcalc gardevoir 252+ spe
Base 80 at level 100 with 31 IVs, 252+ EVs: 284.