feature-detect-es6
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -8,2 +8,10 @@ 'use strict' | ||
* @typicalname detect | ||
* @example | ||
* var detect = require('feature-detect-es6') | ||
* | ||
* if (detect.class() && detect.arrowFunction()){ | ||
* // safe to run ES6 code natively.. | ||
* } else { | ||
* // run your transpiled ES5.. | ||
* } | ||
*/ | ||
@@ -38,1 +46,29 @@ | ||
} | ||
/** | ||
* Returns true if the `let` statement is available. | ||
* | ||
* @returns {boolean} | ||
*/ | ||
exports.let = function () { | ||
try { | ||
eval('let a = 1') | ||
return true | ||
} catch (err) { | ||
return false | ||
} | ||
} | ||
/** | ||
* Returns true if the `const` statement is available. | ||
* | ||
* @returns {boolean} | ||
*/ | ||
exports.const = function () { | ||
try { | ||
eval('const a = 1') | ||
return true | ||
} catch (err) { | ||
return false | ||
} | ||
} |
{ | ||
"name": "feature-detect-es6", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Detect which ES6 features are available.", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/75lb/feature-detect-es6.git", |
@@ -11,6 +11,18 @@ [![view on npm](http://img.shields.io/npm/v/feature-detect-es6.svg)](https://www.npmjs.org/package/feature-detect-es6) | ||
**Example** | ||
```js | ||
var detect = require('feature-detect-es6') | ||
if (detect.class() && detect.arrowFunction()){ | ||
// safe to run ES6 code natively.. | ||
} else { | ||
// run your transpiled ES5.. | ||
} | ||
``` | ||
* [feature-detect-es6](#module_feature-detect-es6) | ||
* [.class()](#module_feature-detect-es6.class) ⇒ <code>boolean</code> | ||
* [.arrowFunction()](#module_feature-detect-es6.arrowFunction) ⇒ <code>boolean</code> | ||
* [.let()](#module_feature-detect-es6.let) ⇒ <code>boolean</code> | ||
* [.const()](#module_feature-detect-es6.const) ⇒ <code>boolean</code> | ||
@@ -27,5 +39,15 @@ <a name="module_feature-detect-es6.class"></a> | ||
**Kind**: static method of <code>[feature-detect-es6](#module_feature-detect-es6)</code> | ||
<a name="module_feature-detect-es6.let"></a> | ||
### detect.let() ⇒ <code>boolean</code> | ||
Returns true if the `let` statement is available. | ||
**Kind**: static method of <code>[feature-detect-es6](#module_feature-detect-es6)</code> | ||
<a name="module_feature-detect-es6.const"></a> | ||
### detect.const() ⇒ <code>boolean</code> | ||
Returns true if the `const` statement is available. | ||
**Kind**: static method of <code>[feature-detect-es6](#module_feature-detect-es6)</code> | ||
* * * | ||
© 2015 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown). |
@@ -8,1 +8,16 @@ var detect = require('../') | ||
}) | ||
test('.arrowFunction()', function (t) { | ||
t.strictEqual(detect.arrowFunction(), false) | ||
t.end() | ||
}) | ||
test('.let()', function (t) { | ||
t.strictEqual(detect.let(), false) | ||
t.end() | ||
}) | ||
test('.const()', function (t) { | ||
t.strictEqual(detect.const(), false) | ||
t.end() | ||
}) |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
7805
10
131
52
3