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


TypeScript Tree.entryCount方法代码示例

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


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

示例1: walkTree

  private async walkTree(
    fileTree: FileTree,
    tree: Tree,
    paths: string[],
    skip: number,
    limit: number,
    childrenDepth: number = 1,
    flatten: boolean = false
  ): Promise<FileTree> {
    const [path, ...rest] = paths;
    fileTree.childrenCount = tree.entryCount();
    if (!fileTree.children) {
      fileTree.children = [];
      for (const e of tree.entries().slice(skip, limit)) {
        const child = entry2Tree(e);
        fileTree.children.push(child);
        if (e.isDirectory()) {
          const childChildrenCount = (await e.getTree()).entryCount();
          if ((childChildrenCount === 1 && flatten) || childrenDepth > 1) {
            await this.walkTree(
              child,
              await e.getTree(),
              [],
              skip,
              limit,
              childrenDepth - 1,
              flatten
            );
          }
        }
      }
      fileTree.children.sort(sortFileTree);
    }
    if (path) {
      const entry = await checkExists(
        () => Promise.resolve(tree.getEntry(path)),
        `path ${fileTree.path}/${path} does not exists.`
      );
      let child = entry2Tree(entry);
      if (entry.isDirectory()) {
        child = await this.walkTree(
          child,
          await entry.getTree(),
          rest,
          skip,
          limit,
          childrenDepth,
          flatten
        );
      }
      const idx = fileTree.children.findIndex(c => c.name === entry.name());
      if (idx >= 0) {
        // replace the entry in children if found
        fileTree.children[idx] = child;
      } else {
        fileTree.children.push(child);
      }
    }

    return fileTree;
  }
开发者ID:elastic,项目名称:kibana,代码行数:61,代码来源:git_operations.ts


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