File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -101,15 +101,11 @@ Promise.nodeify = function (fn) {
101
101
}
102
102
}
103
103
104
- Promise . all = function ( ) {
105
- var calledWithArray = arguments . length === 1 && Array . isArray ( arguments [ 0 ] )
106
- var args = Array . prototype . slice . call ( calledWithArray ? arguments [ 0 ] : arguments )
107
-
108
- if ( ! calledWithArray ) {
109
- var err = new Error ( 'Promise.all should be called with a single array, calling it with multiple arguments is deprecated' )
110
- err . name = 'Warning'
111
- console . warn ( err . stack )
112
- }
104
+ Promise . all = function ( arr ) {
105
+ if ( arguments . length !== 1 || ! Array . isArray ( arr ) )
106
+ return variadicAll . apply ( this , arguments )
107
+
108
+ var args = Array . prototype . slice . call ( arr )
113
109
114
110
return new Promise ( function ( resolve , reject ) {
115
111
if ( args . length === 0 ) return resolve ( [ ] )
@@ -137,6 +133,14 @@ Promise.all = function () {
137
133
} )
138
134
}
139
135
136
+ function variadicAll ( ) {
137
+ var err = new Error ( 'Promise.all should be called with a single array, calling it with multiple arguments is deprecated' )
138
+ err . name = 'Warning'
139
+ console . warn ( err . stack )
140
+
141
+ return Promise . all ( Array . prototype . slice . call ( arguments ) )
142
+ }
143
+
140
144
Promise . reject = function ( value ) {
141
145
return new Promise ( function ( resolve , reject ) {
142
146
reject ( value ) ;
You can’t perform that action at this time.
0 commit comments