caolan / caolan/highland

wrapCallback is uncurryable

Open
#296 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.4k
Forks
145
PR merge metrics
No merged PRs in 30d

Description

```
var foo = _.wrapCallback(function (thing, done){
done(null, thing);
});

foo('bar').apply(_.log); // bar

_.curry(foo)('bar').apply(_.log);
// ^
// TypeError: object is not a function
```

The issue is that wrapCallback handles its arguments dynamically. I'm not sure there's any way around it, but I wanted to raise it for discussion as it would be a useful thing to be able to do. I suppose _.partial could be used instead, but that's less elegant.

```
// _.wrapCallback
function () {
var self = this;
var args = slice.call(arguments);
return _(function (push) {
var cb = function (err, x) {
if (err) {
push(err);
}
else {
push(null, x);
}
push(null, nil);
};
f.apply(self, args.concat([cb]));
});
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.