本文整理汇总了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;未经允许,请勿转载。 |
请发表评论