es-feature-tests
Advanced tools
Comparing version 0.2.1-a to 0.3.0
/*! es-feature-tests | ||
v0.2.1-a (c) Kyle Simpson | ||
v0.3.0 (c) Kyle Simpson | ||
MIT License: http://getify.mit-license.org | ||
*/ | ||
function runIt(e){return new Function(e)()}var results={},es6,setup;global="undefined"!=typeof global?global:runIt("return this"),setup=function(){"use strict";function e(e,s){Object.keys(s).forEach(function(t){e[t]=s[t]})}function s(e){try{return runIt(e),!0}catch(s){return!1}}function t(e){try{return runIt(e)}catch(s){return!1}}function r(e){var r={},i=!0;return Object.keys(e).forEach(function(i){e[i].passes?r[i]=s(e[i].passes):e[i].fails?r[i]=!s(e[i].fails):e[i].is?r[i]=t(e[i].is):e[i].not&&(r[i]=!t(e[i].not))}),Object.keys(e).forEach(function(s){e[s].dependencies&&(e[s].dependencies.reduce(function(s,t){return s&&e[t]},!0)||(r[s]=!1)),r[s]||(i=!1)}),r.everything=i,r}function i(s,t){function i(s){var i=JSON.parse(s.data);i.id;t=t||s.source,"all"==i.req?(e(results,r(es6)),i.res=results,a(JSON.stringify(i))):"api"==i.req&&(i.res=es6,a(JSON.stringify(i)))}function a(e){t.postMessage(e)}s.addEventListener("message",i,!1)}function a(e){var s=e.ports[0];i(s,s),s.start()}function n(e){"start"===e.data&&(self.removeEventListener("message",n),i(self,self))}if(es6={letConst:{passes:"'use strict'; let a; const b = 2;"},letLoop:{passes:"'use strict'; for(let i in {}){}; for(let i=0;;){break}"},constLoop:{passes:"'use strict'; for(const i in {}){}; for (const i=0;;){break}"},defaultParameter:{passes:"'use strict'; function a(b=2){}"},spreadRest:{passes:"'use strict'; var a = [1,2]; +function b(...c){}(...a);"},destructuring:{passes:"'use strict'; var a = [1,2], [b,c] = a, d = {e:1,f:2}, {e:E,f} = d;"},parameterDestructuring:{passes:"'use strict'; function a({b,c}){}"},templateString:{passes:"'use strict'; var a = 1, b = `c${a}d`;"},forOf:{passes:"'use strict'; for (var a of [1]) {}"},arrow:{passes:"'use strict'; var a = () => {};"},generator:{passes:"'use strict'; function *a(){ yield; }"},conciseMethodProperty:{passes:"'use strict'; var a = 1, b = { c(){}, a };"},computedProperty:{passes:"'use strict'; var a = 1, b = { ['x'+a]: 2 };"},moduleExport:{passes:"'use strict'; export var a = 1;"},moduleImport:{passes:"'use strict'; import {a} from 'b';"},classes:{passes:"'use strict'; class Foo {}; class Bar extends Foo {};"},numericLiteral:{passes:"'use strict'; var a = 0o1, b = 0b10;"},oldOctalLiteral:{passes:"var a = 01;"},symbol:{passes:"'use strict'; var a = Symbol('b');"},unicodeEscape:{passes:"'use strict'; var a = '\\u{20BB7}';"},unicodeIdentifier:{passes:"'use strict'; var \\u{20BB7};"},unicodeRegExp:{passes:"'use strict'; var a = /\\u{20BB7}/u;"},stickyRegExp:{passes:"'use strict'; var a = /b/y;"}},e(es6,{"class":es6.classes,letTDZ:{dependencies:["letConst"],fails:"'use strict'; a = 1; let a;"},letLoopScope:{dependencies:["letLoop","forOf"],passes:"'use strict'; var x=[],i=0;for(let i=2;i<3;i++){x.push(function(){return i})};for(let i in {3:0}){x.push(function(){return i})};for(let i of [4]){x.push(function(){return i})};if(x[0]()*x[1]()*x[2]()!=24) throw 0;"},constRedef:{dependencies:["letConst"],fails:"'use strict'; const a = 1; a = 2;"},objectProto:{passes:"'use strict'; var a = { b: 2 }, c = { __proto__: a }; if (c.b !== 2) throw 0;"},objectSuper:{passes:"'use strict'; var a = { b: 2 }, c = { d() { return super.b; } }; Object.setPrototypeOf(c,a); if (c.d() !== 2) throw 0;"},extendNatives:{dependencies:["class"],passes:"'use strict'; class Foo extends Array { }; var a = new Foo(); a.push(1,2,3); if (a.length !== 3) throw 0;"},TCO:{passes:"'use strict'; +function a(b){ if (b<6E4) a(b+1); }(0);"},symbolImplicitCoercion:{fails:"'use strict'; var a = Symbol('a'); a + '';"},functionNameInference:{passes:"'use strict'; var a = { b: function(){} }; if (a.name != 'b') throw 0;"},ObjectStatics:{is:"'use strict'; return ('getOwnPropertySymbols' in Object) && ('assign' in Object) && ('is' in Object);"},ArrayStatics:{is:"'use strict'; return ('from' in Array) && ('of' in Array);"},ArrayMethods:{is:"'use strict'; return ('fill' in Array.prototype) && ('find' in Array.prototype) && ('findIndex' in Array.prototype) && ('entries' in Array.prototype) && ('keys' in Array.prototype) && ('values' in Array.prototype);"},TypedArrays:{is:"'use strict'; return ('ArrayBuffer' in global) && ('Int8Array' in global) && ('Uint8Array' in global) && ('Int32Array' in global) && ('Float64Array' in global);"},TypedArrayStatics:{dependencies:["TypedArrays"],is:"use strict'; return ('from' in Uint32Array) && ('of' in Uint32Array);"},TypedArrayMethods:{dependencies:["TypedArrays"],is:"'use strict'; var x = new Int8Array(1); return ('slice' in x) && ('join' in x) && ('map' in x) && ('forEach' in x);"},StringMethods:{is:"'use strict'; return ('includes' in String.prototype) && ('repeat' in String.prototype);"},NumberStatics:{is:"'use strict'; return ('isNaN' in Number) && ('isInteger' in Number);"},MathStatics:{is:"'use strict'; return ('hypot' in Math) && ('acosh' in Math) && ('imul' in Math);"},collections:{is:"'use strict'; return ('Map' in global) && ('Set' in global) && ('WeakMap' in global) && ('WeakSet' in global);"},Proxy:{is:"'use strict'; return ('Proxy' in global);"},Promise:{is:"'use strict'; return ('Promise' in global);"}}),"undefined"!=typeof module&&module.exports)module.exports.setup=i,module.exports.es6=es6,module.exports.results=results;else if("onconnect"in self)self.addEventListener("connect",a);else{if("undefined"!=typeof window)return i;self.addEventListener("message",n)}}(); |
/*! es-feature-tests | ||
v0.2.1-a (c) Kyle Simpson | ||
v0.3.0 (c) Kyle Simpson | ||
MIT License: http://getify.mit-license.org | ||
*/ | ||
!function(e,t,n){t[e]=t[e]||n(e,t),"undefined"!=typeof module&&module.exports?module.exports=t[e]:"function"==typeof define&&define.amd&&define(function(){return t[e]})}("Reflect.supports",new Function("return this;")(),function(e,t){"use strict";function n(e){for(u=e;m.length>0;)u(m.shift())}function i(e){var t,n=Date.now();if(e.origin===g){if(t=JSON.parse(e.data),f&&"all"==t.req)try{localStorage.setItem(g,JSON.stringify({expires:t.expires||n+y,version:h,results:t.res}))}catch(i){}v[t.id]&&("api"==t.req?v[t.id](t.res):v[t.id](t.res,t.expires-y||n),v[t.id]=null)}}function o(e,t){var n;do n="x"+Math.random();while(v[n]);v[n]=t,e=JSON.stringify({id:n,req:e}),u?u(e):m.push(e)}function s(){p&&localStorage.removeItem(g)}function r(e,t){var n,i=Date.now();if(e="all",t=t||function(){},!r.disabled){if("all"==e&&f&&(n=localStorage.getItem(g)))try{if(n=JSON.parse(n),n.expires=n.expires||i+y,i<n.expires&&n.version&&n.version==h)return void setTimeout(function(){t(n.results,n.expires-y)},0);s()}catch(u){}a(),o(e,t)}}function a(){!l&&"postMessage"in t&&"document"in t&&(l=t.document.createElement("iframe"),l.style.display="none",l.src=g+"/featuretests.html?cache="+(f?"yes":"no")+"&v="+h,t.document.body.appendChild(l),c=t,d=l.contentWindow&&l.contentWindow.postMessage?l.contentWindow:l,c.addEventListener("message",i,!1),l.addEventListener("load",function(){n(function(e){d.postMessage(e,g)})},!1))}r.disableLocalCache=function(){f=!1,s()},r.clearLocalSiteCache=s,r.api=function(e,t){e="api",t=t||function(){},r.disabled||(a(),o(e,t))};var u,c,d,f,l,p,m=[],g="https://featuretests.io",h=1021,v={},y=12096e5;return Date.now||(Date.now=function(){return Number(new Date)}),f=p=function(e){try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(t){return!1}}("storage:featuretests.io"),"undefined"!=typeof module&&module.exports?(c={addEventListener:function(e,t){n(function(e){setTimeout(function(){t({data:e})},0)})}},d={postMessage:function(e){setTimeout(function(){i({origin:g,data:e})},0)}},require("./featuretests.js").setup(c,d)):"postMessage"in t&&"document"in t||(r.disabled=!0),r}); | ||
!function(e,t,n){t[e]=t[e]||n(e,t),"function"==typeof define&&define.amd?define(function(){return t[e]}):"undefined"!=typeof module&&module.exports&&(module.exports=t[e])}("Reflect.supports",new Function("return this;")(),function(e,t){"use strict";function n(e){for(u=e;m.length>0;)u(m.shift())}function i(e){var t,n=Date.now();if(e.origin===g){if(t=JSON.parse(e.data),f&&"all"==t.req)try{localStorage.setItem(g,JSON.stringify({expires:t.expires||n+y,version:h,results:t.res}))}catch(i){}v[t.id]&&("api"==t.req?v[t.id](t.res):v[t.id](t.res,t.expires-y||n),v[t.id]=null)}}function o(e,t){var n;do n="x"+Math.random();while(v[n]);v[n]=t,e=JSON.stringify({id:n,req:e}),u?u(e):m.push(e)}function s(){p&&localStorage.removeItem(g)}function r(e,t){var n,i=Date.now();if(e="all",t=t||function(){},!r.disabled){if("all"==e&&f&&(n=localStorage.getItem(g)))try{if(n=JSON.parse(n),n.expires=n.expires||i+y,i<n.expires&&n.version&&n.version==h)return void setTimeout(function(){t(n.results,n.expires-y)},0);s()}catch(u){}a(),o(e,t)}}function a(){!l&&"postMessage"in t&&"document"in t&&(l=t.document.createElement("iframe"),l.style.display="none",l.src=g+"/featuretests.html?cache="+(f?"yes":"no")+"&v="+h,t.document.body.appendChild(l),c=t,d=l.contentWindow&&l.contentWindow.postMessage?l.contentWindow:l,c.addEventListener("message",i,!1),l.addEventListener("load",function(){n(function(e){d.postMessage(e,g)})},!1))}r.disableLocalCache=function(){f=!1,s()},r.clearLocalSiteCache=s,r.api=function(e,t){e="api",t=t||function(){},r.disabled||(a(),o(e,t))};var u,c,d,f,l,p,m=[],g="https://featuretests.io",h=1030,v={},y=12096e5;return Date.now||(Date.now=function(){return Number(new Date)}),f=p=function(e){try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(t){return!1}}("storage:featuretests.io"),"undefined"!=typeof module&&module.exports?(c={addEventListener:function(e,t){n(function(e){setTimeout(function(){t({data:e})},0)})}},d={postMessage:function(e){setTimeout(function(){i({origin:g,data:e})},0)}},require("./featuretests.js").setup(c,d)):"postMessage"in t&&"document"in t||(r.disabled=!0),r}); |
/*! es-feature-tests | ||
v0.2.1-a (c) Kyle Simpson | ||
v0.3.0 (c) Kyle Simpson | ||
MIT License: http://getify.mit-license.org | ||
@@ -4,0 +4,0 @@ */ |
/*! es-feature-tests | ||
v0.2.1-a (c) Kyle Simpson | ||
v0.3.0 (c) Kyle Simpson | ||
MIT License: http://getify.mit-license.org | ||
@@ -9,4 +9,4 @@ */ | ||
context[name] = context[name] || definition(name,context); | ||
if (typeof module != "undefined" && module.exports) { module.exports = context[name]; } | ||
else if (typeof define == "function" && define.amd) { define(function $AMD$(){ return context[name]; }); } | ||
if (typeof define == "function" && define.amd) { define(function $AMD$(){ return context[name]; }); } | ||
else if (typeof module != "undefined" && module.exports) { module.exports = context[name]; } | ||
})("Reflect.supports",(new Function("return this;"))(),function DEF(name,context){ | ||
@@ -155,3 +155,3 @@ "use strict"; | ||
origin = "https://featuretests.io", | ||
version = 1021, requests = {}, | ||
version = 1030, requests = {}, | ||
local_storage_available, | ||
@@ -158,0 +158,0 @@ expiration = 14 * 1000 * 60 * 60 * 24; |
{ | ||
"name": "es-feature-tests", | ||
"version": "0.2.1-a", | ||
"version": "0.3.0", | ||
"description": "Feature Tests for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "./lib/rs.js", |
@@ -116,3 +116,4 @@ # ES Feature Tests | ||
(default: simple) | ||
--require=test-name force inclusion of a test by name | ||
--enable=test-name force inclusion of a test by name | ||
--disable=test-name force exclusion of a test by name | ||
@@ -133,3 +134,3 @@ -R, --recursive directory scan is recursive | ||
To force the inclusion of a specific test check, use `--require` and specify the test name (matching the test result from this *es-feature-tests* library). | ||
To force the inclusion of a specific test check, use `--enable` and specify the name (matching the test result name from this *es-feature-tests* library). To exclude a specific test check, use `--disable` and specify the matching name. | ||
@@ -162,3 +163,4 @@ Suppress errors for missing scan files with `--ignore-missing` and for invalid files (failure to parse the JS) with `--ignore-invalid`. | ||
**Note:** The CLI `--output` option defaults to `"simple"` (the code for `checkFeatureTests(..)`), but the default value for the library option is `"json"`, which *actually produces the array object itself, since that will likely be more useful when used programmatically. | ||
* `requires` (`string`, `array`): specifies test(s) that should be included | ||
* `enabled` (`string`, `array`): specifies test(s) that should always be included | ||
* `disabled` (`string`, `array`): specifies test(s) that should never be included | ||
* `recursive` (`boolean`, default: `false`): make directory scans recursive | ||
@@ -169,3 +171,3 @@ * `ignore` (`object`, `boolean`): if `true`/`false`, will set all sub-properties accordingly; otherwise, should be an object with one or more of these: | ||
**Note:** `files`, `dirs`, `excludes`, and `requires` are all plurally named as options, but singularly named as CLI parameters. | ||
**Note:** `files`, `dirs`, and `excludes` all have the -`s` suffix, and `enabled` and `disabled` both have the -`d` suffix. However, the associated CLI parameter names do not have these suffixes. | ||
@@ -172,0 +174,0 @@ ## GitHub |
@@ -232,18 +232,34 @@ "use strict"; | ||
else if ( | ||
OPTS.requires != null && | ||
OPTS.enabled != null && | ||
( | ||
OPTS.requires === "" || | ||
OPTS.enabled === "" || | ||
( | ||
typeof OPTS.requires != "string" && | ||
!Array.isArray(OPTS.requires) | ||
typeof OPTS.enabled != "string" && | ||
!Array.isArray(OPTS.enabled) | ||
) || | ||
( | ||
Array.isArray(OPTS.requires) && | ||
~OPTS.requires.indexOf("") | ||
Array.isArray(OPTS.enabled) && | ||
~OPTS.enabled.indexOf("") | ||
) | ||
) | ||
) { | ||
throw new Error("'requires' option must specify a single non-empty value, or an array of non-empty values"); | ||
throw new Error("'enabled' option must specify a single non-empty value, or an array of non-empty values"); | ||
} | ||
else if ( | ||
OPTS.disabled != null && | ||
( | ||
OPTS.disabled === "" || | ||
( | ||
typeof OPTS.disabled != "string" && | ||
!Array.isArray(OPTS.disabled) | ||
) || | ||
( | ||
Array.isArray(OPTS.disabled) && | ||
~OPTS.disabled.indexOf("") | ||
) | ||
) | ||
) { | ||
throw new Error("'disabled' option must specify a single non-empty value, or an array of non-empty values"); | ||
} | ||
else if ( | ||
OPTS.recursive != null && | ||
@@ -302,8 +318,19 @@ typeof OPTS.recursive != "boolean" | ||
} | ||
if (!OPTS.requires) { | ||
OPTS.requires = []; | ||
if (!OPTS.disabled) { | ||
OPTS.disabled = []; | ||
} | ||
else if (!Array.isArray(OPTS.requires)) { | ||
OPTS.requires = [OPTS.requires]; | ||
else if (!Array.isArray(OPTS.disabled)) { | ||
OPTS.disabled = [OPTS.disabled]; | ||
} | ||
if (!OPTS.enabled) { | ||
OPTS.enabled = []; | ||
} | ||
else if (!Array.isArray(OPTS.enabled)) { | ||
OPTS.enabled = [OPTS.enabled]; | ||
} | ||
// now exclude disabled tests | ||
OPTS.enabled = OPTS.enabled.filter(function filterer(test){ | ||
return !~OPTS.disabled.indexOf(test); | ||
}); | ||
if (OPTS.files && !Array.isArray(OPTS.files)) { | ||
@@ -674,4 +701,6 @@ OPTS.files = [OPTS.files]; | ||
// set required tests | ||
OPTS.requires.forEach(function eacher(test){ | ||
tests_needed[test] = true; | ||
OPTS.enabled.forEach(function eacher(test){ | ||
if (tests_needed.hasOwnProperty(test)) { | ||
tests_needed[test] = true; | ||
} | ||
}); | ||
@@ -685,3 +714,8 @@ | ||
.filter(function filterer(test){ | ||
return tests_needed[test]; | ||
return ( | ||
// keep only tests that already passed... | ||
tests_needed[test] && | ||
// ...but exclude any explicitly disabled tests | ||
!~OPTS.disabled.indexOf(test) | ||
); | ||
}); | ||
@@ -688,0 +722,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59919
1068
184