metarhia / metasync

Asynchronous Programming Library for JavaScript & Node.js
https://metarhia.com
MIT License
206 stars 35 forks source link

Doesn't assign an object context in do/chain #389

Closed machendos closed 5 years ago

machendos commented 5 years ago

The function chain in lib/do...

const chain = (fn, ...args) => {
}

...is written as lambda. So, call with chain.call doesn't actually assign an object context to it

Do.prototype.do = function(fn, ...args) {
  return chain.call(this, fn, ...args);
};

As result, only the last composed function will be called, since all the other won't be simply chained, because...

const prev = this instanceof Do ? this : null;

... always is null