本文整理汇总了TypeScript中Immutable.List.slice方法的典型用法代码示例。如果您正苦于以下问题:TypeScript List.slice方法的具体用法?TypeScript List.slice怎么用?TypeScript List.slice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.List
的用法示例。
在下文中一共展示了List.slice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getFoodEntries
private getFoodEntries(): Map<number, Set<string>> {
// Reduce over the second through last line, converting the string into a
// Map of {price: ["set", "of", "foods", "at", "that", "price"]}
return this.lines
.slice(1) // drop the first line, which contains desiredPrice
.reduce(
(accum, el: string): Map<number, Set<string>> => {
// parseOneLine returns a single-entry Map. {price: ["food", "food"]}.
let newEntry = this.parseOneLine(el);
// mergeWith merges two maps. If there is a collision between keys, it
// calls the passed-in function, and sets the value at that key
// as the value returned from the lambda. Here, if the keys collide, we
// know we must concat the food name to the list of food names already
// at that price.
return accum.mergeWith((oldVal, newVal) => {
return oldVal.concat(newVal);
}, newEntry);
}, Map()) as Map<number, Set<string>>;
}