當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript keyBy.keyBy函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。