├── .editorconfig ├── .gitignore ├── .jshintignore ├── .jshintrc ├── .npmignore ├── .travis.yml ├── AUTHORS ├── History.md ├── LICENSE ├── README.md ├── index.js ├── package.json └── test └── enable.test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | [*.md] 10 | trim_trailing_whitespace = false 11 | 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | coverage.html 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | 10 | pids 11 | logs 12 | results 13 | 14 | node_modules 15 | npm-debug.log 16 | coverage/ 17 | -------------------------------------------------------------------------------- /.jshintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | coverage/ 3 | .tmp/ 4 | .git/ 5 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | // JSHint Default Configuration File (as on JSHint website) 3 | // See http://jshint.com/docs/ for more details 4 | 5 | "maxerr" : 50, // {int} Maximum error before stopping 6 | 7 | // Enforcing 8 | "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) 9 | "camelcase" : false, // true: Identifiers must be in camelCase 10 | "curly" : true, // true: Require {} for every new block or scope 11 | "eqeqeq" : true, // true: Require triple equals (===) for comparison 12 | "forin" : false, // true: Require filtering for..in loops with obj.hasOwnProperty() 13 | "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` 14 | "indent" : false, // {int} Number of spaces to use for indentation 15 | "latedef" : false, // true: Require variables/functions to be defined before being used 16 | "newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()` 17 | "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` 18 | "noempty" : true, // true: Prohibit use of empty blocks 19 | "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) 20 | "plusplus" : false, // true: Prohibit use of `++` & `--` 21 | "quotmark" : false, // Quotation mark consistency: 22 | // false : do nothing (default) 23 | // true : ensure whatever is used is consistent 24 | // "single" : require single quotes 25 | // "double" : require double quotes 26 | "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) 27 | "unused" : true, // true: Require all defined variables be used 28 | "strict" : true, // true: Requires all functions run in ES5 Strict Mode 29 | "trailing" : false, // true: Prohibit trailing whitespaces 30 | "maxparams" : false, // {int} Max number of formal params allowed per function 31 | "maxdepth" : false, // {int} Max depth of nested blocks (within functions) 32 | "maxstatements" : false, // {int} Max number statements per function 33 | "maxcomplexity" : false, // {int} Max cyclomatic complexity per function 34 | "maxlen" : false, // {int} Max number of characters per line 35 | 36 | // Relaxing 37 | "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) 38 | "boss" : true, // true: Tolerate assignments where comparisons would be expected 39 | "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. 40 | "eqnull" : false, // true: Tolerate use of `== null` 41 | "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) 42 | "esnext" : true, // true: Allow ES.next (ES6) syntax (ex: `const`) 43 | "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) 44 | // (ex: `for each`, multiple try/catch, function expression…) 45 | "evil" : false, // true: Tolerate use of `eval` and `new Function()` 46 | "expr" : true, // true: Tolerate `ExpressionStatement` as Programs 47 | "funcscope" : false, // true: Tolerate defining variables inside control statements" 48 | "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') 49 | "iterator" : false, // true: Tolerate using the `__iterator__` property 50 | "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block 51 | "laxbreak" : true, // true: Tolerate possibly unsafe line breakings 52 | "laxcomma" : false, // true: Tolerate comma-first style coding 53 | "loopfunc" : false, // true: Tolerate functions being defined in loops 54 | "multistr" : true, // true: Tolerate multi-line strings 55 | "proto" : false, // true: Tolerate using the `__proto__` property 56 | "scripturl" : false, // true: Tolerate script-targeted URLs 57 | "smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment 58 | "shadow" : true, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` 59 | "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation 60 | "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` 61 | "validthis" : false, // true: Tolerate using this in a non-constructor function 62 | 63 | // Environments 64 | "browser" : true, // Web Browser (window, document, etc) 65 | "couch" : false, // CouchDB 66 | "devel" : true, // Development/debugging (alert, confirm, etc) 67 | "dojo" : false, // Dojo Toolkit 68 | "jquery" : false, // jQuery 69 | "mootools" : false, // MooTools 70 | "node" : true, // Node.js 71 | "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) 72 | "prototypejs" : false, // Prototype and Scriptaculous 73 | "rhino" : false, // Rhino 74 | "worker" : false, // Web Workers 75 | "wsh" : false, // Windows Scripting Host 76 | "yui" : false, // Yahoo User Interface 77 | "noyield" : true, // allow generators without a yield 78 | 79 | // Legacy 80 | "nomen" : false, // true: Prohibit dangling `_` in variables 81 | "onevar" : false, // true: Allow only one `var` statement per function 82 | "passfail" : false, // true: Stop on first error 83 | "white" : false, // true: Check against strict whitespace and indentation rules 84 | 85 | // Custom Globals 86 | "globals" : { // additional predefined global variables 87 | // mocha 88 | "describe": true, 89 | "it": true, 90 | "before": true, 91 | "afterEach": true, 92 | "beforeEach": true, 93 | "after": true 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | test/ 2 | Makefile 3 | .travis.yml 4 | logo.png 5 | .jshintignore 6 | .jshintrc 7 | .gitingore 8 | coverage/ 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - '4' 5 | - '6' 6 | - '8' 7 | - '10' 8 | - '12' 9 | - '13' 10 | script: "npm run test-cov" 11 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # Ordered by date of first contribution. 2 | # Auto-generated by 'contributors' on Thu, 30 Oct 2014 15:38:37 GMT. 3 | # https://github.com/xingrz/node-contributors 4 | 5 | fengmk2 (https://github.com/fengmk2) 6 | alsotang (https://github.com/alsotang) 7 | dead-horse (https://github.com/dead-horse) 8 | hemanth (https://github.com/hemanth) 9 | -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 2 | 3.4.0 / 2020-02-15 3 | ================== 4 | 5 | **features** 6 | * [[`d831d40`](http://github.com/node-modules/enable/commit/d831d404c749d0c73184c5357daf7fc6bed24d49)] - feat: detect arrow and async function (#28) (fengmk2 <>) 7 | 8 | **others** 9 | * [[`049d1b3`](http://github.com/node-modules/enable/commit/049d1b3f388371b55fdacb6bdf4d426224c40d30)] - Updated License. (hemanth.hm <>) 10 | * [[`0736fed`](http://github.com/node-modules/enable/commit/0736fedf9fe1b14e1729265eaeb94f038daf2dd0)] - Changelogs for v3.3.0 (Hemanth.HM <>) 11 | * [[`2af6043`](http://github.com/node-modules/enable/commit/2af6043b5a618f142dabc0d9da8c60b2df574629)] - 3.3.0 (Hemanth.HM <>), 12 | 3.3.0 / 2014-12-25 13 | ================== 14 | * All Array related checks. 15 | 16 | 3.2.0 / 2014-12-13 17 | ================== 18 | * All WeakSet related checks. 19 | * All Set related checks. 20 | 21 | 3.1.0/ 2014-12-09 22 | ================== 23 | * All WeakMap related checks. 24 | 25 | 3.0.0 / 2014-12-09 26 | ================== 27 | * All Map realted checks. 28 | 29 | 2.3.1 / 2014-12-08 30 | ================== 31 | * Better `isFunction` check. 32 | * s/realted/related README.md 33 | 34 | 2.3.0 / 2014-12-02 35 | ================== 36 | * ES7 Object methods. 37 | 38 | 39 | 2.2.0 / 2014-11-19 40 | ================== 41 | * Function.prototype.toMethod 42 | * RegExp.prototype.match 43 | * RegExp.prototype.replace 44 | * RegExp.prototype.split 45 | * RegExp.prototype.search 46 | 47 | 2.1.0 / 2014-11-17 48 | ================== 49 | * HTML methods of String.prototype (@hemanth). 50 | 51 | 2.0.0 / 2014-11-16 52 | ================== 53 | * Regex realted methods. 54 | * Major revamp (@hemanth) 55 | 56 | 1.3.2 / 2014-11-11 57 | ================== 58 | * Math realted methods. 59 | * Better readme. 60 | 61 | 62 | 1.3.1 / 2014-11-10 63 | ================== 64 | 65 | * Number method checks. 66 | 67 | 1.3.0 / 2014-11-10 68 | ================== 69 | 70 | * feat: Supports String checks. (@hemanth) 71 | 72 | 1.2.0 / 2014-10-31 73 | ================== 74 | 75 | * feat: Supports Object.{is,assign,getOwnPropertySymbols,setPrototypeOf} 76 | 77 | 1.1.0 / 2014-10-30 78 | ================== 79 | 80 | * Should detect const (@hemanth) 81 | 82 | 1.0.2 / 2014-10-30 83 | ================== 84 | 85 | * refactor, use eval 86 | * chore(travis): add before_install script 87 | 88 | 1.0.1 / 2014-10-30 89 | ================== 90 | 91 | * add `let` support (@alsotang) 92 | 93 | 1.0.0 / 2014-10-30 94 | ================== 95 | 96 | * first commit 97 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2015 fengmk2 <fengmk2@gmail.com> and other contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | 'Software'), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | enable 2 | ======= 3 | 4 | [![NPM version][npm-image]][npm-url] 5 | [![build status][travis-image]][travis-url] 6 | [![Test coverage][coveralls-image]][coveralls-url] 7 | [![Gittip][gittip-image]][gittip-url] 8 | [![David deps][david-image]][david-url] 9 | [![node version][node-image]][node-url] 10 | [![npm download][download-image]][download-url] 11 | 12 | [npm-image]: https://img.shields.io/npm/v/enable.svg?style=flat-square 13 | [npm-url]: https://npmjs.org/package/enable 14 | [travis-image]: https://img.shields.io/travis/node-modules/enable.svg?style=flat-square 15 | [travis-url]: https://travis-ci.org/node-modules/enable 16 | [coveralls-image]: https://img.shields.io/coveralls/node-modules/enable.svg?style=flat-square 17 | [coveralls-url]: https://coveralls.io/r/node-modules/enable?branch=master 18 | [gittip-image]: https://img.shields.io/gittip/fengmk2.svg?style=flat-square 19 | [gittip-url]: https://www.gittip.com/fengmk2/ 20 | [david-image]: https://img.shields.io/david/node-modules/enable.svg?style=flat-square 21 | [david-url]: https://david-dm.org/node-modules/enable 22 | [node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square 23 | [node-url]: http://nodejs.org/download/ 24 | [download-image]: https://img.shields.io/npm/dm/enable.svg?style=flat-square 25 | [download-url]: https://npmjs.org/package/enable 26 | 27 | Detect [es6](http://kangax.github.io/compat-table/es6) and [es7](http://kangax.github.io/compat-table/es7) 28 | features enable or not. 29 | 30 | ## Install 31 | 32 | ```bash 33 | $ npm install enable --save 34 | ``` 35 | 36 | ## Usage 37 | 38 | ```js 39 | var enable = require('enable'); 40 | 41 | if (enable.) { 42 | console.log( is supported); 43 | } 44 | 45 | /* Example: 46 | if (enable.generator) { 47 | console.log('supports generator: `function* a() {}`'); 48 | } 49 | */ 50 | ``` 51 | 52 | ## List of features: 53 | 54 | __Object related:__ 55 | 56 | * Object.is 57 | * Object.assign 58 | * Object.getOwnPropertySymbols 59 | * Object.setPrototypeOf 60 | * Object.observe 61 | * Object.Object.getOwnPropertyDescriptors 62 | 63 | __String related:__ 64 | 65 | * String.raw 66 | * String.fromCodePoint 67 | * String.prototype.codePointAt 68 | * String.prototype.normalize 69 | * String.prototype.repeat 70 | * String.prototype.startsWith 71 | * String.prototype.endsWith 72 | * String.prototype.contains 73 | * String.prototype.anchor 74 | * String.prototype.big 75 | * String.prototype.bold 76 | * String.prototype.fixed 77 | * String.prototype.fontcolor 78 | * String.prototype.fontsize 79 | * String.prototype.italics 80 | * String.prototype.link 81 | * String.prototype.small 82 | * String.prototype.strike 83 | * String.prototype.sub 84 | * String.prototype.sup 85 | 86 | __Number related:__ 87 | 88 | * Number.isFinite 89 | * Number.isInteger 90 | * Number.isSafeInteger 91 | * Number.isNaN 92 | * Number.EPSILON 93 | * Number.MIN_SAFE_INTEGER 94 | 95 | __Math related:__ 96 | 97 | * Math.clz32 98 | * Math.imul 99 | * Math.sign 100 | * Math.log10 101 | * Math.log2 102 | * Math.log1p 103 | * Math.expm1 104 | * Math.cosh 105 | * Math.sinh 106 | * Math.tanh 107 | * Math.acosh 108 | * Math.asinh 109 | * Math.atanh 110 | * Math.hypot 111 | * Math.trunc 112 | * Math.fround 113 | * Math.cbrt 114 | 115 | __RefExp methods:__ 116 | 117 | * RegExp.prototype.match 118 | * RegExp.prototype.replace 119 | * RegExp.prototype.split 120 | * RegExp.prototype.search 121 | 122 | __Map related:__ 123 | 124 | * Map 125 | * Map.prototype.size 126 | * Map.prototype.get 127 | * Map.prototype.has 128 | * Map.prototype.set 129 | * Map.prototype.delete 130 | * Map.prototype.keys 131 | * Map.prototype.values 132 | * Map.prototype.clear 133 | * Map.prototype.forEach 134 | * Map.prototype.entries 135 | 136 | __WeakMap related:__ 137 | 138 | * WeakMap 139 | * WeakMap.length 140 | * WeakMap.prototype.constructor 141 | * WeakMap.prototype.get 142 | * WeakMap.prototype.set 143 | * WeakMap.prototype.has 144 | * WeakMap.prototype.delete 145 | * WeakMap.prototype.clear 146 | 147 | __Set related:__ 148 | 149 | * Set 150 | * Set.prototype.constructor 151 | * Set.prototype.size 152 | * Set.prototype.add 153 | * Set.prototype.has 154 | * Set.prototype.delete 155 | * Set.prototype.clear 156 | * Set.prototype.forEach 157 | * Set.prototype.entries 158 | * Set.prototype.keys 159 | * Set.prototype.values 160 | 161 | __WeakSet related:__ 162 | 163 | * WeakSet 164 | * WeakSet.prototype.constructor 165 | * WeakSet.prototype.add 166 | * WeakSet.prototype.has 167 | * WeakSet.prototype.delete 168 | * WeakSet.prototype.clear 169 | 170 | __Array related:__ 171 | 172 | * Array.from 173 | * Array.of 174 | * Array.prototype.copyWithin 175 | * Array.prototype.find 176 | * Array.prototype.findIndex 177 | * Array.prototype.fill 178 | * Array.prototype.keys 179 | * Array.prototype.values 180 | * Array.prototype.entries 181 | 182 | __Others:__ 183 | 184 | * generator. 185 | * arrowFunction 186 | * asyncFunction 187 | * asyncArrowFunction 188 | * let. 189 | * const. 190 | * Promise. 191 | * class. 192 | 193 | ## Test 194 | 195 | ```bash 196 | $ npm install 197 | $ npm test 198 | ``` 199 | 200 | ### Coverage 201 | 202 | ```bash 203 | $ npm test-cov 204 | ``` 205 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Helper functions. 5 | */ 6 | 7 | function isFunction(attr) { 8 | return Object.prototype.toString.call(attr) === '[object Function]' 9 | } 10 | 11 | function isNumber(attr) { 12 | return typeof attr === 'number'; 13 | } 14 | 15 | // generator 16 | 17 | try { 18 | eval('(function* () {})()'); 19 | exports.generator = true; 20 | } catch (_) { 21 | exports.generator = false; 22 | } 23 | 24 | // arrow function 25 | 26 | try { 27 | eval('(() => {})()'); 28 | exports.arrowFunction = true; 29 | } catch (_) { 30 | exports.arrowFunction = false; 31 | } 32 | 33 | // async function 34 | 35 | try { 36 | eval('(async function() {})()'); 37 | exports.asyncFunction = true; 38 | } catch (_) { 39 | exports.asyncFunction = false; 40 | } 41 | 42 | // async arrow function 43 | 44 | try { 45 | eval('(async () => {})()'); 46 | exports.asyncArrowFunction = true; 47 | } catch (_) { 48 | exports.asyncArrowFunction = false; 49 | } 50 | 51 | // let 52 | 53 | try { 54 | eval('let a = 1;'); 55 | exports.let = true; 56 | } catch (_) { 57 | exports.let = false; 58 | } 59 | 60 | // const 61 | try { 62 | eval('(function () { const fubar = 42; return typeof fubar === "number"; }())'); 63 | exports.const = true; 64 | } catch (_) { 65 | exports.const = false; 66 | } 67 | 68 | // Object methods. 69 | var obj = {}; 70 | [ 71 | 'is','assign','getOwnPropertySymbols','setPrototypeOf', 72 | 'getOwnPropertyDescriptors','observe' 73 | ].forEach(function(attr){ 74 | obj[attr] = isFunction(Object[attr]); 75 | }); 76 | 77 | // String methods. 78 | var str = { prototype: {} }; 79 | ['raw','fromCodePoint'].forEach(function(attr){ 80 | str[attr] = isFunction(String[attr]); 81 | }); 82 | 83 | // Prototype methods of Strings. 84 | ['codePointAt','normalize','repeat','startsWith','endsWith','contains','includes'].forEach(function(attr){ 85 | str.prototype[attr] = isFunction(String.prototype[attr]); 86 | }); 87 | 88 | // String.prototype HTML methods. 89 | [ 90 | 'anchor','big','bold','fixed','fontcolor','fontsize','italics', 91 | 'link', 'small', 'strike', 'sub', 'sup' 92 | ].forEach(function(attr){ 93 | str.prototype[attr] = isFunction(String.prototype[attr]); 94 | }); 95 | 96 | // Number methods. 97 | var num = {}; 98 | [ 99 | 'isFinite','isInteger','isSafeInteger','isNaN', 100 | 'EPSILON','MIN_SAFE_INTEGER','MAX_SAFE_INTEGER' 101 | ].forEach(function(attr){ 102 | num[attr] = isFunction(Number[attr]); 103 | }); 104 | 105 | // Math methods. 106 | var math = {} 107 | "clz32,imul,sign,log10,log2,log1p,expm1,cosh,sinh,tanh,acosh,sinh,tanh,acosh,asinh,atanh,hypot,trunc,fround,cbrt" 108 | .split(",") 109 | .forEach(function(attr){ 110 | math[attr] = isFunction(Math[attr]); 111 | }); 112 | 113 | // RegExp methods. 114 | var regex = {'prototype' : {} }; 115 | ['match', 'replace', 'split', 'search'].forEach(function(attr){ 116 | regex.prototype[attr] = isFunction(RegExp[attr]); 117 | }); 118 | 119 | // Function methods. 120 | var func = {'prototype': {}}; 121 | func.prototype.toMethod = isFunction(Function.prototype.toMethod); 122 | 123 | // class. 124 | var klass = (function(){ 125 | try { 126 | return Function("\nclass Cat {}\nreturn typeof Cat === \"function\";\n ")(); 127 | } catch(e){ 128 | return false; 129 | } 130 | }()); 131 | 132 | // Map. 133 | var map = (function(){ 134 | if(typeof Map !== 'undefined' && isFunction(Map)){ 135 | var map = { 'prototype': {} }; 136 | [ 137 | "get", "has", "set", 138 | "delete", "keys", "values", 139 | "clear", "forEach", "entries" 140 | ].forEach(function(attr){ 141 | map.prototype[attr] = isFunction(Map.prototype[attr]); 142 | }); 143 | map.prototype['size'] = !~~Object.getOwnPropertyDescriptor(Map.prototype,'size') 144 | return map; 145 | } else { 146 | return false; 147 | } 148 | }()); 149 | 150 | //WeakMap. 151 | var wm = (function(){ 152 | if(typeof WeakMap !== 'undefined' && isFunction(WeakMap)){ 153 | var wm = { 'prototype': {} }; 154 | [ 155 | "constructor", "get", "set", 156 | "has", "delete", "clear" 157 | ].forEach(function(attr){ 158 | wm.prototype[attr] = isFunction(WeakMap.prototype[attr]); 159 | }); 160 | wm.length = isNumber(WeakMap.length); 161 | return wm; 162 | } else { 163 | return false; 164 | } 165 | }()); 166 | 167 | //Set. 168 | var set = (function(){ 169 | if(typeof Set !== 'undefined' && isFunction(Set)){ 170 | var set = { 'prototype': {} }; 171 | [ 172 | "constructor", "add", 173 | "has", "delete", "clear", 174 | "forEach", "entries", "keys", "values" 175 | ].forEach(function(attr){ 176 | set.prototype[attr] = isFunction(Set.prototype[attr]); 177 | }); 178 | set.prototype['size'] = !~~Object.getOwnPropertyDescriptor(Map.prototype,'size') 179 | return set; 180 | } else { 181 | return false; 182 | } 183 | }()); 184 | 185 | //WeakSet. 186 | var ws = (function(){ 187 | if(typeof WeakSet !== 'undefined' && isFunction(WeakSet)){ 188 | var ws = { 'prototype': {} }; 189 | [ 190 | "constructor", "add", 191 | "has", "delete", "clear" 192 | ].forEach(function(attr){ 193 | ws.prototype[attr] = isFunction(WeakSet.prototype[attr]); 194 | }); 195 | ws.length = isNumber(WeakMap.length); 196 | return ws; 197 | } else { 198 | return false; 199 | } 200 | }()); 201 | 202 | //Array. 203 | var array = (function(){ 204 | var array = { prototype : {} }; 205 | array.from = isFunction(Array.from); 206 | array.of = isFunction(Array.of); 207 | [ 208 | "copyWithin", "find", "findIndex", 209 | "fill", "keys", "values", "entries" 210 | ].forEach(function(attr){ 211 | array.prototype[attr] = isFunction(Array.prototype[attr]); 212 | }); 213 | return array; 214 | }()); 215 | 216 | 217 | // Export them all 218 | exports.Object = obj; 219 | exports.String = str; 220 | exports.Number = num; 221 | exports.Math = math; 222 | exports.RegExp = regex; 223 | exports.Promise = typeof Promise !== 'undefined' && isFunction(Promise.all); 224 | exports.Function = func; 225 | exports.class = klass; 226 | exports.Map = map; 227 | exports.WeakMap = wm; 228 | exports.Set = set; 229 | exports.WeakSet = ws; 230 | exports.Array = array; 231 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "enable", 3 | "version": "3.4.0", 4 | "description": "ES6 and ES7 feature detection.", 5 | "main": "index.js", 6 | "files": [ 7 | "index.js" 8 | ], 9 | "scripts": { 10 | "test": "mocha --check-leaks -R spec -t 5000 -r should test/*.test.js", 11 | "test-cov": "istanbul cover node_modules/.bin/_mocha -- --check-leaks -t 5000 -r should test/*.test.js", 12 | "jshint": "jshint .", 13 | "autod": "autod -w --prefix '~' && npm run cnpm", 14 | "cnpm": "npm install --registry=https://registry.npm.taobao.org", 15 | "contributors": "contributors -f plain -o AUTHORS" 16 | }, 17 | "dependencies": {}, 18 | "devDependencies": { 19 | "autod": "*", 20 | "contributors": "*", 21 | "should": "*", 22 | "jshint": "*", 23 | "istanbul-harmony": "*", 24 | "mocha": "2" 25 | }, 26 | "homepage": "https://github.com/node-modules/enable", 27 | "repository": { 28 | "type": "git", 29 | "url": "git://github.com/node-modules/enable.git", 30 | "web": "https://github.com/node-modules/enable" 31 | }, 32 | "bugs": { 33 | "url": "https://github.com/node-modules/enable/issues", 34 | "email": "fengmk2@gmail.com" 35 | }, 36 | "keywords": [ 37 | "enable", 38 | "es6", 39 | "es7", 40 | "detect", 41 | "generator" 42 | ], 43 | "engines": { 44 | "node": ">= 0.10.0" 45 | }, 46 | "author": "fengmk2 (https://fengmk2.com)", 47 | "license": "MIT" 48 | } 49 | -------------------------------------------------------------------------------- /test/enable.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var enable = require('..'); 4 | 5 | var version = process.version; 6 | var node = { 7 | v010: version.indexOf('v0.10.') === 0, 8 | v012: version.indexOf('v0.12.') === 0, 9 | v4: version.indexOf('v4.') === 0, 10 | v6: version.indexOf('v6.') === 0, 11 | v8: version.indexOf('v8.') === 0, 12 | v10: version.indexOf('v10.') === 0, 13 | v12: version.indexOf('v12.') === 0, 14 | v13: version.indexOf('v13.') === 0, 15 | }; 16 | 17 | describe('enable.test.js', function () { 18 | it('should detect generator', function () { 19 | enable.generator.should.be.a.Boolean; 20 | if (node.v010) { 21 | enable.generator.should.equal(false); 22 | } else { 23 | enable.generator.should.equal(true); 24 | } 25 | }); 26 | 27 | it('should detect arrow function', function () { 28 | enable.arrowFunction.should.be.a.Boolean; 29 | if (node.v012) { 30 | enable.arrowFunction.should.equal(false); 31 | } else { 32 | enable.arrowFunction.should.equal(true); 33 | } 34 | }); 35 | 36 | it('should detect async function', function () { 37 | enable.asyncFunction.should.be.a.Boolean; 38 | if (node.v4 || node.v6) { 39 | enable.asyncFunction.should.equal(false); 40 | } else { 41 | enable.asyncFunction.should.equal(true); 42 | } 43 | }); 44 | 45 | it('should detect async arrow function', function () { 46 | enable.asyncArrowFunction.should.be.a.Boolean; 47 | if (node.v4 || node.v6) { 48 | enable.asyncArrowFunction.should.equal(false); 49 | } else { 50 | enable.asyncArrowFunction.should.equal(true); 51 | } 52 | }); 53 | 54 | it('should detect let', function () { 55 | enable.let.should.be.a.Boolean; 56 | enable.let.should.equal(true); 57 | }); 58 | 59 | it("should detect const", function() { 60 | enable.const.should.be.a.Boolean; 61 | enable.const.should.equal(true); 62 | }); 63 | 64 | it("should detect Object.is", function() { 65 | enable.Object.is.should.be.a.Boolean; 66 | enable.Object.is.should.equal(true); 67 | }); 68 | 69 | it("should detect Object.assign", function() { 70 | enable.Object.assign.should.be.a.Boolean; 71 | if (node.v010) { 72 | enable.Object.assign.should.equal(false); 73 | } else { 74 | enable.Object.assign.should.equal(true); 75 | } 76 | }); 77 | 78 | it("should detect Object.getOwnPropertySymbols", function() { 79 | enable.Object.getOwnPropertySymbols.should.be.a.Boolean; 80 | if (node.v010) { 81 | enable.Object.getOwnPropertySymbols.should.equal(false); 82 | } else { 83 | enable.Object.getOwnPropertySymbols.should.equal(true); 84 | } 85 | }); 86 | 87 | it("should detect Object.setPrototypeOf", function() { 88 | enable.Object.setPrototypeOf.should.be.a.Boolean; 89 | if (node.v010) { 90 | enable.Object.setPrototypeOf.should.equal(false); 91 | } else { 92 | enable.Object.setPrototypeOf.should.equal(true); 93 | } 94 | }); 95 | 96 | it("should detect Object.observe", function(){ 97 | enable.Object.observe.should.be.Boolean; 98 | if (node.v4) { 99 | enable.Object.observe.should.equal(true); 100 | } else { 101 | enable.Object.observe.should.equal(false); 102 | } 103 | }); 104 | 105 | it("should detect Object.getOwnPropertyDescriptors", function(){ 106 | enable.Object.getOwnPropertyDescriptors.should.be.Boolean; 107 | if (node.v010 || 108 | node.v4 || 109 | node.v6) { 110 | enable.Object.getOwnPropertyDescriptors.should.equal(false); 111 | } else { 112 | enable.Object.getOwnPropertyDescriptors.should.equal(true); 113 | } 114 | }); 115 | 116 | it("should detect String.raw", function() { 117 | enable.String.raw.should.be.a.Boolean; 118 | if (node.v010) { 119 | enable.String.raw.should.equal(false); 120 | } else { 121 | enable.String.raw.should.equal(true); 122 | } 123 | }); 124 | 125 | it("should detect String.fromCodePoint", function() { 126 | enable.String.fromCodePoint.should.be.a.Boolean; 127 | if (node.v010) { 128 | enable.String.fromCodePoint.should.equal(false); 129 | } else { 130 | enable.String.fromCodePoint.should.equal(true); 131 | } 132 | }); 133 | 134 | it("should detect String.prototype.codePointAt", function() { 135 | enable.String.prototype.codePointAt.should.be.a.Boolean; 136 | if (node.v010) { 137 | enable.String.prototype.codePointAt.should.equal(false); 138 | } else { 139 | enable.String.prototype.codePointAt.should.equal(true); 140 | } 141 | }); 142 | 143 | it("should detect String.prototype.normalize", function() { 144 | enable.String.prototype.normalize.should.be.a.Boolean; 145 | if (node.v010) { 146 | enable.String.prototype.normalize.should.equal(false); 147 | } else { 148 | enable.String.prototype.normalize.should.equal(true); 149 | } 150 | }); 151 | 152 | it("should detect String.prototype.repeat", function() { 153 | enable.String.prototype.repeat.should.be.a.Boolean; 154 | if (node.v010) { 155 | enable.String.prototype.repeat.should.equal(false); 156 | } else { 157 | enable.String.prototype.repeat.should.equal(true); 158 | } 159 | }); 160 | 161 | it("should detect String.prototype.startsWith", function() { 162 | enable.String.prototype.startsWith.should.be.a.Boolean; 163 | if (node.v010) { 164 | enable.String.prototype.startsWith.should.equal(false); 165 | } else { 166 | enable.String.prototype.startsWith.should.equal(true); 167 | } 168 | }); 169 | 170 | it("should detect String.prototype.endsWith", function() { 171 | enable.String.prototype.endsWith.should.be.a.Boolean; 172 | if (node.v010) { 173 | enable.String.prototype.endsWith.should.equal(false); 174 | } else { 175 | enable.String.prototype.endsWith.should.equal(true); 176 | } 177 | }); 178 | 179 | it("should detect String.prototype.contains", function() { 180 | enable.String.prototype.contains.should.be.a.Boolean; 181 | if (node.v010) { 182 | enable.String.prototype.contains.should.equal(false); 183 | } else { 184 | enable.String.prototype.contains.should.equal(false); 185 | } 186 | }); 187 | 188 | it("should detect String.prototype.includes", function() { 189 | enable.String.prototype.includes.should.be.a.Boolean; 190 | if (node.v010) { 191 | enable.String.prototype.includes.should.equal(false); 192 | } else { 193 | enable.String.prototype.includes.should.equal(true); 194 | } 195 | }); 196 | 197 | it("should detect HTML methods of String.prototype", function(){ 198 | [ 199 | 'anchor','big','bold','fixed','fontcolor','fontsize','italics', 200 | 'link', 'small', 'strike', 'sub', 'sup' 201 | ].forEach(function(attr){ 202 | enable.String.prototype[attr].should.be.a.Boolean; 203 | enable.String.prototype[attr].should.equal(true); 204 | }); 205 | }); 206 | 207 | it("should detect Number.isFinite", function(){ 208 | enable.Number.isFinite.should.be.a.Boolean; 209 | enable.Number.isFinite.should.equal(true); 210 | }); 211 | 212 | it("should detect Number.isInteger", function(){ 213 | enable.Number.isInteger.should.be.a.Boolean; 214 | enable.Number.isInteger.should.equal(true); 215 | }); 216 | 217 | it("should detect Number.isSafeInteger", function(){ 218 | enable.Number.isSafeInteger.should.be.a.Boolean; 219 | if (node.v010) { 220 | enable.Number.isSafeInteger.should.equal(false); 221 | } else { 222 | enable.Number.isSafeInteger.should.equal(true); 223 | } 224 | }); 225 | 226 | it("should detect Number.isNaN", function(){ 227 | enable.Number.isNaN.should.be.a.Boolean; 228 | enable.Number.isNaN.should.equal(true); 229 | }); 230 | 231 | it("should detect Number.EPSILON", function(){ 232 | enable.Number.EPSILON.should.be.a.Boolean; 233 | if (node.v010) { 234 | enable.Number.EPSILON.should.equal(false); 235 | } else { 236 | enable.Number.EPSILON.should.equal(false); 237 | } 238 | }); 239 | 240 | it("should detect Number.MIN_SAFE_INTEGER", function(){ 241 | enable.Number.MIN_SAFE_INTEGER.should.be.a.Boolean; 242 | if (node.v010) { 243 | enable.Number.MIN_SAFE_INTEGER.should.equal(false); 244 | } else { 245 | enable.Number.MIN_SAFE_INTEGER.should.equal(false); 246 | } 247 | }); 248 | 249 | it("should detect Math.clz32", function(){ 250 | enable.Math.clz32.should.be.a.Boolean; 251 | if (node.v010) { 252 | enable.Math.clz32.should.equal(false); 253 | } else { 254 | enable.Math.clz32.should.equal(true); 255 | } 256 | }); 257 | 258 | it("should detect Math.imul", function(){ 259 | enable.Math.imul.should.be.a.Boolean; 260 | if (node.v010) { 261 | enable.Math.imul.should.equal(false); 262 | } else { 263 | enable.Math.imul.should.equal(true); 264 | } 265 | }); 266 | 267 | it("should detect Math.sign", function(){ 268 | enable.Math.sign.should.be.a.Boolean; 269 | if (node.v010) { 270 | enable.Math.sign.should.equal(false); 271 | } else { 272 | enable.Math.sign.should.equal(true); 273 | } 274 | }); 275 | 276 | it("should detect Math.log10", function(){ 277 | enable.Math.log10.should.be.a.Boolean; 278 | if (node.v010) { 279 | enable.Math.log10.should.equal(false); 280 | } else { 281 | enable.Math.log10.should.equal(true); 282 | } 283 | }); 284 | 285 | it("should detect Math.log2", function(){ 286 | enable.Math.log2.should.be.a.Boolean; 287 | if (node.v010) { 288 | enable.Math.log2.should.equal(false); 289 | } else { 290 | enable.Math.log2.should.equal(true); 291 | } 292 | }); 293 | 294 | it("should detect Math.log1p", function(){ 295 | enable.Math.log1p.should.be.a.Boolean; 296 | if (node.v010) { 297 | enable.Math.log1p.should.equal(false); 298 | } else { 299 | enable.Math.log1p.should.equal(true); 300 | } 301 | }); 302 | 303 | it("should detect Math.expm1", function(){ 304 | enable.Math.expm1.should.be.a.Boolean; 305 | if (node.v010) { 306 | enable.Math.expm1.should.equal(false); 307 | } else { 308 | enable.Math.expm1.should.equal(true); 309 | } 310 | }); 311 | 312 | it("should detect Math.cosh", function(){ 313 | enable.Math.cosh.should.be.a.Boolean; 314 | if (node.v010) { 315 | enable.Math.cosh.should.equal(false); 316 | } else { 317 | enable.Math.cosh.should.equal(true); 318 | } 319 | }); 320 | 321 | it("should detect Math.sinh", function(){ 322 | enable.Math.sinh.should.be.a.Boolean; 323 | if (node.v010) { 324 | enable.Math.sinh.should.equal(false); 325 | } else { 326 | enable.Math.sinh.should.equal(true); 327 | } 328 | }); 329 | 330 | it("should detect Math.tanh", function(){ 331 | enable.Math.tanh.should.be.a.Boolean; 332 | if (node.v010) { 333 | enable.Math.tanh.should.equal(false); 334 | } else { 335 | enable.Math.tanh.should.equal(true); 336 | } 337 | }); 338 | 339 | it("should detect Math.acosh", function(){ 340 | enable.Math.acosh.should.be.a.Boolean; 341 | if (node.v010) { 342 | enable.Math.acosh.should.equal(false); 343 | } else { 344 | enable.Math.acosh.should.equal(true); 345 | } 346 | }); 347 | 348 | it("should detect Math.asinh", function(){ 349 | enable.Math.asinh.should.be.a.Boolean; 350 | if (node.v010) { 351 | enable.Math.asinh.should.equal(false); 352 | } else { 353 | enable.Math.asinh.should.equal(true); 354 | } 355 | }); 356 | 357 | it("should detect Math.atanh", function(){ 358 | enable.Math.atanh.should.be.a.Boolean; 359 | if (node.v010) { 360 | enable.Math.atanh.should.equal(false); 361 | } else { 362 | enable.Math.atanh.should.equal(true); 363 | } 364 | }); 365 | 366 | it("should detect Math.hypot", function(){ 367 | enable.Math.hypot.should.be.a.Boolean; 368 | if (node.v010) { 369 | enable.Math.hypot.should.equal(false); 370 | } else { 371 | enable.Math.hypot.should.equal(true); 372 | } 373 | }); 374 | 375 | it("should detect Math.trunc", function(){ 376 | enable.Math.trunc.should.be.a.Boolean; 377 | if (node.v010) { 378 | enable.Math.trunc.should.equal(false); 379 | } else { 380 | enable.Math.trunc.should.equal(true); 381 | } 382 | }); 383 | 384 | it("should detect Math.fround", function(){ 385 | enable.Math.fround.should.be.a.Boolean; 386 | if (node.v010) { 387 | enable.Math.fround.should.equal(false); 388 | } else { 389 | enable.Math.fround.should.equal(true); 390 | } 391 | }); 392 | 393 | it("should detect Math.cbrt", function(){ 394 | enable.Math.cbrt.should.be.a.Boolean; 395 | if (node.v010) { 396 | enable.Math.cbrt.should.equal(false); 397 | } else { 398 | enable.Math.cbrt.should.equal(true); 399 | } 400 | }); 401 | 402 | it("should detect Promise", function(){ 403 | enable.Promise.should.be.a.Boolean; 404 | if (node.v010) { 405 | enable.Promise.should.equal(false); 406 | } else { 407 | enable.Promise.should.equal(true); 408 | } 409 | }); 410 | 411 | it("should detect RegExp.prototype.match", function(){ 412 | enable.RegExp.prototype.match.should.be.a.Boolean; 413 | if (node.v010) { 414 | enable.RegExp.prototype.match.should.equal(false); 415 | } else { 416 | enable.RegExp.prototype.match.should.equal(false); 417 | } 418 | }); 419 | 420 | it("should detect RegExp.prototype.replace", function(){ 421 | enable.RegExp.prototype.replace.should.be.a.Boolean; 422 | if (node.v010) { 423 | enable.RegExp.prototype.replace.should.equal(false); 424 | } else { 425 | enable.RegExp.prototype.replace.should.equal(false); 426 | } 427 | }); 428 | 429 | it("should detect RegExp.prototype.split", function(){ 430 | enable.RegExp.prototype.split.should.be.a.Boolean; 431 | if (node.v010) { 432 | enable.RegExp.prototype.split.should.equal(false); 433 | } else { 434 | enable.RegExp.prototype.split.should.equal(false); 435 | } 436 | }); 437 | 438 | it("should detect RegExp.prototype.search", function(){ 439 | enable.RegExp.prototype.search.should.be.a.Boolean; 440 | if (node.v010) { 441 | enable.RegExp.prototype.search.should.equal(false); 442 | } else { 443 | enable.RegExp.prototype.search.should.equal(false); 444 | } 445 | }); 446 | 447 | it("should detect Function.prototype.toMethod", function(){ 448 | enable.Function.prototype.toMethod.should.be.Boolean; 449 | if (node.v010) { 450 | enable.Function.prototype.toMethod.should.equal(false); 451 | } else { 452 | enable.Function.prototype.toMethod.should.equal(false); 453 | } 454 | }); 455 | 456 | it("should detect class", function(){ 457 | enable.class.should.be.Boolean; 458 | if (node.v010 || node.v4) { 459 | enable.class.should.equal(false); 460 | } else { 461 | enable.class.should.equal(true); 462 | } 463 | }); 464 | 465 | it("should detect Map", function(){ 466 | enable.Map.should.be.Object; 467 | Object.keys(enable.Map).length.should.equal(1); 468 | }); 469 | 470 | if(enable.Map) { 471 | it("should detect Map.prototype.size", function() { 472 | enable.Map.prototype.size.should.be.Boolean; 473 | enable.Map.prototype.size.should.equal(true); 474 | }); 475 | it("should detect Map.prototype.get", function() { 476 | enable.Map.prototype.get.should.be.Boolean; 477 | enable.Map.prototype.get.should.equal(true); 478 | }); 479 | it("should detect Map.prototype.has", function() { 480 | enable.Map.prototype.has.should.be.Boolean; 481 | enable.Map.prototype.has.should.equal(true); 482 | }); 483 | it("should detect Map.prototype.set", function() { 484 | enable.Map.prototype.set.should.equal(true); 485 | }); 486 | it("should detect Map.prototype.delete", function() { 487 | enable.Map.prototype.delete.should.be.Boolean; 488 | enable.Map.prototype.delete.should.equal(true); 489 | }); 490 | it("should detect Map.prototype.keys", function() { 491 | enable.Map.prototype.keys.should.equal(true); 492 | }); 493 | it("should detect Map.prototype.values", function() { 494 | enable.Map.prototype.values.should.be.Boolean; 495 | enable.Map.prototype.values.should.equal(true); 496 | }); 497 | it("should detect Map.prototype.clear", function() { 498 | enable.Map.prototype.clear.should.be.Boolean; 499 | if (node.v010) { 500 | enable.Map.prototype.clear.should.equal(false); 501 | } else { 502 | enable.Map.prototype.clear.should.equal(true); 503 | } 504 | }); 505 | it("should detect Map.prototype.forEach", function() { 506 | enable.Map.prototype.forEach.should.be.Boolean; 507 | if (node.v010) { 508 | enable.Map.prototype.forEach.should.equal(false); 509 | } else { 510 | enable.Map.prototype.forEach.should.equal(true); 511 | } 512 | }); 513 | it("should detect Map.prototype.entries", function() { 514 | enable.Map.prototype.entries.should.be.Boolean; 515 | if (node.v010) { 516 | enable.Map.prototype.entries.should.equal(false); 517 | } else { 518 | enable.Map.prototype.entries.should.equal(true); 519 | } 520 | }); 521 | } 522 | 523 | it("should detect WeakMap", function() { 524 | enable.WeakMap.should.be.Object; 525 | Object.keys(enable.WeakMap).length.should.equal(2); 526 | }); 527 | 528 | if(enable.WeakMap){ 529 | it("should detect WeakMap.length", function() { 530 | enable.WeakMap.length.should.be.Boolean; 531 | enable.WeakMap.length.should.equal(true); 532 | }); 533 | it("should detect WeakMap.prototype.constructor", function() { 534 | enable.WeakMap.prototype.constructor.should.be.Boolean; 535 | enable.WeakMap.prototype.constructor.should.equal(true); 536 | }); 537 | it("should detect WeakMap.prototype.get", function() { 538 | enable.WeakMap.prototype.get.should.be.Boolean; 539 | enable.WeakMap.prototype.get.should.equal(true); 540 | }); 541 | it("should detect WeakMap.prototype.set", function() { 542 | enable.WeakMap.prototype.set.should.be.Boolean; 543 | enable.WeakMap.prototype.set.should.equal(true); 544 | }); 545 | it("should detect WeakMap.prototype.has", function() { 546 | enable.WeakMap.prototype.has.should.be.Boolean; 547 | enable.WeakMap.prototype.has.should.equal(true); 548 | }); 549 | it("should detect WeakMap.prototype.delete", function() { 550 | enable.WeakMap.prototype.delete.should.be.Boolean; 551 | enable.WeakMap.prototype.delete.should.equal(true); 552 | }); 553 | it("should detect WeakMap.prototype.clear", function() { 554 | enable.WeakMap.prototype.clear.should.be.Boolean; 555 | if (node.v010 || node.v4 || node.v6) { 556 | enable.WeakMap.prototype.clear.should.equal(false); 557 | } else { 558 | enable.WeakMap.prototype.clear.should.equal(false); 559 | } 560 | }); 561 | } 562 | 563 | it("should detect Set", function() { 564 | enable.Set.should.be.Object; 565 | Object.keys(enable.Set).length.should.equal(1); 566 | }); 567 | 568 | if (enable.Set) { 569 | it("should detect Set.prototype.constructor", function() { 570 | enable.Set.prototype.constructor.should.be.Boolean; 571 | enable.Set.prototype.constructor.should.equal(true); 572 | }); 573 | it("should detect Set.prototype.size", function() { 574 | enable.Set.prototype.size.should.be.Boolean; 575 | enable.Set.prototype.size.should.equal(true); 576 | }); 577 | it("should detect Set.prototype.add", function() { 578 | enable.Set.prototype.add.should.be.Boolean; 579 | enable.Set.prototype.add.should.equal(true); 580 | }); 581 | it("should detect Set.prototype.has", function() { 582 | enable.Set.prototype.has.should.be.Boolean; 583 | enable.Set.prototype.has.should.equal(true); 584 | }); 585 | it("should detect Set.prototype.delete", function() { 586 | enable.Set.prototype.delete.should.be.Boolean; 587 | enable.Set.prototype.delete.should.equal(true); 588 | }); 589 | it("should detect Set.prototype.clear", function() { 590 | enable.Set.prototype.clear.should.be.Boolean; 591 | if (node.v010) { 592 | enable.Set.prototype.clear.should.equal(false); 593 | } else { 594 | enable.Set.prototype.clear.should.equal(true); 595 | } 596 | }); 597 | it("should detect Set.prototype.forEach", function() { 598 | enable.Set.prototype.forEach.should.be.Boolean; 599 | if (node.v010) { 600 | enable.Set.prototype.forEach.should.equal(false); 601 | } else { 602 | enable.Set.prototype.forEach.should.equal(true); 603 | } 604 | }); 605 | it("should detect Set.prototype.entries", function() { 606 | enable.Set.prototype.entries.should.be.Boolean; 607 | if (node.v010) { 608 | enable.Set.prototype.entries.should.equal(false); 609 | } else { 610 | enable.Set.prototype.entries.should.equal(true); 611 | } 612 | }); 613 | it("should detect Set.prototype.keys", function() { 614 | enable.Set.prototype.keys.should.be.Boolean; 615 | if (node.v010) { 616 | enable.Set.prototype.keys.should.equal(false); 617 | } else { 618 | enable.Set.prototype.keys.should.equal(true); 619 | } 620 | }); 621 | it("should detect Set.prototype.values", function() { 622 | enable.Set.prototype.values.should.be.Boolean; 623 | if (node.v010) { 624 | enable.Set.prototype.values.should.equal(false); 625 | } else { 626 | enable.Set.prototype.values.should.equal(true); 627 | } 628 | }); 629 | } 630 | 631 | it("should detect WeakSet", function() { 632 | if (node.v010) { 633 | enable.WeakSet.should.be.Boolean; 634 | enable.WeakSet.should.equal(false); 635 | } else { 636 | enable.WeakSet.should.be.Object; 637 | Object.keys(enable.WeakSet).length.should.equal(2); 638 | } 639 | }); 640 | 641 | if (enable.WeakSet) { 642 | it("should detect WeakSet.prototype.constructor", function() { 643 | enable.WeakSet.prototype.constructor.should.be.Boolean; 644 | if (node.v010) { 645 | enable.WeakSet.prototype.constructor.should.equal(false); 646 | } 647 | if (process.version.indexOf('v0.11.') === 0) { 648 | enable.WeakSet.prototype.constructor.should.equal(true); 649 | } 650 | }); 651 | 652 | it("should detect WeakSet.prototype.add", function() { 653 | enable.WeakSet.prototype.add.should.be.Boolean; 654 | if (node.v010) { 655 | enable.WeakSet.prototype.add.should.equal(false); 656 | } else { 657 | enable.WeakSet.prototype.add.should.equal(true); 658 | } 659 | }); 660 | 661 | it("should detect WeakSet.prototype.has", function() { 662 | enable.WeakSet.prototype.has.should.be.Boolean; 663 | if (node.v010) { 664 | enable.WeakSet.prototype.has.should.equal(false); 665 | } else { 666 | enable.WeakSet.prototype.has.should.equal(true); 667 | } 668 | }); 669 | 670 | it("should detect WeakSet.prototype.delete", function() { 671 | enable.WeakSet.prototype.delete.should.be.Boolean; 672 | if (node.v010) { 673 | enable.WeakSet.prototype.delete.should.equal(false); 674 | } else { 675 | enable.WeakSet.prototype.delete.should.equal(true); 676 | } 677 | }); 678 | 679 | it("should detect WeakSet.prototype.clear", function() { 680 | enable.WeakSet.prototype.clear.should.be.Boolean; 681 | if (node.v010 || node.v4 || node.v6 || node.v8 || node.v10) { 682 | enable.WeakSet.prototype.clear.should.equal(false); 683 | } else { 684 | enable.WeakSet.prototype.clear.should.equal(false); 685 | } 686 | }); 687 | } 688 | 689 | it("should detect Array.from", function() { 690 | enable.Array.from.should.be.Boolean; 691 | if (node.v010) { 692 | enable.Array.from.should.equal(false); 693 | } else { 694 | enable.Array.from.should.equal(true); 695 | } 696 | }); 697 | it("should detect Array.of", function() { 698 | enable.Array.of.should.be.Boolean; 699 | if (node.v010) { 700 | enable.Array.of.should.equal(false); 701 | } else { 702 | enable.Array.of.should.equal(true); 703 | } 704 | }); 705 | it("should detect Array.prototype.copyWithin", function() { 706 | enable.Array.prototype.copyWithin.should.be.Boolean; 707 | if (node.v010) { 708 | enable.Array.prototype.copyWithin.should.equal(false); 709 | } else { 710 | enable.Array.prototype.copyWithin.should.equal(true); 711 | } 712 | }); 713 | it("should detect Array.prototype.find", function() { 714 | enable.Array.prototype.find.should.be.Boolean; 715 | if (node.v010) { 716 | enable.Array.prototype.find.should.equal(false); 717 | } else { 718 | enable.Array.prototype.find.should.equal(true); 719 | } 720 | }); 721 | it("should detect Array.prototype.findIndex", function() { 722 | enable.Array.prototype.findIndex.should.be.Boolean; 723 | if (node.v010) { 724 | enable.Array.prototype.findIndex.should.equal(false); 725 | } else { 726 | enable.Array.prototype.findIndex.should.equal(true); 727 | } 728 | }); 729 | it("should detect Array.prototype.fill", function() { 730 | enable.Array.prototype.fill.should.be.Boolean; 731 | if (node.v010) { 732 | enable.Array.prototype.fill.should.equal(false); 733 | } else { 734 | enable.Array.prototype.fill.should.equal(true); 735 | } 736 | }); 737 | it("should detect Array.prototype.keys", function() { 738 | enable.Array.prototype.keys.should.be.Boolean; 739 | if (node.v010) { 740 | enable.Array.prototype.keys.should.equal(false); 741 | } else { 742 | enable.Array.prototype.keys.should.equal(true); 743 | } 744 | }); 745 | it("should detect Array.prototype.values", function() { 746 | enable.Array.prototype.values.should.be.Boolean; 747 | if (node.v010 || 748 | node.v4 || 749 | node.v6 || 750 | node.v8) { 751 | enable.Array.prototype.values.should.equal(false); 752 | } else { 753 | enable.Array.prototype.values.should.equal(true); 754 | } 755 | }); 756 | it("should detect Array.prototype.entries", function() { 757 | enable.Array.prototype.entries.should.be.Boolean; 758 | if (node.v010) { 759 | enable.Array.prototype.entries.should.equal(false); 760 | } else { 761 | enable.Array.prototype.entries.should.equal(true); 762 | } 763 | }); 764 | }); 765 | --------------------------------------------------------------------------------