本文整理汇总了TypeScript中Immutable.List.of方法的典型用法代码示例。如果您正苦于以下问题:TypeScript List.of方法的具体用法?TypeScript List.of怎么用?TypeScript List.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.List
的用法示例。
在下文中一共展示了List.of方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should return the number of open tasks for the given state', (done) => {
let person1 = new Person('P1', List.of(
new Task(TaskType.BREAKFAST, 15, '', TaskState.FINISHED),
new Task(TaskType.WASH_FACE, 15, '', TaskState.RUNNING),
new Task(TaskType.DRIVE_TO_SCHOOL, 15, '', TaskState.WAITING)
), startTime);
let person2 = new Person('P2', List.of(
new Task(TaskType.BREAKFAST, 15, '', TaskState.FINISHED),
new Task(TaskType.WASH_FACE, 15, '', TaskState.BLOCKED),
new Task(TaskType.DRIVE_TO_SCHOOL, 15, '', TaskState.WAITING)
), startTime);
let person3 = new Person('P3', List.of(
new Task(TaskType.BREAKFAST, 15, '', TaskState.FINISHED),
new Task(TaskType.WASH_FACE, 15, '', TaskState.FINISHED),
new Task(TaskType.DRIVE_TO_SCHOOL, 15, '', TaskState.FINISHED)
), startTime);
const testState = Map({
persons: List.of(person1, person2, person3)
});
let expected = 4;
let actual = Person.getNumberOfOpenTasks(testState);
expected.should.equal(actual);
done();
});
示例2: it
it('adds the entries to the state', () => {
const state: Map<{}, {}> = Map();
const entries: List<string> = List.of('Trainspotting', '28 Days Later');
const nextState: Map<{}, {}> = setEntries(state, entries);
expect(nextState).to.equal(Map({
entries: List.of('Trainspotting', '28 Days Later')
}));
});
示例3: it
it('can compose Immutable::List initial states', () => {
const state = compose(List.of('a', 'b'), List.of('c', 'd'), List.of());
expect(List.isList(state)).to.be.true;
const plain = state.toJS();
expect(plain).not.to.be.null;
expect(plain).to.deep.equal(['a', 'b', 'c', 'd']);
});
示例4: it
it('compares lists', () => {
var list = List.of(1,2,3);
expectIs(list, list);
expectIsNot(list, [1,2,3]);
expectIs(list, Seq.of(1,2,3));
expectIs(list, List.of(1,2,3));
var listLonger = list.push(4);
expectIsNot(list, listLonger);
var listShorter = listLonger.pop();
expect(list === listShorter).toBe(false);
expectIs(list, listShorter);
});
示例5: it
it('is immutable', () => {
let state: List<string> = List.of('Trainspotting', '28 Days Later');
let nextState: List<string> = addMovie(state, 'Sunshine');
expect(nextState).to.equal(List.of(
'Trainspotting',
'28 Days Later',
'Sunshine'
));
expect(state).to.equal(List.of(
'Trainspotting',
'28 Days Later'
));
});
示例6: Map
export let generateInitialState = () => Map({
// blocked tasks is a list of tasks that needs another task to unlock it. (MAKE_BREAKFAST => BREAKFAST)
blockedTasks: List.of(TaskType.BREAKFAST, TaskType.DRIVE_TO_SCHOOL, TaskType.PUT_CLOTHES_ON, TaskType.FEED_BABY),
// tasks that can be executed by more than one person at the same time
parallelTasks: List.of(TaskType.BREAKFAST, TaskType.DRINK_COFFEE, TaskType.PUT_CLOTHES_ON, TaskType.PUT_SHOES_ON, TaskType.PREPARE_FOR_SCHOOL, TaskType.DRIVE_TO_SCHOOL, TaskType.CLEAN_KITCHEN, TaskType.GET_DRESSED),
// the current time
time: startTime,
// all persons, that are part of the simulation
persons: initialPersonList(),
// the last action. needed to determine the next action
lastAction: ActionType.TICK,
// the log, which will be displayed in UI.
log: List<string>()
});
示例7: it
it('counts from the end of the indexed sequence on negative index', () => {
var i = List.of(9, 5, 3, 1).map(x => - x);
expect(i.get(0)).toBe(-9);
expect(i.get(-1)).toBe(-1);
expect(i.get(-4)).toBe(-9);
expect(i.get(-5, 888)).toBe(888);
})
示例8: multiShard
function multiShard(): T {
const shards = List.of(
mkShard(reqs.slice(3, 5)),
mkShard(reqs.slice(5, 10))
)
return mkOrder(reqs.slice(0, 3), shards)
}