Skip to content

Commit

Permalink
Fix bug in isArray empty
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorhakes committed Jun 15, 2019
1 parent e826101 commit 03f6f9a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "promise-polyfill",
"version": "8.1.1",
"version": "8.1.2",
"description": "Lightweight promise polyfill. A+ compliant",
"main": "lib/index.js",
"module": "src/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import promiseFinally from './finally';
var setTimeoutFunc = setTimeout;

function isArray(x) {
return Boolean(x && x.length);
return Boolean(x && typeof x.length !== 'undefined');
}

function noop() {}
Expand Down
16 changes: 15 additions & 1 deletion test/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ describe('Promise', function() {
}
);
});
it('throws on multiple promises', function() {
it('works on multiple resolved promises', function() {
return Promise.all([Promise.resolve(), Promise.resolve()]).then(
function() {
assert.ok(true);
Expand All @@ -383,6 +383,16 @@ describe('Promise', function() {
}
);
});
it('works on empty array', function() {
return Promise.all([]).then(
function(arr) {
assert.ok(arr.length === 0);
},
function() {
assert.fail();
}
);
});
});
describe('Promise.race', function() {
it('throws on implicit undefined', function() {
Expand Down Expand Up @@ -499,5 +509,9 @@ describe('Promise', function() {
}
);
});
it('works on empty array', function() {
var prom = Promise.race([]);
return assert(prom instanceof Promise);
});
});
});

0 comments on commit 03f6f9a

Please sign in to comment.