Skip to content

Commit 03f6f9a

Browse files
committed
Fix bug in isArray empty
1 parent e826101 commit 03f6f9a

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "promise-polyfill",
3-
"version": "8.1.1",
3+
"version": "8.1.2",
44
"description": "Lightweight promise polyfill. A+ compliant",
55
"main": "lib/index.js",
66
"module": "src/index.js",

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import promiseFinally from './finally';
55
var setTimeoutFunc = setTimeout;
66

77
function isArray(x) {
8-
return Boolean(x && x.length);
8+
return Boolean(x && typeof x.length !== 'undefined');
99
}
1010

1111
function noop() {}

test/promise.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ describe('Promise', function() {
373373
}
374374
);
375375
});
376-
it('throws on multiple promises', function() {
376+
it('works on multiple resolved promises', function() {
377377
return Promise.all([Promise.resolve(), Promise.resolve()]).then(
378378
function() {
379379
assert.ok(true);
@@ -383,6 +383,16 @@ describe('Promise', function() {
383383
}
384384
);
385385
});
386+
it('works on empty array', function() {
387+
return Promise.all([]).then(
388+
function(arr) {
389+
assert.ok(arr.length === 0);
390+
},
391+
function() {
392+
assert.fail();
393+
}
394+
);
395+
});
386396
});
387397
describe('Promise.race', function() {
388398
it('throws on implicit undefined', function() {
@@ -499,5 +509,9 @@ describe('Promise', function() {
499509
}
500510
);
501511
});
512+
it('works on empty array', function() {
513+
var prom = Promise.race([]);
514+
return assert(prom instanceof Promise);
515+
});
502516
});
503517
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy