Last active
February 14, 2024 01:55
-
-
Save dotproto/34e38e29d78b19c1ab96 to your computer and use it in GitHub Desktop.
Function application as a service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buildApply() { | |
var args = Array.prototype.slice.call(arguments, 0); | |
var fn = args.shift(); | |
// proxy function | |
return function bindProxy() { | |
var proxyArgs = Array.prototype.slice.call(arguments, 0); | |
return fn.apply(null, args.concat(proxyArgs)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use case is partial application in a scenario where your target function requires access to params it wouldn't otherwise have access to.