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

It would be nice to have callBind (demethodify) #10

Open
kirilloid opened this issue Oct 31, 2013 · 1 comment
Open

It would be nice to have callBind (demethodify) #10

kirilloid opened this issue Oct 31, 2013 · 1 comment

Comments

@kirilloid
Copy link

Some built-in methods are rather useful, but they can be used only as methods and cannot be used as simple function with one argument for map etc.
Function.call.bind can help us, but this is a bit clumsy.
_.callBind = function (fn) { return fn.call.bind(fn); }

Also this could be useful for "uncurrying" 1 argument, like e.g.
someString.replace(/&#(\d+);/g, _.callBind(String.fromCharCode));

@DrBoolean
Copy link

Thanks kirilloid,

That's a great addition. I'll try to get that in today with some tests to match

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants