Last active
August 12, 2022 15:28
-
-
Save jacebenson/10247d6baa07f49c3dfe3ca66a9f753c to your computer and use it in GitHub Desktop.
Test SN for ES6 stuff
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
// run this in your background | |
var test = function(name, code){ | |
try{ | |
eval(code) | |
gs.print("SUPPORTED - " + name) | |
} catch(e){ | |
gs.print("NOT SUPPORTED - " + name + ' - ' + e) | |
} | |
} | |
test('const', 'const a="test"') | |
test('let', 'let b="test"') | |
test('arrow functions', '()=>{gs.print("ImAnArrowFx")}') | |
// for / of | |
test('for/of', "for (var number of [0,1,2]){gs.print('?');}") | |
test('map/set objects',"var apples = {name: 'Apples'};var ads = {name: 'Ads'};var things = new Map()") | |
test('set', "var letters = new Set();letters.add('a')") | |
test('promises',"var iPromise=new Promise(function(resolve,reject){})")//thanks pok | |
test('symbol', "var person={name:'jace'};var id = Symbol('id')") | |
test('default params', "function say(message = '...'){gs.print(message)}say();say('hello')") | |
test('spread', "var obj={id:1,x:1};var test = {...obj}") | |
// not sure how to test imports/exports | |
test('Template Strings',"`hello`") | |
test('Destructing object', "var {make,model} = {make: 'chevy', model: 'nova'}") //thanks pok | |
test('Destructing array', "var [red,green,blue] = [1,2,3]") | |
test('class', "class Point { constructor(x,y){this.x=x;this.y=y}toString(){return this.x + ',' + this.y}}")//thanks pok | |
test('String.startsWith', "var text='hello';text.startsWith('hell')") | |
test('String.endsWith', "var text='hello';text.endsWith('llo')") | |
test('String.includes', "'test'.includes('es')") | |
test('Array.from','var arr1 = [1,2];var arr2 = Array.from(arr1);') | |
test('Array.prototype.keys',"[1,2].keys()") | |
test('Array.prototype.entries',"[1,2].entries()") | |
test('Array.prototype.values',"[1,2].values()") | |
test('Array.find', "[1,2,3].find(function(value,index,array){return value > 2})") | |
test('Array.findIndex', "[1,2,3].findIndex(function(value,index,array){return value > 2})") | |
test('Array.of','Array.of("A", "B", "C")') | |
test('Array.prototype.copyWithin()','[1,2].copyWithin(9,9,9)') | |
test('Array.prototype.fill()','[1,2].fill("hello")') | |
test('Math.trunc', "Math.trunc(4.9)") | |
test('Math.sign', "Math.sign(-4)") | |
test('Math.cbrt', "Math.cbrt(8)") | |
test('Math.log2', "Math.log2(2)") | |
test('Math.log10', "Math.log10(10)") | |
test('Number.EPSILON',"Number.EPSILON") | |
test('Number.MIN_SAFE_INTEGER',"Number.MIN_SAFE_INTEGER") | |
test('Number.MAX_SAVE_INTEGER',"Number.MAX_SAFE_INTEGER") | |
test('Number.isInteger()',"Number.isInteger(10)") | |
test('Number.isSafeInteger()',"Number.isSafeInteger(10.5)") | |
test('isFinite()',"isFinite(10/0)") | |
test('isNaN()',"isNaN('hello')") |
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
*** Script: SUPPORTED - const | |
*** Script: NOT SUPPORTED - let - SyntaxError: let is an ECMAScript 6 feature - not supported | |
*** Script: NOT SUPPORTED - arrow functions - SyntaxError: syntax error | |
*** Script: NOT SUPPORTED - for/of - SyntaxError: missing ; after for-loop initializer | |
*** Script: NOT SUPPORTED - map/set objects - ReferenceError: "Map" is not defined. | |
*** Script: NOT SUPPORTED - set - ReferenceError: "Set" is not defined. | |
*** Script: NOT SUPPORTED - promises - SyntaxError: missing ) after argument list | |
*** Script: NOT SUPPORTED - symbol - ReferenceError: "Symbol" is not defined. | |
*** Script: NOT SUPPORTED - default params - SyntaxError: missing ) after formal parameters | |
*** Script: NOT SUPPORTED - spread - SyntaxError: invalid property id | |
*** Script: NOT SUPPORTED - Template Strings - SyntaxError: illegal character | |
*** Script: NOT SUPPORTED - Destructing object - SyntaxError: destructuring assignment is an ECMAScript 6 feature - not supported | |
*** Script: NOT SUPPORTED - Destructing array - SyntaxError: destructuring assignment is an ECMAScript 6 feature - not supported | |
*** Script: NOT SUPPORTED - class - SyntaxError: identifier "class" is a reserved word | |
*** Script: SUPPORTED - String.startsWith | |
*** Script: SUPPORTED - String.endsWith | |
*** Script: SUPPORTED - String.includes | |
*** Script: SUPPORTED - Array.from | |
*** Script: SUPPORTED - Array.prototype.keys | |
*** Script: SUPPORTED - Array.prototype.entries | |
*** Script: SUPPORTED - Array.prototype.values | |
*** Script: SUPPORTED - Array.find | |
*** Script: SUPPORTED - Array.findIndex | |
*** Script: SUPPORTED - Array.of | |
*** Script: SUPPORTED - Array.prototype.copyWithin() | |
*** Script: SUPPORTED - Array.prototype.fill() | |
*** Script: SUPPORTED - Math.trunc | |
*** Script: SUPPORTED - Math.sign | |
*** Script: SUPPORTED - Math.cbrt | |
*** Script: SUPPORTED - Math.log2 | |
*** Script: SUPPORTED - Math.log10 | |
*** Script: SUPPORTED - Number.EPSILON | |
*** Script: SUPPORTED - Number.MIN_SAFE_INTEGER | |
*** Script: SUPPORTED - Number.MAX_SAVE_INTEGER | |
*** Script: SUPPORTED - Number.isInteger() | |
*** Script: SUPPORTED - Number.isSafeInteger() | |
*** Script: SUPPORTED - isFinite() | |
*** Script: SUPPORTED - isNaN() |
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
*** Script: SUPPORTED - const | |
*** Script: NOT SUPPORTED - let - SyntaxError: let is an ECMAScript 6 feature - not supported | |
*** Script: NOT SUPPORTED - arrow functions - SyntaxError: syntax error | |
*** Script: NOT SUPPORTED - for/of - SyntaxError: missing ; after for-loop initializer | |
*** Script: NOT SUPPORTED - map/set objects - ReferenceError: "Map" is not defined. | |
*** Script: NOT SUPPORTED - set - ReferenceError: "Set" is not defined. | |
*** Script: NOT SUPPORTED - promises - SyntaxError: missing ) after argument list | |
*** Script: NOT SUPPORTED - symbol - ReferenceError: "Symbol" is not defined. | |
*** Script: NOT SUPPORTED - default params - SyntaxError: missing ) after formal parameters | |
*** Script: NOT SUPPORTED - spread - SyntaxError: invalid property id | |
*** Script: NOT SUPPORTED - Template Strings - SyntaxError: illegal character | |
*** Script: NOT SUPPORTED - Destructing object - SyntaxError: destructuring assignment is an ECMAScript 6 feature - not supported | |
*** Script: NOT SUPPORTED - Destructing array - SyntaxError: destructuring assignment is an ECMAScript 6 feature - not supported | |
*** Script: NOT SUPPORTED - class - SyntaxError: identifier "class" is a reserved word | |
*** Script: SUPPORTED - String.startsWith | |
*** Script: SUPPORTED - String.endsWith | |
*** Script: SUPPORTED - String.includes | |
*** Script: SUPPORTED - Array.from | |
*** Script: SUPPORTED - Array.prototype.keys | |
*** Script: SUPPORTED - Array.prototype.entries | |
*** Script: SUPPORTED - Array.prototype.values | |
*** Script: SUPPORTED - Array.find | |
*** Script: SUPPORTED - Array.findIndex | |
*** Script: SUPPORTED - Array.of | |
*** Script: SUPPORTED - Array.prototype.copyWithin() | |
*** Script: SUPPORTED - Array.prototype.fill() | |
*** Script: SUPPORTED - Math.trunc | |
*** Script: SUPPORTED - Math.sign | |
*** Script: SUPPORTED - Math.cbrt | |
*** Script: SUPPORTED - Math.log2 | |
*** Script: SUPPORTED - Math.log10 | |
*** Script: SUPPORTED - Number.EPSILON | |
*** Script: SUPPORTED - Number.MIN_SAFE_INTEGER | |
*** Script: SUPPORTED - Number.MAX_SAVE_INTEGER | |
*** Script: SUPPORTED - Number.isInteger() | |
*** Script: SUPPORTED - Number.isSafeInteger() | |
*** Script: SUPPORTED - isFinite() | |
*** Script: SUPPORTED - isNaN() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment