Inject idGenerator function for aggregate id that is command aware.
@param   {Function}  fn The function to be injected.
@returns {Aggregate}    to be able to chain...
542048
function (fn) {
    if (fn.length === 0) throw new Error('Please define your function to accept the command!');
    if (fn.length === 1) {
      var orgFn = fn;
      fn = function(cmd, callback) {
        callback(null, orgFn(cmd));
      };
    }

    this.getNewAggregateId = fn;

    return this;
  }
314429
function operationId(given, method, url, allKnown) {
  var id;
  var generate = given == null;
  if (generate) {
    id = toIdentifier(method + url);
  } else {
    id = toIdentifier(given);
  }
  var duplicated = allKnown.has(id);
  if (duplicated) {
    var i = 1;
    while (allKnown.has(id + '_' + i)) {
      i++;
    }
    id = id + '_' + i;
  }
  if (generate) {
    console.warn(
      "Operation '" +
        method +
        "' on '" +
        url +
        "' defines no operationId. Assuming '" +
        id +
        "'."
    );
  } else if (duplicated) {
    console.warn(
      "Operation '" +
        method +
        "' on '" +
        url +
        "' defines a duplicated operationId: " +
        given +
        '. ' +
        "Assuming '" +
        id +
        "'."
    );
  }
  allKnown.add(id);
  return id;
}
714301
static InterpretedFunction createScript(InterpreterData idata,
                                            Object staticSecurityDomain)
    {
        InterpretedFunction f;
        f = new InterpretedFunction(idata, staticSecurityDomain);
        return f;
    }
6951
def reduce(self, reduce_fn):
        
        op = Operator(
            _generate_uuid(),
            OpType.Reduce,
            "Sum",
            reduce_fn,
            num_instances=self.env.config.parallelism)
        return self.__register(op)
509098
function injectArguments (funcs, task, args) {
  function getArgument (index) {
    return args[index]
  }

  /**
   * Inject arguments.
   */

  function inject (taskKey) {
    var funcName = task[taskKey]

    if (funcName === 'arguments') {
      funcs[funcName] = function getArguments () { return args }
    } else {
      var arg = regexArgument.exec(funcName)

      if (arg) {
        funcs[funcName] = getArgument.bind(null, arg[1])
      }
    }
  }

  Object.keys(task)
    .forEach(inject)
}
700547
function(args, fn, type) {
    this.args = args;
    this.fn = fn;
    this.type = type;

    this.id = prefix + _code_node_id_count++;
}
1183748
function executeSerializedFunction(id, args) {
    SerializedFunctions.forEach(function(sf) {
        if (sf.id == id) {
            sf.func.apply(null, args);
        }
    });
}
375843
function wrapFn (gen) {
  if (!is.function(gen)) throw new Error('Middleware must be a function')
  if (!is.generator(gen)) return gen

  // wrap generator with raco
  var fn = raco.wrap(gen)
  return function (ctx, next) {
    fn.call(this, ctx, next)
  }
}
1065063
function fork(annotationObj) {
  const id = generateUUID();
  generation += 1;
  return Object.assign({}, annotationObj, { generation, id });
}
306989
public DifferentialFunction getFunctionById(@NonNull String id) {
        if (!ops.containsKey(id)) {
            throw new ND4JIllegalStateException("No function with id " + id + " found!");
        }
        return ops.get(id).getOp();
    }
1147749
function (cmd, callback) {
    debug('called a custom command handler');
    console.log('Is your use case not solvable without a custom command handling? Sagas? Micro-Services?');

    var self = this;

    function _handle (aggId) {
      var concatenatedId = self.getConcatenatedId(aggId, cmd);

      var isFirst = !self.getNextCommandInQueue(concatenatedId);

      self.queueCommand(concatenatedId, cmd, callback);

      if (!isFirst) {
        return;
      }

      (function handleNext (aggregateId, c) {
        var concId = self.getConcatenatedId(aggregateId, c);
        var cmdEntry = self.getNextCommandInQueue(concId);
        if (cmdEntry) {
          if (cmdEntry.callback.length > 2) {
            self.cmdHndlFn(aggregateId, cmdEntry.command, self, function (err, evts, aggData, meta) {
              self.removeCommandFromQueue(concId, cmdEntry.command);
              handleNext(aggregateId, cmdEntry.command);
              cmdEntry.callback(err, evts, aggData, meta);
            });
            return;
          }
          self.cmdHndlFn(aggregateId, cmdEntry.command, self, function (err, evts) {
            self.removeCommandFromQueue(concId, cmdEntry.command);
            handleNext(aggregateId, cmdEntry.command);
            cmdEntry.callback(err, evts);
          });
        }
      })(aggId, cmd);
    }

    if (dotty.exists(cmd, this.definitions.command.aggregateId)) {
      return _handle(dotty.get(cmd, this.definitions.command.aggregateId));
    }

    debug('no aggregateId in command, so generate a new one');

    this.getNewAggregateId(cmd, function (err, id) {
      if (err) {
        debug(err);
        return callback(err);
      }

      return _handle(id);
    });
  }
15138
function (cmd, callback) {
    var getNewIdFn = this.eventStore.getNewId.bind(this.eventStore);
    if (this.aggregate && this.aggregate.getNewAggregateId) {
      getNewIdFn = this.aggregate.getNewAggregateId.bind(this.aggregate);
    } else if (this.getNewAggregateIdFn) {
      getNewIdFn = this.getNewAggregateIdFn.bind(this);
    }

    if (getNewIdFn.length === 2) {
      return getNewIdFn(cmd, callback);
    }

    getNewIdFn(callback);
  }
1284131
function spawnIt(args, fn) {
  var gpg = spawn('gpg', globalArgs.concat(args || []) );
  gpg.on('error', fn);
  return gpg;
}
274184
function (fn, update, container) {
  // Alias passed in variables for later access.
  this._fn        = fn;
  this._update    = update;
  this._container = container;

  // Assign every subscription instance a unique id. This helps with linking
  // between parent and child subscription instances.
  this.cid             = 'c' + Utils.uniqueId();
  this.children        = {};
  this.subscriptions   = {};
  this.unsubscriptions = [];

  // Create statically bound function instances for public consumption.
  this.boundUpdate         = Utils.bind(this.update, this);
  this.boundUnsubscription = Utils.bind(this.unsubscription, this);
}
1250159
function bindHelper(fn) {
    return function() {
      var p = priv.get(this);
      return fn.apply(p.sequence, Array.prototype.slice.call(arguments));
    }
  }
804269
def call_fn(fn, arglist, env):
  """"""
  if isinstance(fn, framework.LazyFunction):
    # The following looks complicated, but this is necessary because you can't
    # construct closures over the loop variable directly.
    thunks = [(lambda thunk: lambda: framework.eval(thunk, env))(th) for th in arglist.values]
    return fn(*thunks)

  evaled_args = framework.eval(arglist, env)
  if isinstance(fn, framework.EnvironmentFunction):
    return fn(*evaled_args, env=env)

  return fn(*evaled_args)
609861
function(fn) {
      return function(key, value) {
        if (typeOf(key) == "object") {
          for (var i in key) {
            fn.call(this, i, key[i]);
          }
        } else {
          fn.call(this, key, value);
        }
        return this;
      };
    }