Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

feature-detect-es6

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feature-detect-es6 - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

.travis.yml

36

lib/feature-detect-es6.js

@@ -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
}
}

2

package.json
{
"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>
* * *
&copy; 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()
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc