jashkenas / jashkenas/underscore

add _.oneArg (and maybe _.twoArgs and _.limitArgs)

Open
#2,871 2 comments 0 reactions 0 assignees View on GitHub
contrib enhancement
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.