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


TypeScript Immutable.Stack类代码示例

本文整理汇总了TypeScript中Immutable.Stack的典型用法代码示例。如果您正苦于以下问题:TypeScript Stack类的具体用法?TypeScript Stack怎么用?TypeScript Stack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: push

    /**
     * 设置重做、撤销栈
     * @param baseState this.state.baseState
     * @param contentState 当前设置的新内容State,newContentState
     * @param isSetUndo 是否设置撤销栈,线性调整在调整过程中不记录堆栈,调整结束时手动记录调整开始位置的状态为撤销栈
     */
    static push(baseState: BaseState, contentState: ContentState, isSetUndo: boolean = true): BaseState {
        if (baseState.getCurrentContent() === contentState) {
            return baseState;
        }

        const currentContent: ContentState = baseState.getCurrentContent();
        let tempContentState: ContentState = baseState.getTempContentState();
        let undoStack: Stack<ContentState> = baseState.getUndoStack();
        const redoStack: Stack<ContentState> = baseState.getRedoStack();
        const newContent: ContentState = contentState;

        if (newContent !== currentContent && isSetUndo === true) {
            tempContentState = newContent;
            undoStack = undoStack.push(currentContent);
        }

        const editorStateChanges: any = {
            currentContent: newContent,
            tempContentState,
            undoStack,
            redoStack
        };

        return BaseState.set(baseState, editorStateChanges);
    }
开发者ID:xprst,项目名称:xprst-com,代码行数:31,代码来源:BaseState.ts

示例2: it

 it('push inserts at lowest index', () => {
   var s0 = Stack.of('a', 'b', 'c');
   var s1 = s0.push('d', 'e', 'f');
   expect(s0.size).toBe(3);
   expect(s1.size).toBe(6);
   expect(s1.toArray()).toEqual(['d', 'e', 'f', 'a', 'b', 'c']);
 });
开发者ID:Harishs84,项目名称:immutable-js,代码行数:7,代码来源:Stack.ts

示例3: redo

    /**
     * 重做
     * @param baseState 当前baseState
     */
    static redo(baseState: BaseState): BaseState {
        const redoStack: Stack<ContentState> = baseState.getRedoStack();
        const newCurrentContent: ContentState = redoStack.peek();
        if (!newCurrentContent) {
          return baseState;
        }

        const currentContent: ContentState = baseState.getCurrentContent();

        return BaseState.set(baseState, {
            currentContent: newCurrentContent,
            tempContentState: newCurrentContent,
            undoStack: baseState.getUndoStack().push(currentContent),
            redoStack: redoStack.shift()
        });
    }
开发者ID:xprst,项目名称:xprst-com,代码行数:20,代码来源:BaseState.ts

示例4: InterpreterState

export const createInterpreter = (): InterpreterState => {
  const globalEnv: Scope = {
    name: '_global_',
    parent: undefined,
    environment: Map<string, any>()
  }

  return new InterpreterState({
    _done: false,
    _isReturned: false,
    _result: undefined,
    isRunning: true,
    frames: Stack.of(0),
    scopes: Map.of(0, globalEnv),
    errors: List(),
    value: undefined,
    node: undefined
  })
}
开发者ID:evansb,项目名称:source-toolchain,代码行数:19,代码来源:interpreter.ts

示例5: constructor

 constructor(init: T, private _onChange?: (e: T) => void)
 {
     this._history = Immutable.Stack.of<T>(init);
     this._redoHistory = Immutable.Stack<T>();
 }
开发者ID:hiram-k,项目名称:flex,代码行数:5,代码来源:History.ts


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