lib/aigle.js
function mixin(sources, opts = {}) {
  const { override, promisify = true } = opts;
  Object.getOwnPropertyNames(sources).forEach(key => {
    const func = sources[key];
    if (typeof func !== 'function' || (Aigle[key] && !override)) {
      return;
    }
    // check lodash chain
    if (key === 'chain') {
      const obj = func();
      if (obj && obj.__chain__) {
        Aigle.chain = _resolve;
        Aigle.prototype.value = function() {
          return this;
        };
        return;
      }
    }
    const Proxy = createProxy(func, promisify);
    Aigle[key] = function(value, arg1, arg2, arg3) {
      return new Proxy(value, arg1, arg2, arg3)._execute();
    };
    Aigle.prototype[key] = function(arg1, arg2, arg3) {
      return addProxy(this, Proxy, arg1, arg2, arg3);
    };
  });
  return Aigle;
}
function mixin(sources, opts = {}) {
  const { override, promisify = true } = opts;
  Object.getOwnPropertyNames(sources).forEach(key => {
    const func = sources[key];
    if (typeof func !== 'function' || (Aigle[key] && !override)) {
      return;
    }
    // check lodash chain
    if (key === 'chain') {
      const obj = func();
      if (obj && obj.__chain__) {
        Aigle.chain = _resolve;
        Aigle.prototype.value = function() {
          return this;
        };
        return;
      }
    }
    const Proxy = createProxy(func, promisify);
    Aigle[key] = function(value, arg1, arg2, arg3) {
      return new Proxy(value, arg1, arg2, arg3)._execute();
    };
    Aigle.prototype[key] = function(arg1, arg2, arg3) {
      return addProxy(this, Proxy, arg1, arg2, arg3);
    };
  });
  return Aigle;
}
function mixin ( sources , opts = { } ) { const { override , promisify = true } = opts ; Object . getOwnPropertyNames ( sources ) . forEach ( key => { const func = sources [ key ] ; if ( typeof func !== 'function' || ( Aigle [ key ] && ! override ) ) { return ; } // check lodash chain if ( key === 'chain' ) { const obj = func ( ) ; if ( obj && obj . __chain__ ) { Aigle . chain = _resolve ; Aigle . prototype . value = function ( ) { return this ; } ; return ; } } const Proxy = createProxy ( func , promisify ) ; Aigle [ key ] = function ( value , arg1 , arg2 , arg3 ) { return new Proxy ( value , arg1 , arg2 , arg3 ) . _execute ( ) ; } ; Aigle . prototype [ key ] = function ( arg1 , arg2 , arg3 ) { return addProxy ( this , Proxy , arg1 , arg2 , arg3 ) ; } ; } ) ; return Aigle ; }
Add functions which sources has to the Aigle class functions and static functions.
The functions will be converted asynchronous functions.
If an extended function returns a promise instance, the function will wait until the promise is resolved.

@param {Object} sources
@param {Object} [opts]
@param {boolean} [opts.promisify=true]
@param {boolean} [opts.override=false]
@example
Aigle.mixin(require('lodash'));
const array = [1, 2, 3];
return Aigle.map(array, n => Aigle.delay(10, n * 2))
.sum()
.then(value => {
console.log(value; // 12
});

@example
Aigle.mixin(require('lodash'));
const array = [1.1, 1.4, 2.2];
return Aigle.map(array, n => Aigle.delay(10, n * 2))
.uniqBy(n => Aigle.delay(10, Math.floor(n))
.then(array => {
console.log(array; // [2.2, 4.4]
});
Add functions which sources has to the Aigle class functions and static functions . The functions will be converted asynchronous functions . If an extended function returns a promise instance the function will wait until the promise is resolved .