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


TypeScript List.last方法代码示例

本文整理汇总了TypeScript中Immutable.List.last方法的典型用法代码示例。如果您正苦于以下问题:TypeScript List.last方法的具体用法?TypeScript List.last怎么用?TypeScript List.last使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Immutable.List的用法示例。


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

示例1: reduceOutputs

export function reduceOutputs(
  outputs: List<ImmutableOutput> = List(),
  output: OnDiskOutput
): List<ImmutableOutput> {
  // Find the last output to see if it's a stream type
  // If we don't find one, default to null
  const last = outputs.last(null);

  if (!last || !last.output_type) {
    return outputs.push(createImmutableOutput(output));
  }

  if (output.output_type !== "stream" || last.output_type !== "stream") {
    // If the last output type or the incoming output type isn't a stream
    // we just add it to the outputs
    // This is kind of like a "break" between streams if we get error,
    // display_data, execute_result, etc.
    return outputs.push(createImmutableOutput(output));
  }

  const streamOutput: OnDiskStreamOutput = output;

  if (typeof streamOutput.name === "undefined") {
    return outputs.push(createImmutableOutput(streamOutput));
  }

  function appendText(text: string): string {
    if (typeof streamOutput.text === "string") {
      return escapeCarriageReturnSafe(text + streamOutput.text);
    }
    return text;
  }

  // Invariant: size > 0, outputs.last() exists
  if (last.name === streamOutput.name) {
    return outputs.updateIn([outputs.size - 1, "text"], appendText);
  }

  // Check if there's a separate stream to merge with
  const nextToLast = outputs.butLast().last(null);

  if (
    nextToLast &&
    nextToLast.output_type === "stream" &&
    nextToLast.name === streamOutput.name
  ) {
    return outputs.updateIn([outputs.size - 2, "text"], appendText);
  }
  // If nothing else matched, just append it
  return outputs.push(createImmutableOutput(streamOutput));
}
开发者ID:nteract,项目名称:nteract,代码行数:51,代码来源:notebook.ts

示例2: Some

 .reduce((accumulator: List<[string, List<GitHubCommit>]>, currentCommit: GitHubCommit, currentIndex: number): List<[string, List<GitHubCommit>]> => {
     const isNotEmpty: boolean = ! accumulator.isEmpty();
     const previousGroup = accumulator.last();
     const maybePreviousAuthorName: Option<string> = isNotEmpty ? headOption(previousGroup) : None;
     return maybePreviousAuthorName
         .flatMap(previousAuthorName => {
             if (previousAuthorName === currentCommit.authorName) {
                 const currentCommitsByAuthor = previousGroup[1];
                 const index = accumulator.indexOf(previousGroup);
                 return new Some(accumulator.set(index, [ previousAuthorName, currentCommitsByAuthor.push(currentCommit) ]))
             } else {
                 return None;
             }
         })
         .getOrElse(() => accumulator.push([ currentCommit.authorName, List([ currentCommit ]) ]))
 }, List<[string, List<GitHubCommit>]>())
开发者ID:,项目名称:,代码行数:16,代码来源:

示例3: selectAutocompleteItem

export const selectPreviousAutocompleteItem = (options: List<AutocompleteItem>, current: AutocompleteItem) => {
  const index = options.findIndex((option) => option === current);
  const item = index === 0 ? options.last() : options.get(index - 1);
  return selectAutocompleteItem(item);
};
开发者ID:threehams,项目名称:reverie-client,代码行数:5,代码来源:commandActions.ts

示例4: simSpec

 get simSpec(): xmile.SimSpec {
   return defined(defined(this.files.last()).simSpec);
 }
开发者ID:sdlabs,项目名称:sd.js,代码行数:3,代码来源:project.ts

示例5:

this.todos.update(todos=>this.history.last().deref());
开发者ID:binaryk,项目名称:rect-rx-typescript,代码行数:1,代码来源:index.ts


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