Chain State
@constructor
554527
function ChainState() {
  if (!(this instanceof ChainState))
    return new ChainState();

  this.startHeight = -1;
  this.startHash = encoding.NULL_HASH;
  this.height = -1;
  this.marked = false;
}
911655
function(state) {
            if (state == this.state) return;

            this.state = state;
            logging.log("state ", this.state);
            this.trigger("state", this.state);
        }
1107631
function initState() {
        var result = $.Deferred();
        updateJsonHandler.parse()
            .done(function() {
                result.resolve();
            })
            .fail(function (code) {
                var logMsg;
                switch (code) {
                case StateHandlerMessages.FILE_NOT_FOUND:
                    logMsg = "AutoUpdate : updateHelper.json cannot be parsed, does not exist";
                    break;
                case StateHandlerMessages.FILE_NOT_READ:
                    logMsg = "AutoUpdate : updateHelper.json could not be read";
                    break;
                case StateHandlerMessages.FILE_PARSE_EXCEPTION:
                    logMsg = "AutoUpdate : updateHelper.json could not be parsed, exception encountered";
                    break;
                case StateHandlerMessages.FILE_READ_FAIL:
                    logMsg = "AutoUpdate : updateHelper.json could not be parsed";
                    break;
                }
                console.log(logMsg);
                result.reject();
            });
        return result.promise();
    }
1023969
function State(state) {
    if ( state === void 0 ) state = {};

    Object.defineProperty(this, "_", {
        value: new Subscriber()
    });
    this.update(state);
}
61915
function iterator(state, tasks, callback)
{
  var keys
    , tasksLeft = tasks.length
    , task      = tasks.shift()
    ;

  if (tasksLeft === 0)
  {
    return callback(null, state);
  }

  // init current task reference
  state._currentTask = {waiters: {}};

  if (typeOf(task) == 'object')
  {
    // update state with new options
    // to make it available for all the subcommands
    if (typeOf(task.options) == 'object')
    {
      state.options = extend(state.options || {}, task.options);

      // no need to process it further
      delete task.options;
    }

    // generate list of properties to update
    keys = Object.keys(task);
  }

  // convert non-array and non-object elements
  // into single element arrays
  if (typeof task != 'object')
  {
    task = [task];
  }

  execute(state, task, keys, function(err, modifiedState)
  {
    // reset current task
    // if it's error and modified state
    // isn't provided, use context
    (modifiedState || state)._currentTask = undefined; // eslint-disable-line no-undefined

    if (err) return callback(err);

    // proceed to the next element
    iterator(modifiedState, tasks, callback);
  });
}
1295653
function chain() {
	let arg = Array.from(arguments),
		pipe = arg.length > 0 ? arg.shift() : stream => stream;

	return function() {
		let writer = through.obj();

		return duplexer(
			{objectMode: true},
			writer,
			pipe.apply(null, [writer].concat(merge(arguments, arg)))
		);
	};
}
932294
function() {
        if (!this.transitions) return

        var leaveState, event, transitions = this.transitions
        for (leaveState in transitions)
          for (event in transitions[leaveState])
            this.transition(leaveState, event, transitions[leaveState][event])

        if (!(transitions.hasOwnProperty(INIT_STATE)
          || transitions.hasOwnProperty(ANY_STATE)) && typeof console !== 'undefined')
          console.warn('there is no transition from state "init" to another state.')
      }
1023838
function createChainedFunction(one, two) {
    return function chainedFunction() {
      one.apply(this, arguments);
      two.apply(this, arguments);
    };
  }
427018
function __chain_inner(result) {
		var args = slice.call(arguments, 1);
		nextTick(function() {
			try {
				if (result) {
					var params = that.handle_args(env, that.if_true, args);
					params.unshift(env, after);
					env._fm.$push_call(helpers.fname(that.if_true, that.if_true.fn.name));
					that.if_true.fn.apply(null, params);
				}
				else {
					var params = that.handle_args(env, that.if_false, args);
					params.unshift(env, after);
					env._fm.$push_call(helpers.fname(that.if_false, that.if_false.fn.name));
					that.if_false.fn.apply(null, params);
				}
			}
			catch (e) {
				env.$throw(e);
			}
		});
	}
997475
function( required, startFunc ) {
		var self = this;

		if ( required !== self.state ) {
			self._stateError( startFunc || self.requireState );
		}

		return self;
	}
788235
function(state)
  {
    console.log('# Started batch process\n');
    console.log('## Initial State:\n');
    console.log('```');
    console.log(JSON.stringify(sortKeys(state), null, 2));
    console.log('```');
    console.log('\n## Execution\n');
  }
258591
function(name) {
    name = name || '';

    var state = null;

    // Only use valid state queries
    if(!_validateStateName(name)) {
      return null;
    
    // Use cache if exists
    } else if(_stateCache[name]) {
      return _stateCache[name];
    }

    var nameChain = _getNameChain(name);
    var stateChain = nameChain
      .map(function(name, i) {
        var item = angular.copy(_stateLibrary[name]);
        return item;
      })
      .filter(function(parent) {
        return !!parent;
      });

    // Walk up checking inheritance
    for(var i=stateChain.length-1; i>=0; i--) {
      if(stateChain[i]) {
        var nextState = stateChain[i];
        state = angular.merge(nextState, state || {});
      }

      if(state && state.inherit === false) break;
    }

    // Store in cache
    _stateCache[name] = state;

    return state;
  }
1368702
function() {
  if (! (this instanceof Chain)) {
    return new Chain();
  }

  this.validators = [];
  this.target = null;
  this.isOptional = false;
  this.isImmutable = false;
  this.isUpdateRequired = false;
  this._validatorCount = 0;
  this._numItemsValidator = null;
}
922247
function resetState(node) {
    _.each(node._tree.defaultState, (val, prop) => {
        node.state(prop, val);
    });

    return node;
}
246647
def init_chain(self):
        
        if not self._hasinit:
            self._hasinit = True
            self._devices = []

            self.jtag_enable()
            while True:
                # pylint: disable=no-member
                idcode = self.rw_dr(bitcount=32, read=True,
                                    lastbit=False)()
                if idcode in NULL_ID_CODES: break
                dev = self.initialize_device_from_id(self, idcode)
                if self._debug:
                    print(dev)
                self._devices.append(dev)
                if len(self._devices) >= 128:
                    raise JTAGTooManyDevicesError("This is an arbitrary "
                        "limit to deal with breaking infinite loops. If "
                        "you have more devices, please open a bug")

            self.jtag_disable()

            #The chain comes out last first. Reverse it to get order.
            self._devices.reverse()
1022693
function(state, data){
      var stateCode = String(state);
      var oldState = this.childNodesState;

      if (!STATE.values[stateCode])
        throw new Error('Wrong state value');

      // set new state for object
      if (oldState != stateCode || oldState.data != data)
      {
        this.childNodesState = Object(stateCode);
        this.childNodesState.data = data;

        this.emit_childNodesStateChanged(oldState);
      }
    }
212244
function transition() {
    var ts = this.__transitions__, i, len;

    if (!ts || ts.length === 0) { return; }

    for (i = 0, len = ts.length; i < len; i++) {
      enter.call(ts[i].pivot, ts[i].states, ts[i].opts);
    }

    this.__transitions__ = [];
  }