Before, an options object containing properties and values to be used
was how decorated instances of the class would be created. This meant
the constructor could assign anything you feel like to `this`. Rather
than that, the constructor now assigns a strict set of values, and
methods are redefined in subclasses.
Basic unit tests were added to test if they could be written for after
the final refactor to fix the other memory leak here.
Only Blue, Red, and Yellow Floette can be found in the Friend Safari, so Orange and White are currently unable to have Symbiosis.
This is done here since there's no reason to add teambuilder slots for them when they won't be tiered separately anyway.
Unless we want to change the syntax for data tables like pokedex.js,
'constructor' will always exist as a table key.
These changes represent the bare minimum to prevent this from
causing too-weird behavior.
An external dependency is kind of overkill when the only
implementation we need is three lines.
This also lets us write a more performant implementation that
omits the parts irrelevant to us.
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
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.
Crashlogger now supports passing in a dictionary of additional
information to report, so we no longer need to resort to making fake
errors.
The hadException parameter has now been removed entirely. I don't know
of a use case for it to be false.
The old code told me Tyranitar with Dragon Dance + Outrage needed to
have Guts (which is Larvitar's ability), which is clearly wrong.
The new code figures out the correct ability for the corresponding
ability slot.
There's no need to push individual move sources if sourcesBefore covers
it.
Unfortunately, 5M and 5T come after 5E, so it's not nearly as optimal
as it could be...