lundi 21 septembre 2015

passing a returned value to another function, javascript

Given the following piece of code:

 function Foo() {};
 Foo.prototype.one = fluent(function(a , b) {
    return a + b;
 });
 Foo.prototype.two = fluent(function(c) {
    var d = c + 0.15; //0.15 cause I just couldnt thougth anything else at this moment...
    return d;
 });

ok that's all good for the moment, now let's say fluent is a decorator function that allows me to implement it like this:

var test = new Foo();
test.one(10, 5).two(); //here is the problem...

Thinking as it was a promise, how can I modify this code in order to make the returned valued of one available on two??? meaning, c should be the returned valued of one(), while keeping the sample implementation.

Here is the fiddle;

Aucun commentaire:

Enregistrer un commentaire