Skip to content

Instantly share code, notes, and snippets.

@ruxandrafed
Forked from adatta02/partial.js
Created March 29, 2018 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruxandrafed/4bd3ec6bdfca7d55fa99053337981c12 to your computer and use it in GitHub Desktop.
Save ruxandrafed/4bd3ec6bdfca7d55fa99053337981c12 to your computer and use it in GitHub Desktop.
function partial(fn /*, rest args */){
const newArgs = Array.apply(null, arguments).slice(1);
return function(){
const fnArgs = newArgs.concat(Array.apply(null, arguments));
fn.apply(null, fnArgs);
}
}
const Logger = {
log(level, dateFormat, msg) {
console.log(level, dateFormat, msg);
}
};
const info = partial(Logger.log, "info", "ISO8601");
info("Application started");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment