From 364bf1d183337f26aac71be0849744e21a2d6236 Mon Sep 17 00:00:00 2001 From: "hemanth.hm" Date: Thu, 30 Oct 2014 18:10:16 +0530 Subject: [PATCH 1/2] Should detect const. --- index.js | 9 +++++++++ test/enable.test.js | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/index.js b/index.js index 6d968c6..01d5a94 100644 --- a/index.js +++ b/index.js @@ -32,3 +32,12 @@ try { } catch (_) { exports.let = false; } + +// const +try { + eval('(function () { const fubar = 42; return typeof fubar === "number"; }())'); + exports.const = true; +} catch (_) { + exports.const = false; +} + diff --git a/test/enable.test.js b/test/enable.test.js index be86d14..b4f3c1b 100644 --- a/test/enable.test.js +++ b/test/enable.test.js @@ -32,4 +32,11 @@ describe('enable.test.js', function () { enable.let.should.equal(true); } }); + + it("should detect const", function() { + enable.const.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.const.should.equal(true); + } + }); }); From 8e2f3dac1e87483f22866eb55546aa0869832a73 Mon Sep 17 00:00:00 2001 From: "hemanth.hm" Date: Thu, 30 Oct 2014 18:17:53 +0530 Subject: [PATCH 2/2] Updated readme. --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eb0624b..424c0ef 100644 --- a/README.md +++ b/README.md @@ -38,11 +38,15 @@ $ npm install enable --save var enable = require('enable'); if (enable.generator) { - console.log('support generator'); + console.log('supports generator'); } if (enable.let) { - console.log('support let a = 1;'); + console.log('supports `let a = 1;`'); +} + +if (enable.const) { + console.log('supports `const salary = 0;`') } ```