当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.drop函数代码示例

本文整理汇总了TypeScript中lodash.drop函数的典型用法代码示例。如果您正苦于以下问题:TypeScript drop函数的具体用法?TypeScript drop怎么用?TypeScript drop使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了drop函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: execute

  /**
   * Locate and execute a command given an array of positional command
   * arguments (argv) and a set of environment variables.
   *
   * If a command is not found, formatted help is automatically output for the
   * right-most namespace found.
   *
   * @param argv Command arguments sliced to the root for the namespace of this
   *             executor. Usually, this means `process.argv.slice(2)`.
   * @param env Environment variables for this execution.
   */
  async execute(argv: readonly string[], env: NodeJS.ProcessEnv): Promise<void> {
    if (argv[0] === EXECUTOR_OPS.RPC) {
      return this.rpc();
    }

    const parsedArgs = stripOptions(argv, { includeSeparated: false });
    const location = await this.namespace.locate(parsedArgs);

    if (argv.find(arg => arg === '--help' || arg === '-?') || isNamespace(location.obj)) {
      const cmdoptions = parseArgs([...argv]);
      this.stdout.write(await this.formatHelp(location, { format: cmdoptions['json'] ? 'json' : 'terminal' }));
    } else {
      const cmd = location.obj;
      const cmdargs = lodash.drop(argv, location.path.length - 1);

      try {
        await this.run(cmd, cmdargs, { location, env, executor: this });
      } catch (e) {
        if (e instanceof BaseError) {
          this.stderr.write(`Error: ${e.message}`);
          process.exitCode = typeof e.exitCode === 'undefined' ? 1 : e.exitCode;
          return;
        }

        throw e;
      }
    }
  }
开发者ID:driftyco,项目名称:ionic-cli,代码行数:39,代码来源:executor.ts

示例2:

    return _.map(timestampeds, (values, outcome: string) => {
      let result: T | undefined;
      const beforeBucket = _.takeWhile(values, (pl) => pl.timestamp <= bucket.timestamp);
      if (beforeBucket.length > 0) {
        _.drop(values, beforeBucket.length);
        result = _.last(beforeBucket);
      }

      if (!result) result = Object.assign({ outcome }, defaultValue);
      result.timestamp = bucket.timestamp;

      return result;
    });
开发者ID:AugurProject,项目名称:augur_node,代码行数:13,代码来源:get-profit-loss.ts

示例3: List

 return new List(function* () {
   let n = xs0.length;
   let xs = xs0;
   let prevHd = new Array<A>();
   while (n >= k) {
     const hd = _.take(xs, k);
     const tl = _.drop(xs, k);
     yield prevHd.concat(tl);
     n = n - k;
     xs = tl;
     prevHd = prevHd.concat(hd);
   }
 });
开发者ID:srijs,项目名称:node-arbitrator,代码行数:13,代码来源:shrink.ts

示例4: Set

export const sortTableData = (
  data: string[][],
  sort: SortOptions
): {sortedData: string[][]; sortedTimeVals: string[]} => {
  const headerSet = new Set(data[0])

  let sortIndex = 0

  if (headerSet.has(sort.field)) {
    sortIndex = _.indexOf(data[0], sort.field)
  }

  const dataValues = _.drop(data, 1)
  const sortedData = [
    data[0],
    ..._.orderBy<string[][]>(dataValues, sortIndex, [sort.direction]),
  ] as string[][]

  const sortedTimeVals = fastMap<string[], string>(
    sortedData,
    (r: string[]): string => r[sortIndex]
  )
  return {sortedData, sortedTimeVals}
}
开发者ID:viccom,项目名称:influxdb,代码行数:24,代码来源:tableGraph.ts

示例5:

 return _.map(array, (val, i) => _.drop(array, i).concat(_.take(array, i)));
开发者ID:tessenate,项目名称:polyhedra-viewer,代码行数:1,代码来源:Vertex.ts

示例6: handleMessage

  handleMessage({ content, player, timestamp}: ClientMessage<Player.GamePlayer>): Message[] {
    let responses: Message[] = [ Messaging.createEchoMessage(content, player) ];

    const component = Actions.getComponentByText(content);

    // if we received an action command message
    if (component) {
      const action = component.parse(content, player.character, timestamp);

      const { isValid, error } = component.validate(action, this);

      if (isValid) {
        player.character.nextAction = action;
        responses.push(Messaging.createGameMessage(`Next action: ${content}`, [ player ]));
      } else {
        responses.push(Messaging.createGameMessage(`Invalid action: ${error}`, [ player ]));
      }
    } else if (_.startsWith(content, '/')) {
      const messageNameSpan = Messaging.spanMessagePlayerNames(content, this.players);

      const toPlayers: Player.GamePlayer[] = [];

      if (_.startsWith(content, '/s ')) {
        this.getNearbyAnimals(player.character).forEach(animal => {
          // do we even need to send a message?
          if (Character.isPlayerCharacter(animal)) {
            // don't send a shout to the shouter!
            if (animal.playerId !== player.id) {
              const maybePlayer = this.getPlayer(animal.playerId);
              if (maybePlayer) {
                toPlayers.push(maybePlayer);
              } else {
                throw new Error(`Got a bad or missing id: ${animal.playerId}`);
              }
            }
          }
        });
      } else {
        messageNameSpan.names.forEach(name => {
          const maybePlayer = this.getPlayerByName(name);

          if (maybePlayer) {
            toPlayers.push(maybePlayer);
          } else {
            // do nothing
          }
        });
      }

      const [ yesComm, noComm ] = _.partition(toPlayers, otherPlayer => Player.canCommunicate(player, otherPlayer));

      const noCommMessage = 'something [CANNOT COMMUNICATE]';

      const restContent = messageNameSpan.rest;

      if (_.startsWith(content, '/t ')) {
        responses.push(Messaging.createTalkMessage(player, restContent, yesComm));
        responses.push(Messaging.createTalkMessage(player, noCommMessage, noComm));
      } else if (_.startsWith(content, '/s ')) {
        responses.push(Messaging.createShoutMessage(player, restContent, yesComm));
        responses.push(Messaging.createShoutMessage(player, noCommMessage, noComm));
      } else if (_.startsWith(content, '/w ')) {
        if (toPlayers.length) {
          if (yesComm.length) {
            const whisperContent = _.drop(content.split(' '), 2).join(' ');

            responses.push(Messaging.createWhisperMessage(player, whisperContent, _.head(yesComm)));
          }

          if (noComm.length) {
            responses.push(Messaging.createWhisperMessage(player, noCommMessage, _.head(noComm)));
          }
        }
      } else {
        responses.push(Messaging.createGameMessage(`Unknown communication: "${content}`, [ player ]));
      }
    } else {
      responses.push(Messaging.createGameMessage(`Unknown command or communication: "${content}"`, [ player ]));
    }
    return responses;
  }
开发者ID:zthomae,项目名称:xanadu,代码行数:81,代码来源:game.ts

示例7: parseInt

          return rows.map(row => {
            const name = _.drop(row.name.split('~')).join('~')

            return { ...row, name: _.isEmpty(name) ? 'unknown' : name, count: parseInt(row.count) }
          })
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:5,代码来源:custom-analytics.ts


注:本文中的lodash.drop函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。