Introducing aight: the script
This release includes a new aight
command-line script that rewrites JavaScript to include IE8-friendly protections. There's only one of these right now, and it's intended to make the current release (3.3.9, as of this writing) of D3 work in IE8, as discussed in this pull request.
bin/aight
There's no --help
argument for usage yet, but here's how it works. First off, install aight
via npm:
npm install aight
# or, more specifically:
npm install [email protected]
aight
reads JavaScript filenames synchronously (or script source from stdin) and prints to stdout:
# make d3.js IE8-friendly
aight d3.js > d3-ie8.js
# or
cat d3.js | aight > d3-ie8.js
You can see what it does by piping in a for..in
loop:
echo "var obj = {}; for (var key in obj) console.log(key, obj[key]);" | aight
this outputs (with whitespace for clarity):
var obj = {};
for (var key in obj) if (obj.hasOwnProperty(key)) {
console.log(key, obj[key]);
}
In a future release I'll be adding usage instructions to the script, and possibly adding a build step that grabs the latest d3.js
and transforms it for IE8.