• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript underscore.first函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: shellExecuteNpmInstall

    /**
     * Executes the 'npm install' command for the packages specified in the registry package map.
     *
     * @param packagePath The folder of the package that is to be installed.
     * @param registryMap The map of registry and packages that should be installed.
     */
    public shellExecuteNpmInstall(packagePath: string, registryMap: IDictionary<Array<string>>): void {
        const INSTALLABLE_PACKAGE_CHUNKSIZE: number = 50;

        for (let registry in registryMap) {
            let packages = registryMap[registry];

            if (!packages || packages.length === 0) continue;

            // Install packages in bundles because command line lengths aren't infinite. Windows for example has
            // a command line limit of 8192 characters. It's variable on *nix and OSX but will in the 100,000s

            let installablePackages = _.first(packages, INSTALLABLE_PACKAGE_CHUNKSIZE);
            packages = _.rest(packages, INSTALLABLE_PACKAGE_CHUNKSIZE);

            while (installablePackages && installablePackages.length > 0) {
                var installArgs = ["install"].concat(installablePackages);

                if (packagePath === process.cwd()) {
                    installArgs.push("--ignore-scripts");
                }

                if (registry !== "*") {
                    installArgs.push("--registry");
                    installArgs.push(registry);
                }

                this.shellExecuteNpm(packagePath, installArgs);

                installablePackages = _.first(packages, INSTALLABLE_PACKAGE_CHUNKSIZE);
                packages = _.rest(packages, INSTALLABLE_PACKAGE_CHUNKSIZE);
            }
        }
    }
开发者ID:i-e-b,项目名称:gulp-npmworkspace,代码行数:39,代码来源:NpmPluginBinding.ts


示例2:

 _.each(postmasterItemCountsByType, (count, bucket) => {
   if (count > 0) {
     const items: DimItem[] = store.buckets[bucket];
     const capacity = store.capacityForItem(items[0]);
     const numNeededToMove = Math.max(0, count + items.length - capacity);
     if (numNeededToMove > 0) {
       // We'll move the lowest-value item to the vault.
       const candidates = _.sortBy(items.filter((i) => !i.equipped && !i.notransfer), (i) => {
         let value = {
           Common: 0,
           Uncommon: 1,
           Rare: 2,
           Legendary: 3,
           Exotic: 4
         }[i.tier];
         // And low-stat
         if (i.primStat) {
           value += i.primStat.value / 1000;
         }
         return value;
       });
       itemsToMove.push(..._.first(candidates, numNeededToMove));
     }
   }
 });
开发者ID:bhollis,项目名称:DIM,代码行数:25,代码来源:postmaster.ts


示例3: formatError

export function formatError(
  e: Error,
  apiErrorPrefix?: string
): LocalizedString {
  const re = asRequestError(e);
  if (re && re.rpcError) {
    const { code, data } = re.rpcError;
    if (data && data.apiError && apiErrorPrefix) {
      const { messages } = data.apiError;
      const message = first(messages) as string;
      if (message) {
        const snakeCaseMessage = message.replace(/\s/g, "_").toLowerCase();
        return [
          `errors.api.${apiErrorPrefix}.${snakeCaseMessage}`,
          {
            defaultValue: `{message}`,
            message,
          },
        ];
      }
    }

    const { message } = re.rpcError;
    return [
      `butlerd.codes.${code}`,
      {
        defaultValue: `{message}`,
        message,
      },
    ];
  }
  return e.message;
}
开发者ID:itchio,项目名称:itch,代码行数:33,代码来源:errors.ts


示例4:

 const itemsByType = _.mapObject(_.groupBy(engrams, 'type'), (items) => {
   // Sort exotic engrams to the end so they don't crowd out other types
   items = _.sortBy(items, (i) => {
     return i.isExotic ? 1 : 0;
   });
   // No more than 9 engrams of a type
   return _.first(items, 9);
 });
开发者ID:delphiactual,项目名称:DIM,代码行数:8,代码来源:auto-loadouts.ts


示例5: limitToBucketSize

function limitToBucketSize(items: DimItem[], isVault) {
  if (!items.length) {
    return [];
  }
  const item = items[0];

  if (!item.bucket) {
    return isVault ? items : _.first(items, 9);
  }
  const bucket = isVault ? item.bucket.vaultBucket : item.bucket;

  if (!bucket) {
    return isVault ? items : _.first(items, 9);
  }
  // TODO: this doesn't take into account stacks that need to split
  return _.first(items, bucket.capacity - (item.equipment ? 1 : 0));
}
开发者ID:delphiactual,项目名称:DIM,代码行数:17,代码来源:auto-loadouts.ts


