本文整理汇总了TypeScript中Immutable.OrderedSet函数的典型用法代码示例。如果您正苦于以下问题:TypeScript OrderedSet函数的具体用法?TypeScript OrderedSet怎么用?TypeScript OrderedSet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OrderedSet函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: OrderedSet
(() => {
let expectedResult = OrderedSet([
List([1, 1, 1, 1]),
List([1, 1, 2]),
List([2, 2]),
List([1, 3])]);
expect((new Knapsack(OrderedSet([1, 2, 3]), 4)).getResults()).toEqual(expectedResult);
})();
示例2: it
it("correctly computes the supplied problem", () => {
let expectedResultGiven = OrderedSet([
List([215, 215, 215, 215, 215, 215, 215]),
List([215, 355, 355, 580])
]);
let menuItems = OrderedSet([215, 275, 335, 355, 420, 580]);
expect((new Knapsack(menuItems, 1505)).getResults()).toEqual(expectedResultGiven);
});
示例3: it
it('it should extract keys for each path in a nested complex array', () => {
let schema = {
type: 'object',
properties: {
anArray: {
type: 'array',
items: {
type: 'object',
properties: {
anObject: {
type: 'object',
properties: {
prop1: {
type: 'string'
},
prop2: {
type: 'string'
}
}
},
aString: {
type: 'string'
},
innerArray: {
type: 'array',
items: {
type: 'object',
properties: {
prop1: {
type: 'string'
},
prop2: {
type: 'string'
}
}
}
}
}
}
}
}
};
let expectedMap = {
'': OrderedSet(['anArray']),
'.anArray': OrderedSet(['anObject', 'aString', 'innerArray']),
'.anArray.anObject': OrderedSet(['prop1', 'prop2']),
'.anArray.innerArray': OrderedSet(['prop1', 'prop2'])
};
service.buildSchemaKeyStore(schema);
Object.keys(service.schemaKeyStoreMap)
.forEach(key => {
expect(service.schemaKeyStoreMap[key]).toEqual(expectedMap[key]);
});
});
示例4: it
it('supports React elements {min: false}', () => {
const reactElement = React.createElement('Mouse', null, 'Hello World');
expect(Immutable.OrderedSet([reactElement, reactElement])).toPrettyPrintTo(
'Immutable.OrderedSet [\n <Mouse>\n Hello World\n </Mouse>,\n]',
{min: false},
);
});
示例5: switch
export const uiReducer = (state = INITIAL_STATE, action: Actions) => {
switch (action.type) {
case 'EDITOR_ADD_VIEW':
return addView(state, action.payload.id);
case 'EDITOR_REMOVE_VIEW':
return removeView(state, action.payload.id);
case 'INVENTORY_SELECT_ITEMS':
return state.set('selectedItems', OrderedSet(action.payload.ids));
case 'EDITOR_SET_ACTIVE_VIEW':
return state.set('activeEditorView', action.payload.id);
case 'INVENTORY_TOGGLE_SELECT':
return toggleSelect(state, action);
case 'INVENTORY_TOGGLE_EXPAND':
return toggleExpand(state, action);
case 'INVENTORY_EXPAND_ITEMS':
return expandItems(state, action);
case 'SET_STATE':
return setState(state, action);
case 'SOCKET_STATUS':
return state.set('alert', ALERTS[action.payload.status]);
case 'PLAYER_SET_ACTIVE_VIEW':
return state.set('activePlayerView', action.payload.name);
case 'RESIZE_PANEL':
return state.set(action.payload.property, action.payload.size);
default:
return state;
}
};
示例6: genKey
const createContentBlock = ( blockData: DraftEntityInstance, contentState: ContentState) => {
const {key, type, text, data, inlineStyles, entityData} = blockData;
let blockSpec = {
type: type != null ? type : 'unstyled',
text: text != null ? text : '',
key: key != null ? key : genKey(),
data: null,
characterList: List([]),
};
if (data) {
blockSpec.data = fromJS(data)
}
if (inlineStyles || entityData) {
let entityKey;
if (entityData) {
const {type, mutability, data} = entityData;
contentState.createEntity(type, mutability, data);
entityKey = contentState.getLastCreatedEntityKey();
} else {
entityKey = null
}
const style = OrderedSet(inlineStyles || [])
const charData = CharacterMetadata.create({style, entityKey} as CharacterMetadataConfig)
blockSpec.characterList = List(Repeat(charData, text.length))
}
return new ContentBlock(blockSpec)
}
示例7: List
return prices.flatMap((price: number) => {
let newBudget = budget - price; // If we buy this item, what is our new budget?
// Remove items that are more than our budget and more than the item
// under consideration.
let newMenuItems = prices.filter(c => {
let priceCeiling = Math.min(newBudget, price);
return c <= priceCeiling;
}) as OrderedSet<number>; // Should remain an OrderedSet after filter
// No recursion if the item under consideration exactly zeroes our
// budget.
if (newBudget === 0) {
let results = List([List([price])]);
this.memo[hashed] = results;
return results;
};
// Recursive call
let recursive = this.computeHelper(newMenuItems, newBudget);
// If recursion returned results, concat the item under consideration
// onto each result and return that. If recursion didn't return results
// return empty set.
let results = recursive
? recursive.map((e: List<number>) => e.concat(price)).toSet()
: OrderedSet([]);
this.memo[hashed] = results;
return results;
});
示例8: attachBibData
private attachBibData(filterData:{[k:string]:Array<FilterResponseValue>}) {
const attrObj = this.textTypesStore.getAttribute(this.bibliographyAttribute);
const newBibData = filterData[this.bibliographyAttribute];
// set the data iff server data are full-fledget (i.e. including unique 'ident')
if (newBibData.length > 0 && !!newBibData[0].ident) {
this.bibliographyIds = this.bibliographyIds.union(Immutable.OrderedSet<string>(newBibData.map(v => v.ident)));
}
this.textTypesStore.setExtendedInfoSupport(
this.bibliographyAttribute,
(ident:string) => {
if (this.bibliographyIds.contains(ident)) {
return this.loadBibInfo(ident).then(
(serverData:ServerBibData) => {
this.textTypesStore.setExtendedInfo(this.bibliographyAttribute,
ident, Immutable.OrderedMap<string, any>(serverData.bib_data));
}
).catch(
(err:any) => {
this.pluginApi.showMessage('error', err);
}
);
} else {
return new RSVP.Promise<any>((resolve:()=>void, reject:(err)=>void) => {
reject(new Error('Item not found'));
})
}
}
);
}