本文整理汇总了TypeScript中Immutable.Set函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Set函数的具体用法?TypeScript Set怎么用?TypeScript Set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Set函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getAllSelections
function getAllSelections(state: State): Set<Record<AnnotationSelection>> {
const rangeSelections = state.getIn(['selection', 'annotation', 'range'])
const pickSelections = state.getIn(['selection', 'annotation', 'pick'])
const selected = state.getIn(['selection', 'annotation', 'selected'])
const selectedSet = selected !== null ? Set().add(selected) : Set()
return rangeSelections.union(pickSelections).union(selectedSet)
}
示例2: describe
describe("formatter", () => {
let priceMap = Map.of(
215, Set(["mixed fruit", "bubble yum"]),
275, Set(["french fries"]),
335, Set(["side salad"]),
355, Set(["hot wings"]),
420, Set(["mozzarella sticks"]),
580, Set(["sampler plate"])
);
let priceCombinations = Set([
List([215, 215, 215, 215, 215, 215, 215]),
List([215, 355, 355, 580])
]);
let expectedResult = Set([
Set(["7 orders of mixed fruit or bubble yum (at $2.15 each)."]),
Set([
"1 order of mixed fruit or bubble yum (at $2.15 each).",
"1 order of mixed fruit or bubble yum (at $2.15 each).",
"2 orders of hot wings (at $3.55 each).",
"1 order of sampler plate (at $5.80 each)."
])
]);
it("properly formats the supplied data", () => {
let f = new Formatter(priceMap, priceCombinations);
expect(f.getSentences().equals(expectedResult)).toBe(true);
});
});
示例3: createSelector
export const getAnnotationsSelections = createSelector(getProjectAnnotationSelection, annotationSelection => {
const ranged = annotationSelection.get('range', null)
const picked = annotationSelection.get('pick', null)
const selected = annotationSelection.get('selected', null)
const selectedSet: Set<Record<AnnotationSelection>> = selected ? Set().add(selected) : Set()
return ranged.union(picked, selectedSet)
})
示例4: Set
const getState = () => StateFactory.build({
lar: LarFactory.build({
filters: FiltersFactory.build({
county: Set(["1234", "2345"]),
metro: Set(["3456"]),
}),
lookups: LookupsFactory.build({
geos: Map([
[
"1234",
new Geo("name", { lat: 29, lon: -10 }, { lat: 11, lon: -20 }),
],
[
"2345",
new Geo("other", { lat: 29, lon: -11 }, { lat: 10, lon: -19 }),
],
[
"3456",
new Geo("another", { lat: 30, lon: -11 }, { lat: 11, lon: -19 }),
],
]),
}),
}),
window: { height: 100, width: 100 },
});
示例5:
const getState = () => StateFactory.build({
lar: LarFactory.build({
filters: FiltersFactory.build({
county: Set<string>(),
metro: Set<string>(),
}),
}),
});
示例6: createCommandSet
function createCommandSet(commands: CommandData[]): Set<Command> {
if (!commands) {
return Set([]);
}
return commands.reduce((set, command) => {
return set.add(createCommandRecord(command));
}, Set([]));
}
示例7: it
it("loads county, lender, and metro", () => {
const result = deriveLar("county=123&lender=456&metro=789", [2009]);
expect(result.filters).toMatchObject({
county: Set(["123"]),
lender: Set(["456"]),
metro: Set(["789"]),
});
});
示例8: List
allowed: List(part.allowed.map((allow) => new Allowed({
...allow,
components: Set(allow.components),
names: Set(allow.names),
owners: Set(allow.owners),
states: Set(allow.states),
types: Set(allow.types),
}))),
示例9: Error
}).then((ud: UserDetail) => {
if(!ud)
throw new Error('Invalid Session');
req.user = ud;
// convert javascript arrays into Sets
req.user.estates = Set<number>(req.user.estates);
req.user.regions = Set<string>(req.user.regions);
return next();
}).catch((err: Error) => {