Skip to content

Commit 37c5205

Browse files
committed
Merge pull request #336 from jhnns/fix/node-args
Fix wrong order of applied arguments
2 parents f1975f6 + 59017b0 commit 37c5205

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ define(function(require) {
8484
}
8585

8686
function apply2(resolver, f, thisArg, args) {
87-
Promise._handler(args[0]).fold(function(y, x, resolver) {
87+
Promise._handler(args[0]).fold(function(x, y, resolver) {
8888
Promise._handler(x).fold(function(x, y, resolver) {
8989
f.call(this, x, y, createCallback(resolver));
9090
}, y, this, resolver);

test/node-test.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ buster.testCase('when/node', {
6969
cb(null, x + y);
7070
}
7171

72-
var promise = nodefn.apply(async, [10, 20]);
72+
var promise = nodefn.apply(async, ['a', 'b']);
7373
return promise.then(function(value) {
74-
assert.equals(value, 30);
74+
assert.equals(value, 'ab');
7575
});
7676
},
7777

@@ -80,9 +80,9 @@ buster.testCase('when/node', {
8080
cb(null, x + y);
8181
}
8282

83-
var promise = nodefn.apply(async, [when(10), 20]);
83+
var promise = nodefn.apply(async, [when('a'), 'b']);
8484
return promise.then(function(value) {
85-
assert.equals(value, 30);
85+
assert.equals(value, 'ab');
8686
});
8787
}
8888
},
@@ -139,9 +139,9 @@ buster.testCase('when/node', {
139139
cb(null, x + y);
140140
}
141141

142-
var promise = nodefn.call(async, 10, 20);
142+
var promise = nodefn.call(async, 'a', 'b');
143143
return promise.then(function(value) {
144-
assert.equals(value, 30);
144+
assert.equals(value, 'ab');
145145
});
146146
},
147147

@@ -150,9 +150,9 @@ buster.testCase('when/node', {
150150
cb(null, x + y);
151151
}
152152

153-
var promise = nodefn.call(async, when(10), 20);
153+
var promise = nodefn.call(async, when('a'), 'b');
154154
return promise.then(function(value) {
155-
assert.equals(value, 30);
155+
assert.equals(value, 'ab');
156156
});
157157
}
158158
},
@@ -219,26 +219,26 @@ buster.testCase('when/node', {
219219
},
220220

221221
'should accept leading arguments': function() {
222-
function fancySum(x, y, callback) {
222+
function async(x, y, callback) {
223223
callback(null, x + y);
224224
}
225225

226-
var partiallyApplied = nodefn.lift(fancySum, 5);
226+
var partiallyApplied = nodefn.lift(async, 'a');
227227

228-
return partiallyApplied(10).then(function(value) {
229-
assert.equals(value, 15);
228+
return partiallyApplied('b').then(function(value) {
229+
assert.equals(value, 'ab');
230230
}, fail);
231231
},
232232

233233
'should accept promises as leading arguments': function() {
234-
function fancySum(x, y, callback) {
234+
function async(x, y, callback) {
235235
callback(null, x + y);
236236
}
237237

238-
var partiallyApplied = nodefn.lift(fancySum, when(5));
238+
var partiallyApplied = nodefn.lift(async, when('a'));
239239

240-
return partiallyApplied(10).then(function(value) {
241-
assert.equals(value, 15);
240+
return partiallyApplied('b').then(function(value) {
241+
assert.equals(value, 'ab');
242242
});
243243
}
244244
},

0 commit comments

Comments
 (0)