Skip to content

Commit

Permalink
[fix] Get rid of 'some' version of fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Keslin committed Apr 3, 2017
1 parent f636767 commit b0ba0e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
18 changes: 5 additions & 13 deletions index.js
Expand Up @@ -321,19 +321,11 @@ Assert.add('eitherOfType, oneOfType', function multitypecheck(ofs, msg) {
var value = type(this.value)
, expect = format('`%j` (%s) to @ be a %s', this.value, value, ofs.join(' or a '));

var test;
if (typeof ofs.some === 'function') {
test = ofs.some(function(of) {
of = of.toString().toLowerCase();
return of === value;
});
} else {
test = false;
for (var i = 0; i < ofs.length; i++) {
if (ofs[i].toString().toLowerCase() === value) {
test = true;
break;
}
var test = false;
for (var i = 0; i < ofs.length; i++) {
if (ofs[i].toString().toLowerCase() === value) {
test = true;
break;
}
}

Expand Down
12 changes: 0 additions & 12 deletions test/test.js
Expand Up @@ -255,18 +255,6 @@ describe('Assertions', function assertions() {
try { assume({}).to.not.be.eitherOfType(['string', 'object']); }
catch (e) { next(); }
});

it('works without `Array.prototype.some`', function (next) {
var foo = ['string', 'object'];

// Override foo.some so we fallback to linear search
foo.some = null;

assume({}).to.be.eitherOfType(foo);

try { assume(1).to.be.eitherOfType(foo); }
catch (e) { next(); }
});
});

describe('#instanceof', function () {
Expand Down

0 comments on commit b0ba0e0

Please sign in to comment.