Moved to dedicated repository.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UPD: | |
// Now available as npm module! | |
// Check out https://github.com/RReverser/better-log for details. | |
console.log = (function (log, inspect) { | |
return function () { | |
return log.apply(this, Array.prototype.map.call(arguments, function (arg) { | |
return inspect(arg, { depth: 1, colors: true }); | |
})); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The MIT License (MIT) | |
Copyright (c) 2015 Ingvar Stepanyan | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var createChain = function (ops) { | |
var chain = function () {}; | |
chain.__asyncOps = ops; | |
return new Proxy(chain, AsyncContextHandler); | |
}; | |
function AsyncAccessError() { | |
TypeError.call(this, 'Can\'t perform synchronous operation on remote object.'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var fs = require('fs'); | |
var acorn = require('./parser'); | |
var transform = require('./transform'); | |
var escodegen = require('escodegen'); | |
var filename = process.argv[2]; | |
if (!filename) { | |
console.log('Usage: transpile filename.js'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function awaitableVersionOf(nodeFunction) { | |
return (...args) => new Promise((resolve, reject) => { | |
nodeFunction( | |
...args, | |
(error, ...cbArgs) => error ? reject(error) : resolve(...cbArgs) | |
); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function slice(str, start, end) { | |
let i = 0, pos = 0, legacyStart, legacyEnd; | |
for (let ch of str) { | |
if (i === start) { | |
legacyStart = pos; | |
} | |
i++; | |
pos += ch.length; | |
if (i === end) { | |
legacyEnd = pos; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example #1: | |
ArrayLiteral[Yield] : | |
[ Elision[opt] ] | |
[ ElementList[?Yield] ] | |
[ ElementList[?Yield] , Elision[opt] ] | |
Option #1: | |
ArrayLiteral : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function *getSymbols(s) { | |
for (var i = 0; i < s.length - 1; i++) { | |
if (s.charCodeAt(i) >> 10 === 0x36 && s.charCodeAt(i + 1) >> 10 === 0x37) { | |
yield s.substr(i, 2); | |
} else { | |
yield s.charAt(i); | |
} | |
} | |
yield s.charAt(i); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RegExp.prototype.matches = function* (str) { | |
let moreThanOnce = this.global || this.sticky; | |
let myLastIndex = 0; | |
do { | |
// preserve lastIndex of another .exec() calls on same regexp | |
let savedLastIndex = this.lastIndex; | |
// use own state for lastIndex to match our str | |
this.lastIndex = myLastIndex; | |
let match = this.exec(str); |