JSFiddle - React, Tailwind, and code Playground
JavaScript
(function(){
// Lets add Curry method to Function so that we can call it on any function we want.
Function.prototype.curry = function(){
var fn = this, args = Array.prototype.slice.call(arguments);
return function(){
return fn.apply(this, args.concat(Array.prototype.slice.call(arguments)));
};
};
// Core method.
function showMessage(type, position, message){
console.log('showing [' + message + '] of type [' + type + '] at [' + position + '].' );
}
// Create special versions of Core method using Currying.
var showError = showMessage.curry('error', 'top');
var showInfo = showMessage.curry('info', 'bottom');
// Call our special methods.
showError('Not good.');
showInfo('You better know this.');
}());