当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript List.push方法代码示例

本文整理汇总了TypeScript中Immutable.List.push方法的典型用法代码示例。如果您正苦于以下问题:TypeScript List.push方法的具体用法?TypeScript List.push怎么用?TypeScript List.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Immutable.List的用法示例。


在下文中一共展示了List.push方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getAdjacencies

export function getAdjacencies(voucherBooks: List<EAPAVoucherBook>): List<VoucherBookAdjacency> {

    let prevIds = voucherBooks.insert(0, undefined);
    let nextIds = voucherBooks.push(undefined).skip(1);

    return voucherBooks.zipWith(
        (curr, prev, next) => getAdjacency(curr, prev, next),
        voucherBooks.insert(0, undefined),
        voucherBooks.push(undefined).skip(1)
    ).toList();
}
开发者ID:ovangle,项目名称:TNC-admin-client,代码行数:11,代码来源:adjacency.model.ts

示例2: log

function log(state: List<Message> = List<Message>(), action: Action): List<Message> {
    switch (action.type) {
        case ActionType.CHANGE_CHANNEL:
            // Clear log
            return List<Message>()
        case ActionType.LOG_LINE:
            return state.push(Object.freeze({id: -1, channel: -1, username: "***", content: action.payload.log, timestamp: new Date()}))
        case ActionType.CHAT_MESSAGE:
            return state.push(action.payload.message)
        default:
            return state
    }
}
开发者ID:RX14,项目名称:discord-curses,代码行数:13,代码来源:reducers.ts

示例3: reduceOutputs

export function reduceOutputs(
  outputs: List<ImmutableOutput> = List(),
  output: OnDiskOutput
): List<ImmutableOutput> {
  // Find the last output to see if it's a stream type
  // If we don't find one, default to null
  const last = outputs.last(null);

  if (!last || !last.output_type) {
    return outputs.push(createImmutableOutput(output));
  }

  if (output.output_type !== "stream" || last.output_type !== "stream") {
    // If the last output type or the incoming output type isn't a stream
    // we just add it to the outputs
    // This is kind of like a "break" between streams if we get error,
    // display_data, execute_result, etc.
    return outputs.push(createImmutableOutput(output));
  }

  const streamOutput: OnDiskStreamOutput = output;

  if (typeof streamOutput.name === "undefined") {
    return outputs.push(createImmutableOutput(streamOutput));
  }

  function appendText(text: string): string {
    if (typeof streamOutput.text === "string") {
      return escapeCarriageReturnSafe(text + streamOutput.text);
    }
    return text;
  }

  // Invariant: size > 0, outputs.last() exists
  if (last.name === streamOutput.name) {
    return outputs.updateIn([outputs.size - 1, "text"], appendText);
  }

  // Check if there's a separate stream to merge with
  const nextToLast = outputs.butLast().last(null);

  if (
    nextToLast &&
    nextToLast.output_type === "stream" &&
    nextToLast.name === streamOutput.name
  ) {
    return outputs.updateIn([outputs.size - 2, "text"], appendText);
  }
  // If nothing else matched, just append it
  return outputs.push(createImmutableOutput(streamOutput));
}
开发者ID:nteract,项目名称:nteract,代码行数:51,代码来源:notebook.ts

示例4: addNode

    addNode(node: any) {
        var nodes = this.nodes.push(node);
        var children = this.children.set(node.id, List<any>());
        var parents = this.parents.set(node.id, List<any>());

        return new Graph(nodes, children, parents);
    }
开发者ID:gsanta,项目名称:gsgraph,代码行数:7,代码来源:Graph.ts

示例5: reducer

export function reducer(state: List<SettingItem> = List<SettingItem>(), action: ITodoAction) {

  function indexOf(uuid: string) {
    return state.findIndex((i: SettingItem) => i.uuid === action.itemId);
  }

  function createItemObj(text: string) {
    if (!text) {
      return new SettingItem();
    }
    if (text.indexOf('|') >= 0) {
      // parse the text for name|value format
      let tokens = text.split('|');
      if (tokens.length > 1) {
        return new SettingItem({name: tokens[0], value: tokens[1], completed: false, uuid: uuid.v4()});
      }
    }
    return new SettingItem({name: '[no name]', value: text, completed: false, uuid: uuid.v4()});
  }

  switch (action.type) {
    case 'ADD':
      return state.push(createItemObj(action.text));
    case 'REMOVE':
      return List<SettingItem>(state.filter((i: SettingItem) => i.uuid !== action.itemId));
    case 'UPDATE_ITEM_VALUE':
      return state.update(indexOf(action.itemId), (i: SettingItem) => i.setValue(action.text));
    case 'UPDATE_ITEM_COMPLETION':
      return state.update(indexOf(action.itemId), (i: SettingItem) => i.setCompleted(action.completed));
    default:
      return state;
  }

}
开发者ID:tanchifu,项目名称:angular2-todo,代码行数:34,代码来源:reducer.ts

示例6: deleteObjectIdRecur

