Created
November 30, 2014 04:10
-
-
Save realistschuckle/4e28a39064648f783f46 to your computer and use it in GitHub Desktop.
Example ES6 File
This file contains 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
import data from 'data-es6'; | |
export var tests = {}; | |
class Test { | |
constructor (name, link, criterion, traceurSupport) { | |
this.name = name; | |
this.link = link; | |
this.traceurSupport = traceurSupport; | |
if (typeof criterion !== 'function') { | |
criterion = criterion[0].script; | |
} | |
criterion = criterion.toString().replace('/*', '').replace('*/', ''); | |
if (this.name === 'let') { | |
criterion = criterion.replace('test', 'return '); | |
} else if (this.name === 'Array.prototype.entries') { | |
criterion = 'function(){return [].entries && [].entries().next;}'; | |
} | |
this._criterion = criterion; | |
} | |
get nativeSupport() { | |
try { | |
return eval('(' + this._criterion + ')()'); | |
} catch (e) { | |
return false; | |
} | |
} | |
} | |
for (var test of data.tests) { | |
if (test.exec === undefined) { | |
continue; | |
} | |
tests[test.name] = new Test(test.name, test.link, test.exec, test.res.tr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment