本文整理匯總了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) => {