es-abstract
Advanced tools
Comparing version
@@ -0,1 +1,7 @@ | ||
1.3.2 / 2015-09-26 | ||
================= | ||
* [Fix] Fix `ES6.IsRegExp` to properly handle `Symbol.match`, per spec. | ||
* [Tests] up to `io.js` `v3.3`, `node` `v4.1` | ||
* [Dev Deps] update `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver` | ||
1.3.1 / 2015-08-15 | ||
@@ -2,0 +8,0 @@ ================= |
15
es6.js
@@ -24,2 +24,4 @@ 'use strict'; | ||
var hasRegExpMatcher = require('is-regex'); | ||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-abstract-operations | ||
@@ -180,5 +182,14 @@ var ES6 = assign(assign({}, ES5), { | ||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isregexp | ||
// http://www.ecma-international.org/ecma-262/6.0/#sec-isregexp | ||
IsRegExp: function IsRegExp(argument) { | ||
return toStr.call(argument) === '[object RegExp]'; | ||
if (!argument || typeof argument !== 'object') { | ||
return false; | ||
} | ||
if (hasSymbols) { | ||
var isRegExp = RegExp[Symbol.match]; | ||
if (typeof isRegExp !== 'undefined') { | ||
return ES5.ToBoolean(isRegExp); | ||
} | ||
} | ||
return hasRegExpMatcher(argument); | ||
}, | ||
@@ -185,0 +196,0 @@ |
{ | ||
"name": "es-abstract", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"author": "Jordan Harband", | ||
@@ -36,15 +36,16 @@ "description": "ECMAScript spec abstract operations.", | ||
"is-callable": "^1.0.4", | ||
"es-to-primitive": "^1.0.0" | ||
"es-to-primitive": "^1.0.0", | ||
"is-regex": "^1.0.3" | ||
}, | ||
"devDependencies": { | ||
"tape": "^4.1.0", | ||
"tape": "^4.2.0", | ||
"covert": "^1.1.0", | ||
"jscs": "^2.1.0", | ||
"jscs": "^2.1.1", | ||
"editorconfig-tools": "^0.1.1", | ||
"nsp": "^1.0.3", | ||
"eslint": "^1.1.0", | ||
"@ljharb/eslint-config": "^1.0.4", | ||
"nsp": "^1.1.0", | ||
"eslint": "^1.5.0", | ||
"@ljharb/eslint-config": "^1.2.0", | ||
"object-is": "^1.0.1", | ||
"foreach": "^2.0.5", | ||
"semver": "^5.0.1", | ||
"semver": "^5.0.3", | ||
"replace": "^0.3.0" | ||
@@ -51,0 +52,0 @@ }, |
@@ -331,2 +331,13 @@ 'use strict'; | ||
}); | ||
t.test('Symbol.match', { skip: !hasSymbols || !Symbol.match }, function (st) { | ||
var obj = {}; | ||
obj[Symbol.match] = true; | ||
st.equal(true, ES.IsRegExp(obj), 'object with truthy Symbol.match is regex'); | ||
var regex = /a/; | ||
regex[Symbol.match] = false; | ||
st.equal(false, ES.IsRegExp(regex), 'regex with falsy Symbol.match is not regex'); | ||
st.end(); | ||
}); | ||
t.end(); | ||
@@ -333,0 +344,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
71721
1.52%1286
1.5%4
33.33%+ Added