當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。