本文整理汇总了TypeScript中Immutable.List.map方法的典型用法代码示例。如果您正苦于以下问题:TypeScript List.map方法的具体用法?TypeScript List.map怎么用?TypeScript List.map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.List
的用法示例。
在下文中一共展示了List.map方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getStageNameList
function getStageNameList(stageList: List<StageConfig | RawStageConfig>) {
if (stageList.isEmpty()) {
return 'empty'
} else {
return stageList.map(s => s.name).join(',')
}
}
示例2: todosReducer
function todosReducer(state:List<ITask>, action:IAction):List<ITask> {
console.log(`todosReducer: Action(${JSON.stringify(action)})`);
switch(action.type) {
case Keys.AddTodo:
var todos: List<ITask> = List<ITask>(state.concat([action.payload]));
console.log(`todosReducer: todos(${JSON.stringify(todos)})`);
return todos;
case Keys.CompleteTodo:
return List<ITask>(state.map((task:ITask) => {
if (task.Id === action.payload.Id) {
return new Task(
task.Id,
task.Title,
task.Description,
action.payload.Complete
);
} else {
return task;
}
}));
case Keys.RemoveTodo:
return List<ITask>(state.filter((task:ITask) => {
return task.Id !== action.payload.Id;
}))
}
return state || initialState.todos;
}
示例3: totalIncomeForeignAmount
totalIncomeForeignAmount(): BigNumber {
return this.incomes
.map((i: Income) => i.foreignAmount)
.reduce(
(a: BigNumber, b: BigNumber) => a.plus(b),
new BigNumber(0));
}
示例4: recomputeRemaining
recomputeRemaining(): Project {
let remaining: BigNumber = this.incomes
.map(
(i: Income) => i.remainingLocalAmount())
.reduce(
(a: BigNumber, b: BigNumber) => a.plus(b),
new BigNumber(0));
return this.set('remainingLocalAmount', remaining);
}
示例5: todosReducer
function todosReducer(state: List<Todo> = List([]), action) {
switch (action.type) {
case LOAD_TODOS:
return List(action.todos);
case ADD_TODO:
return state.push(action.newTodo);
case TOGGLE_TODO:
return toggleTodo(state, action);
case TOGGLE_ALL_TODO:
return toggleAllTodo(state, action.completed);
case DELETE_TODO:
let index = state.findIndex((todo) => todo.id === action.todo.id);
return state.delete(index);
case SET_CURRENT_FILTER:
return state.map(todo => todo);
case '@@redux-pouchdb-plus/SET_REDUCER':
return state.map(todo => new Todo(todo.toJS()));
default:
return state;
}
}
示例6: calcMinMoves
private calcMinMoves() {
this.consoleLogMsg('score.service', 'calcMinMoves');
let moves: number = 0;
if (this._data.size > 0) {
this._data.map((score: Score) => {
if (moves === 0 || score.moves < moves) {
moves = score.moves;
}
});
}
this._minMoves = moves;
}
示例7: calcNextRow
private calcNextRow() {
this.consoleLogMsg('score.service', 'calcNextRow');
let row: number = 1;
if (this._data.size > 0) {
this._data.map((score: Score) => {
if (score.row > row) {
row = score.row;
}
});
row++;
}
this.nextRow = row;
this.consoleLogMsg('score.service', 'nextRow = ' + this.nextRow);
}
示例8: calcNextId
private calcNextId() {
this.consoleLogMsg('score.service', 'calcNextId');
let id: number = 1;
if (this._data.size > 0) {
this._data.map((score: Score) => {
if (score.id > id) {
id = score.id;
}
});
id++;
}
this._nextId = id;
this.consoleLogMsg('score.service', 'nextId = ' + this.nextId);
}
示例9: forkJoin
const fetchMapIssues = (reposIds: List<string>, state: any, page: number) =>
forkJoin(
...reposIds
.map(id =>
get({
endpoint: `repos/${state.repository.getIn([id, "full_name"])}/issues`,
params: { page }
})
)
.toArray()
).pipe(
map(issues => {
return List(issues)
.map((issueArr: any, index) => {
return issueArr.map(issue =>
issue.set("repositoryId", reposIds.get(index))
);
})
.flatten(1);
})
);
示例10: todosReducer
function todosReducer(state:List<ITask>, action:IAction):List<ITask> {
switch(action.key) {
case Keys.AddTodo:
return List<ITask>(state.concat([action.payload]))
case Keys.CompleteTodo:
return List<ITask>(state.map((task:ITask) => {
if (task.Id === action.payload.Id) {
return new Task(
task.Id,
task.Title,
task.Description,
action.payload.Complete
);
} else {
return task;
}
}));
case Keys.RemoveTodo:
return List<ITask>(state.filter((task:ITask) => {
return task.Id !== action.payload.Id;
}))
}
return state;
}