JSFiddle - React, Tailwind, and code Playground
by kentaromiura
JavaScript
function ↂ(ƒ){
return function(){
ƒ.apply(this, arguments);
return this;
}
}
function compose(ƒ0, ƒ1){
console.log('f0', ƒ0());
console.log('f1', ƒ1());
return function(){ƒ0(ƒ1())};
}
var lastone = null;
function λ(expression, property){
var lambda = function(){return property ? expression[property] : expression};
lambda.toString = function(){
console.log('???' + this())
if(lastone !== null) {
console.log('eureka')
var tts = this.toString;
this.toString = this.constructor.toString;
var result = compose(lastone, this);
this.toString = tts;
lastone = null;
return result;
}else{
lastone = this;
return '';
}
}
return lambda
}
function Test(){ }
Test.prototype.first = ↂ(function(){
alert('one')
});
Test.prototype.second = ↂ(function(){
alert(λ({foo:'bar'},'foo')())
});
new Test().first().second();
var X = λ('one') + λ('two')
console.log('X', X);