0.1.0 • Published 5 years ago
wolf-ecs-system-transform v0.1.0
wolf-ecs-query-inline
A Babel plugin to inline and optimise WolfECS query iteration.
Usage
Install Babel first if you haven't already:
npm i @babel/cli @babel/core -DInstall the plugin:
npm i wolf-ecs-query-inlineAdd the plugin to your babel.config.json:
{
"plugins": [
"wolf-ecs-query-inline"
]
}More info on Babel config here.
Finally, replace any instances of query.forEach you want to inline with query._forEach. This is to prevent name collisions with other functions such as Array.prototype.forEach.
Caveats
returnis not yet supported.- The argument passed to
_forEachmust be a function expression. (function() {}or() => {}) - Arrow functions must have braces.
_forEachcan't be used as a method name elsewhere, otherwise it will also be mistakenly compiled into a query iteration loop.
0.1.0
5 years ago