Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider support partial function application #92

Closed
dschenkelman opened this issue Oct 9, 2014 · 6 comments
Closed

Consider support partial function application #92

dschenkelman opened this issue Oct 9, 2014 · 6 comments
Assignees
Labels
feature New functionality or improvement

Comments

@dschenkelman
Copy link

What do you think about including a function to allow partial application of arguments?
I think it could be a useful addition and can PR it if you would like to.

Example use case: currently I'm working on a plug-in where I need pass parameters when using async.series:

async.series([
      f1,
      f2,
      f3],
      callback);

I'd like to do something like the following without having to include lodash or underscore:

async.series([
      Hoek.apply(f1, request),
      Hoek.apply(f2, request),
      Hoek.apply(f3, request)],
      callback);

Thoughts?

@dschenkelman
Copy link
Author

Just to clarify, nothing too complex just:

function partial(f){
  var args = Array.prototype.slice.call(arguments, 1);

  return function(){
    return f.apply(null, args.concat(Array.prototype.slice.call(arguments)));
  };
}

@nlf nlf self-assigned this Oct 20, 2014
@nlf
Copy link
Member

nlf commented Oct 20, 2014

Per the reasons described in #98 (this is not a general purpose module) I'm going to decline on this one.

@nlf nlf closed this as completed Oct 20, 2014
@dschenkelman
Copy link
Author

I see, didn't know about that. Thanks for clarifying!

@arb
Copy link
Contributor

arb commented Oct 20, 2014

@dschenkelman couldn't you achieve that with either bind or async.apply?

@dschenkelman
Copy link
Author

@arb +1 for bind. We ended up getting rid of async to use items, but bind would work :)

@Marsup Marsup added feature New functionality or improvement and removed request labels Sep 21, 2019
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

5 participants