function deleteObjectIdRecur(obj: any, stack: List<object>) {
  for (let i=0; i< stack.size; i++) {
    if (i > 10) {
      logger.warn("deleteObjectIdRecur: Too deep stack");
      logger.warn(obj);
      return;
    }
    if (obj === stack[i]) {
      logger.warn("deleteObjectIdRecur: recurrence found");
      logger.warn(obj);
      return;
    }
  }
  if (obj !== null && typeof(obj) == 'object') {
    if (obj instanceof Promise) {
      logger.warn("deleteObjectIdRecur: Object is promise");
    } else if (Array.isArray(obj)) {
      for (let i = 0; i < obj.length; i++) {
        if (obj[i] && obj[i]._id) deleteObjectIdRecur(obj[i], stack.push(obj));  //recursive del calls on array elements
      }
    } else {
      delete obj._id;
      Object.keys(obj).forEach(function(key) {
        if (obj[key] && obj[key]._id) deleteObjectIdRecur(obj[key], stack.push(obj)); //recursive del calls on object elements
      });
    }
  }
}
开发者ID:wafflestudio,项目名称:snutt,代码行数:28,代码来源:ObjectUtil.ts

示例7: function

export default function(state: List<TaskModel>, action: ITaskAction) {

  function indexOf(id: string): number {
    return state.findIndex((i: TaskModel) => i.id === id);
  }

  switch (action.type) {
    case LOAD_TASKS:
      state = action.taskList;
      return List<TaskModel>(state);
    case UPDATE_TASK:
      let index = state.findIndex((task) => task.id === action.task.id);
      return state.set(
        index,
        new TaskModel({
          id: action.task.id,
          title: action.task.title,
          details: action.task.details,
          dueDate: action.task.dueDate,
          completed: action.task.completed,
          completedDate: action.task.completedDate
        })
      );
    case COMPLETE_TASK:
      let completedTaskIndex = state.findIndex((task) => task.id === action.id);
      return state.delete(completedTaskIndex);
    case ADD_TASK:
      return state.push(action.task);
    default:
      return List<TaskModel>(state);
  }
}
开发者ID:wsquared,项目名称:angular2-task,代码行数:32,代码来源:taskReducer.ts

示例8: addTodo

	public addTodo(title: string){
        this.history = this.history.push(this.todos);
		this.todos.push(fromJS({
			id: Utils.uuid(),
			title: title,
			completed: false
		}));
	}
开发者ID:binaryk,项目名称:rect-rx-typescript,代码行数:8,代码来源:index.ts

示例9: Epic

 .subscribe(results => {
     if (results.type === ItemNameDialogResultType.Saved) {
         let epic = new Epic(this.modelId, this.router, this._createStoryDialog, results.name);
         epic.observeEvents();
         this._epics = this._epics.push(epic);
     }
     this._createEpicDialog.close();
 });
开发者ID:esp,项目名称:esp-js,代码行数:8,代码来源:workspace.ts

示例10: adnet

export function adnet(state: Map<string,any> = Map<string,any>(), action: any): Map<string,any> {

    var indexOfRateId = function (i_rateId: string) {
        return rates.findIndex((i: AdnetRateModel) => i.rateId() === i_rateId);
    }
    var indexOfCustomerId = function (i_adnetCustomerId: string) {
        return customers.findIndex((i: AdnetCustomerModel) => i.customerId() === i_adnetCustomerId);
    }
    switch (action.type) {
        case AdnetActions.RECEIVE_CUSTOMERS: {
            return state.setIn(['customers'], action.customers);
        }
        case AdnetActions.RECEIVE_RATES: {
            return state.setIn(['rates'], action.rates);
        }
        case AdnetActions.UPDATE_ADNET_RATE_TABLE: {
            var rates: List<AdnetRateModel> = state.getIn(['rates']);

            rates = rates.update(indexOfRateId(action.payload.rateId), (rate: AdnetRateModel) => {
                return rate.setField('rateMap', action.payload.rateTable)
            });
            rates = rates.update(indexOfRateId(action.payload.rateId), (rate: AdnetRateModel) => {
                rate = rate.setField('hourRate0', action.payload.adHourlyRate["0"])
                rate = rate.setField('hourRate1', action.payload.adHourlyRate["1"])
                rate = rate.setField('hourRate2', action.payload.adHourlyRate["2"])
                rate = rate.setField('hourRate3', action.payload.adHourlyRate["3"])
                return rate;
            });
            return state.setIn(['rates'], rates);
        }
        case AdnetActions.ADD_ADNET_RATE_TABLE: {
            var rates: List<AdnetRateModel> = state.getIn(['rates']);
            rates = rates.push(action.adnetRateModel);
            return state.setIn(['rates'], rates);
        }
        case AdnetActions.REMOVE_ADNET_RATE_TABLE: {
            var rates: List<AdnetRateModel> = state.getIn(['rates']);
            var updatedRates:List<AdnetRateModel> = rates.filter((adnetRateModel:AdnetRateModel) => adnetRateModel.rateId() !== action.rateId) as List<AdnetRateModel>;
            return state.setIn(['rates'], updatedRates);
        }
        case AdnetActions.UPDATE_ADNET_CUSTOMER: {
            var customers: List<AdnetCustomerModel> = state.getIn(['customers'])
            customers = customers.update(indexOfCustomerId(action.payload.Key), (customer: AdnetCustomerModel) => {
                return customer.setData<AdnetCustomerModel>(AdnetCustomerModel, action.payload)
            });
            return state.setIn(['customers'], customers);
        }
        case AdnetActions.RENAME_ADNET_RATE_TABLE: {
            var rates: List<AdnetRateModel> = state.getIn(['rates']);
            rates = rates.update(indexOfRateId(action.payload.rateId), (rate: AdnetRateModel) => {
                return rate.setField('label', action.payload.newLabel)
            });
            return state.setIn(['rates'], rates);
        }
        default:
            return state;
    }
}
开发者ID:nubiofs,项目名称:studioDashboard,代码行数:58,代码来源:AdnetReducer.ts


注:本文中的Immutable.List.push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。