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

TypeScript lodash.take函数代码示例

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

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



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

示例1: it

        it('should return the same set of results after reset() is called', () => {

            let paginator = paginationService.getPaginatorInstance('/collection');

            // Get first page
            $httpBackend.expectGET('/api/collection', (headers) => {
                    return headers.Range == 'entities=0-9'
                })
                .respond(206, _.take(collection, 10));

            let results1 = paginator.getNext();

            paginator.reset(); //reset the counter

            $httpBackend.flush();

            // Get first page again
            $httpBackend.expectGET('/api/collection', (headers) => {
                    return headers.Range == 'entities=0-9'
                })
                .respond(206, _.take(collection, 10));

            let results2 = paginator.getNext();

            $httpBackend.flush();

            expect(results1).eventually.to.be.instanceof(Array);
            expect(results1).eventually.to.have.length(10);
            expect(results2).eventually.to.have.length(10);
            expect(results1).eventually.to.deep.equal(_.take(collection, 10));
            expect(results2).eventually.to.deep.equal(_.take(collection, 10));

        });
开发者ID:swordman1205,项目名称:angular-typescript-material,代码行数:33,代码来源:paginationService.spec.ts


示例2: getPageInfo

export function getPageInfo(): GitLabInfo {
    const host = window.location.hostname

    const projectLink = document.querySelector<HTMLAnchorElement>('.context-header a')
    if (!projectLink) {
        throw new Error('Unable to determine project name')
    }

    const projectName = new URL(projectLink.href).pathname.slice(1)

    const parts = projectName.split('/')

    const owner = take(parts, parts.length - 1).join('/')
    const repoName = last(parts)!

    let pageKind: GitLabPageKind
    if (window.location.pathname.includes(`${owner}/${repoName}/commit`)) {
        pageKind = GitLabPageKind.Commit
    } else if (window.location.pathname.includes(`${owner}/${repoName}/merge_requests`)) {
        pageKind = GitLabPageKind.MergeRequest
    } else {
        pageKind = GitLabPageKind.File
    }

    return {
        owner,
        repoName,
        repoPath: [host, owner, repoName].join('/'),
        pageKind,
    }
}
开发者ID:JoYiRis,项目名称:sourcegraph,代码行数:31,代码来源:scrape.ts


示例3:

 _.each(postmasterItemCountsByType, (count, bucket) => {
   if (count > 0 && store.buckets[bucket].length > 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: number = {
           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(..._.take(candidates, numNeededToMove));
     }
   }
 });
开发者ID:w1cked,项目名称:DIM,代码行数:25,代码来源:postmaster.ts


示例4: limitToBucketSize

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

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

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


示例5:

 const itemsByType = _.mapValues(_.groupBy(engrams, (e) => e.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 _.take(items, 9);
 });
开发者ID:w1cked,项目名称:DIM,代码行数:8,代码来源:auto-loadouts.ts


示例6: runtime

const historicalDirectory = runtime(async (context) =>
    decorate(
        choice(
            _.take(["-", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "-9"], context.historicalCurrentDirectoriesStack.size)
                .map(alias => decorate(string(alias), description(expandHistoricalDirectory(alias, context.historicalCurrentDirectoriesStack))))
        ),
        style(styles.directory)
    )
开发者ID:Alubatm,项目名称:black-screen,代码行数:8,代码来源:Cd.ts


示例7: ngOnChanges

  ngOnChanges() {

    if (this.userData) {

    this.usersSorted = _.orderBy(this.userData, function(u){return Number(u.score)}, ['desc']);
    this.usersSorted =_.take(this.usersSorted,5);
    }
  }
开发者ID:NaturalSolutions,项目名称:Validator-clientNG,代码行数:8,代码来源:ranking.component.ts


示例8: function

 .add<RpcBotLog>("BOT_LOG", function (state, { payload }) {
   if (isBotLog(payload)) {
     state.logQueue.unshift(payload);
     state.logQueue = _.take(state.logQueue, state.logQueueSize);
   } else {
     console.warn(i18next.t("Unexpected log message?"));
   }
   return state;
 })
开发者ID:roryaronson,项目名称:farmbot-web-frontend,代码行数:9,代码来源:reducer.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.takeRight函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.tail函数代码示例发布时间: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