orangeeli/patterns

View on GitHub
lib/promise/context.js

Summary

Maintainability
A
1 hr
Test Coverage
module.exports =
  (()=>{
    
    "use strict";

    return {
      currentStepIndex : 0,
      
      onComplete() {
        return this.runner.onComplete();
      },
      incrementStepCounter(){
        this.currentStepIndex++;
      },
      getCurrentStepCounter(){
        return this.currentStepIndex;
      },
      setContextData (data){
        this.data = data;
      },
      getContextData (){
        return this.data;
      },
      setRunner (runner){
        this.runner = runner;
      },

      clear (){
        this.setContextData (new Map());
      },

      chainInterruption (message){
        return this.runner.onInterrupt(message);
      }
      
    };
  })();