示例6: it

 it('when default path is specified, sends the correct path in the query', () => {
   test = Mock.optionsComponentSetup<CategoryFacet, ICategoryFacetOptions>(CategoryFacet, {
     field: '@field',
     basePath: ['base', 'path']
   });
   const { queryBuilder } = Simulate.query(test.env, simulateQueryData);
   expect(first(queryBuilder.categoryFacets[0].path, 2)).toEqual(['base', 'path']);
 });
开发者ID:francoislg,项目名称:search-ui,代码行数:8,代码来源:CategoryFacetTest.ts


示例7: setExpandedAndCollapsed

 private setExpandedAndCollapsed() {
   if (this.facetValues.length > this.facet.options.numberOfValuesInBreadcrumb) {
     this.collapsed = _.rest(this.facetValues, this.facet.options.numberOfValuesInBreadcrumb - 1);
     this.expanded = _.first(this.facetValues, this.facet.options.numberOfValuesInBreadcrumb - 1);
   } else {
     this.collapsed = [];
     this.expanded = this.facetValues;
   }
 }
开发者ID:erocheleau,项目名称:search-ui,代码行数:9,代码来源:BreadcrumbValuesList.ts


示例8: build

  public async build(sources: Record<string, ITableDataSource>[], table: Dom, gridOptions = defaultGridOptions) {
    const firstData = first(sources) || {};
    const mapToAgGridFormat = (value: agGridModule.ColDef & agGridModule.ColGroupDef, key: string): any => {
      if (value.children) {
        return {
          field: key,
          headerName: key,
          marryChildren: true,
          children: flatten(
            value.children.map((child: any) => {
              return map(child, mapToAgGridFormat);
            })
          )
        };
      } else {
        return {
          field: key,
          headerName: key,
          ...value
        };
      }
    };

    const columnDefs = map(firstData as any, mapToAgGridFormat) as agGridModule.ColDef[];

    const rowData = map(sources, source => {
      const merged: any = {};

      const extractContent = (value: ITableDataSource & agGridModule.ColGroupDef, key: string) => {
        if (value.content) {
          merged[key] = value.content;
        } else if (value.children) {
          each(value.children, (child: any) => {
            each(child, extractContent);
          });
        }
      };

      each(source, extractContent as any);
      return merged;
    });

    this.gridOptions = {
      ...defaultGridOptions,
      columnDefs,
      rowData,
      ...gridOptions
    };

    await loadAgGridLibrary();
    const grid = new agGrid.Grid(table.el, this.gridOptions);

    return { grid, gridOptions: this.gridOptions };
  }
开发者ID:coveo,项目名称:search-ui,代码行数:54,代码来源:TableBuilder.ts


示例9: getRelativePathLeadingCharacters

  private static getRelativePathLeadingCharacters(toNormalize: IUrlNormalize) {
    let leadingRelativeUrlCharacters = '';

    const relativeUrlLeadingCharactersRegex = /^(([\/])+)/;
    const firstPath = first(this.toArray(toNormalize.paths));

    if (firstPath) {
      const match = relativeUrlLeadingCharactersRegex.exec(firstPath);
      if (match) {
        leadingRelativeUrlCharacters = match[0];
      }
    }

    return leadingRelativeUrlCharacters;
  }
开发者ID:coveo,项目名称:search-ui,代码行数:15,代码来源:UrlUtils.ts


示例10: function

    topWordList: function (objectList, options) {
        let topN = options.topN || 50;

        var tags = analyseAll(objectList);
        let words = _(Object.keys(tags))
            .map((w) => {
                return {
                    word: w,
                    plaqueCount: tags[w]
                };
            });

        let sorted = _.sortBy(words, (w: any) => w.plaqueCount * -1);
        let topList = _.first(sorted, topN).map((w: any) => w.word);

        return topList;
    },
开发者ID:toastermagic,项目名称:plaques,代码行数:17,代码来源:index.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript underscore.flatten函数代码示例发布时间:2022-05-25
下一篇:
TypeScript underscore.findWhere函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap