Skip to content

Commit

Permalink
[Fix] ensure that zloirock/core-js#144 doesn't cause false positives.
Browse files Browse the repository at this point in the history
Also add `npm run test:corejs`.

Relates to #4.
  • Loading branch information
ljharb committed Dec 15, 2015
1 parent 815dfbe commit 61c73ca
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
21 changes: 19 additions & 2 deletions getCollectionsForEach.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
module.exports = function () {
var mapForEach = typeof Map === 'function' ? Map.prototype.forEach : null;
var setForEach = typeof Set === 'function' ? Set.prototype.forEach : null;
var mapForEach = (function () {
if (typeof Map !== 'function') { return null; }
try {
Map.prototype.forEach.call({}, function () {});
} catch (e) {
return Map.prototype.forEach;
}
return null;
}());

var setForEach = (function () {
if (typeof Set !== 'function') { return null; }
try {
Set.prototype.forEach.call({}, function () {});
} catch (e) {
return Set.prototype.forEach;
}
return null;
}());

return { Map: mapForEach, Set: setForEach };
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"main": "index.js",
"scripts": {
"test": "npm run lint && npm run tests-only && npm run security",
"tests-only": "npm run test:native && npm run test:shimmed",
"tests-only": "npm run test:native && npm run test:shimmed && npm run test:corejs",
"test:native": "node test/native.js",
"test:shimmed": "node test/shimmed.js",
"test:corejs": "node test/corejs.js",
"coverage": "covert test/native.js",
"coverage-quiet": "covert test/native.js --quiet",
"lint": "npm run jscs && npm run eslint",
Expand Down Expand Up @@ -58,7 +59,8 @@
"@ljharb/eslint-config": "^1.6.0",
"nsp": "^2.1.0",
"replace": "^0.3.0",
"es6-shim": "^0.33.13"
"es6-shim": "^0.33.13",
"core-js": "^1.2.6"
},
"testling": {
"files": "test/native.js",
Expand Down
5 changes: 5 additions & 0 deletions test/corejs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

require('core-js');

require('./native');

0 comments on commit 61c73ca

Please sign in to comment.