Checking for Set isn't browser dependant

This commit is contained in:
Gregg Van Hove
2016-09-27 16:11:43 -07:00
parent bad9c63bf7
commit 5279e7a8c4
4 changed files with 23 additions and 19 deletions

View File

@@ -0,0 +1,21 @@
(function(env) {
function hasFunctioningSets() {
if (typeof Set === 'undefined') { return false; }
try {
var s = new Set([4]);
if (s.size !== 1) { return false; }
if (s.values().next().value !== 4) { return false; }
return true;
} catch(e) {
return false;
}
}
env.requireFunctioningSets = function() {
if (!hasFunctioningSets()) {
pending("Browser has incomplete or missing support for Sets");
}
};
})(jasmine.getEnv());