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

TypeScript keyBy.keyBy函数代码示例

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

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



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

示例1: parseResponse

  private parseResponse(res: IGroupBuyResponse): GroupBuy {
    let items = res.Items || [];
    let skus = res.Skus || [];

    let skuMap = keyBy(skus, item => item.ID);
    let map: Dict<IGroupBuyItem> = {};
    let active: IGroupBuyItem[] = [];
    let inactive: IGroupBuyItem[] = [];
    items.sort((a, b) => a.Start - b.Start).forEach(item => {
      let sku = skuMap[item.SkuID];
      if (sku) {
        item.sku = sku;
        (item.End > Date.now() / 1000 ? active : inactive).push(item);
        map[item.SkuID] = item;
      }
    });
    return { items, map, active, inactive };
  }
开发者ID:tooltakes,项目名称:ec-front,代码行数:18,代码来源:groupbuy.service.ts


示例2: add

 add(product: IProduct) {
   let index = this.getItems().findIndex(item => item.ProductID === product.ID);
   if (~index) {
     let id = this.getItems()[index].ID;
     this.getItems().splice(index, 1);
   }
   let item = {
     ID: 0,
     ProductID: product.ID,
     Name: product.Name,
     Img: product.Img || product.skus[0].Img,
     Price: product.skus[0].SalePrice,
     Vpn: product.Vpn,
   };
   this.getItems().unshift(item);
   if (this.getItems().length > MAX) {
     let map = keyBy(this._items.splice(MAX));
   }
   localStorage.setItem(historyKey, JSON.stringify(this._items));
 }
开发者ID:tooltakes,项目名称:ec-front,代码行数:20,代码来源:history.service.ts


示例3: require

    job: 'Developer @ VTEX',
    link: 'https://github.com/mairatma',
    name: 'Maira Bello',
  },
  {
    avatar: require('../assets/graphics/contributors/ben.jpg'),
    bio: "A full time Elixir developer at CargoSense, Ben is a co-author of the Absinthe GraphQL implementation for Elixir.",
    job: 'Developer @ Cargosense',
    link: 'https://twitter.com/benwilson512',
    name: 'Ben Wilson',
  },
  {
    avatar: require('../assets/graphics/contributors/bruce.jpg'),
    bio:
      "Bruce is a polyglot technologist, speaker, and Pragmatic Bookshelf author. He's the CTO of CargoSense, a logistics intelligence company built on Elixir and committed to its open source community.",
    job: 'CTO @ Cargosense',
    link: 'https://twitter.com/wbruce',
    name: 'Bruce Williams',
  },
  {
    avatar: require('../assets/graphics/contributors/marcandre.jpg'),
    bio:
      "A Jazz guitarist turned developer, Marc-AndrĂŠ is currently working at Shopify, trying to make commerce better for everyone. When he's not hacking on Rails, GraphQL or Relay, he likes lifting heavy barbells above his head.",
    link: 'http://mgiroux.me',
    job: 'Senior Developer @ Shopify',
    name: 'Marc-Andre Giroux'
  }
]

export default keyBy(authors, 'name')
开发者ID:arthurbragaa,项目名称:howtographql,代码行数:30,代码来源:authors.ts


示例4: keyBy

 ).map(([profile, res]: [IProfile, Response]) => {
   let items = keyBy(res.json(), (store: IStore) => store.ID) as Dict<IStore>;
   items[0] = { ID: 0, Name: profile.OfficialStoreName, CreatedAt: 0, User1: 0, Amap: null };
   return items;
 }).publishReplay(1).refCount();
开发者ID:tooltakes,项目名称:ec-front,代码行数:5,代码来源:store.service.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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