jashkenas / jashkenas/underscore
_.bind supports _.partial application, but not its non pre-filled argument syntax with _
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 27.3k
- Forks
- 5.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 1
Description
I don't know if this is intended behavior, but it seems all around confusing if so. My guess is this portion of _.bind was just left untouched when _.partial received this functionality. Here's the simplified reproduction of it in jsfiddle: http://jsfiddle.net/j3jpL4eb/1/
``` javascript
var foo = function(bar) {
console.log(bar); //this should always print 'bar' if non pre-filled arguments applied to bind's partial application as well, yet it has the value of underscore when not double wrapped
}
_.bind(foo, this, _)('bar'); //function (n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)}
_.bind(_.partial(foo, _), this)('bar'); //bar
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the JavaScript reproduction from the issue and compare _.bind(foo, this, _)('bar') with the _.partial-wrapped example. Inspect the _.bind and _.partial entry points to determine whether underscore placeholders should be handled consistently; done means the direct bind form passes 'bar' to foo like the wrapped form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100