jashkenas / jashkenas/underscore
add _.oneArg (and maybe _.twoArgs and _.limitArgs)
- Dominant language
- JavaScript
- Stars
- 27.3k
- Forks
- 5.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 1
Description
I suggest adding a new function called oneArg to underscore. It wraps a function and allows it to be called with one argument only and ignores rest of the arguments.
Implementation:
`const oneArg = fn => arg => fn(arg);`
usage:
Before oneArg:
` ['34','11','19','199','201'].map(parseInt);
// returns [34, NaN, 1, 1, 33]`
After oneArg:
`const safeParseInt = oneArg(parseInt);
['34','11','19','199','201'].map(safeParseInt)
// returns [34, 11, 19, 199, 201]`
Contributor guide
Research direction
The issue names no file or test, so first locate Underscore's public function definitions and its tests for API additions. Confirm the proposed oneArg behavior with the parseInt mapping example, and clarify whether twoArgs and limitArgs are in scope before considering the work complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100