flw.js
function _checkContext(c) {
    if (c.hasOwnProperty('_stopped')) return; // Already done?

    c._stopped = null;

    // Indicate that we gracefully stop
    //  if set, stops the flow until we are back to the main callback
    function _flw_stop(reason, cb) {
      if (!cb && typeof reason === 'function') {
        cb = reason;
        reason = 'stopped';
      }
      c._stopped = reason;
      return cb();
    }
    Object.defineProperty(c, '_stop', {
      enumerable: false,
      configurable: false,
      writable: false,
      value: _flw_stop,
    });

    // Stores the data returned from the callback in the context with key 'key'
    //  then calls the callback
    function _flw_store(key, cb) {
      const self = this;

      const fn = function (err, data) {
        if (err) return cb(err);

        self[key] = data;
        return cb();
      };
      return fn;
    }
    Object.defineProperty(c, '_store', {
      enumerable: false,
      configurable: false,
      value: _flw_store,
    });

    // Cleans all flw related properties from the context object
    function _flw_clean() {
      const self = this;
      const contextCopy = {};
      Object.keys(this).forEach(function (k) {
        if (ourContextKeys.indexOf(k) !== -1) return;
        contextCopy[k] = self[k];
      });
      return contextCopy;
    }
    Object.defineProperty(c, '_clean', {
      enumerable: false,
      configurable: false,
      value: _flw_clean,
    });

    // compatibilty for a while
    Object.defineProperty(c, '_flw_store', {
      enumerable: false,
      configurable: false,
      writable: false,
      value: _flw_store,
    });

    return c;
  }
function _checkContext(c) {
    if (c.hasOwnProperty('_stopped')) return; // Already done?

    c._stopped = null;

    // Indicate that we gracefully stop
    //  if set, stops the flow until we are back to the main callback
    function _flw_stop(reason, cb) {
      if (!cb && typeof reason === 'function') {
        cb = reason;
        reason = 'stopped';
      }
      c._stopped = reason;
      return cb();
    }
    Object.defineProperty(c, '_stop', {
      enumerable: false,
      configurable: false,
      writable: false,
      value: _flw_stop,
    });

    // Stores the data returned from the callback in the context with key 'key'
    //  then calls the callback
    function _flw_store(key, cb) {
      const self = this;

      const fn = function (err, data) {
        if (err) return cb(err);

        self[key] = data;
        return cb();
      };
      return fn;
    }
    Object.defineProperty(c, '_store', {
      enumerable: false,
      configurable: false,
      value: _flw_store,
    });

    // Cleans all flw related properties from the context object
    function _flw_clean() {
      const self = this;
      const contextCopy = {};
      Object.keys(this).forEach(function (k) {
        if (ourContextKeys.indexOf(k) !== -1) return;
        contextCopy[k] = self[k];
      });
      return contextCopy;
    }
    Object.defineProperty(c, '_clean', {
      enumerable: false,
      configurable: false,
      value: _flw_clean,
    });

    // compatibilty for a while
    Object.defineProperty(c, '_flw_store', {
      enumerable: false,
      configurable: false,
      writable: false,
      value: _flw_store,
    });

    return c;
  }
function _checkContext ( c ) { if ( c . hasOwnProperty ( '_stopped' ) ) return ; // Already done? c . _stopped = null ; // Indicate that we gracefully stop //  if set, stops the flow until we are back to the main callback function _flw_stop ( reason , cb ) { if ( ! cb && typeof reason === 'function' ) { cb = reason ; reason = 'stopped' ; } c . _stopped = reason ; return cb ( ) ; } Object . defineProperty ( c , '_stop' , { enumerable : false , configurable : false , writable : false , value : _flw_stop , } ) ; // Stores the data returned from the callback in the context with key 'key' //  then calls the callback function _flw_store ( key , cb ) { const self = this ; const fn = function ( err , data ) { if ( err ) return cb ( err ) ; self [ key ] = data ; return cb ( ) ; } ; return fn ; } Object . defineProperty ( c , '_store' , { enumerable : false , configurable : false , value : _flw_store , } ) ; // Cleans all flw related properties from the context object function _flw_clean ( ) { const self = this ; const contextCopy = { } ; Object . keys ( this ) . forEach ( function ( k ) { if ( ourContextKeys . indexOf ( k ) !== - 1 ) return ; contextCopy [ k ] = self [ k ] ; } ) ; return contextCopy ; } Object . defineProperty ( c , '_clean' , { enumerable : false , configurable : false , value : _flw_clean , } ) ; // compatibilty for a while Object . defineProperty ( c , '_flw_store' , { enumerable : false , configurable : false , writable : false , value : _flw_store , } ) ; return c ; }
Ensures a enrichched flw context when a flow is starting
@private
Ensures a enrichched flw context when a flow is starting