當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript algorithm.find函數代碼示例

本文整理匯總了TypeScript中@phosphor/algorithm.find函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript find函數的具體用法?TypeScript find怎麽用?TypeScript find使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了find函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

      it('should remove the specified node from the list', () => {
        let list = LinkedList.from([0, 1, 2, 3]);

        expect(list.isEmpty).to.equal(false);
        expect(list.length).to.equal(4);
        expect(list.first).to.equal(0);
        expect(list.last).to.equal(3);
        expect(toArray(list)).to.deep.equal([0, 1, 2, 3]);

        let n1 = find(list.nodes(), n => n.value === 2)!;
        list.removeNode(n1);
        expect(list.isEmpty).to.equal(false);
        expect(list.length).to.equal(3);
        expect(list.first).to.equal(0);
        expect(list.last).to.equal(3);
        expect(toArray(list)).to.deep.equal([0, 1, 3]);
        expect(n1.list).to.equal(null);
        expect(n1.next).to.equal(null);
        expect(n1.prev).to.equal(null);
        expect(n1.value).to.equal(2);

        let n2 = find(list.nodes(), n => n.value === 3)!;
        list.removeNode(n2);
        expect(list.isEmpty).to.equal(false);
        expect(list.length).to.equal(2);
        expect(list.first).to.equal(0);
        expect(list.last).to.equal(1);
        expect(toArray(list)).to.deep.equal([0, 1]);
        expect(n2.list).to.equal(null);
        expect(n2.next).to.equal(null);
        expect(n2.prev).to.equal(null);
        expect(n2.value).to.equal(3);

        let n3 = find(list.nodes(), n => n.value === 0)!;
        list.removeNode(n3);
        expect(list.isEmpty).to.equal(false);
        expect(list.length).to.equal(1);
        expect(list.first).to.equal(1);
        expect(list.last).to.equal(1);
        expect(toArray(list)).to.deep.equal([1]);
        expect(n3.list).to.equal(null);
        expect(n3.next).to.equal(null);
        expect(n3.prev).to.equal(null);
        expect(n3.value).to.equal(0);

        let n4 = find(list.nodes(), n => n.value === 1)!;
        list.removeNode(n4);
        expect(list.isEmpty).to.equal(true);
        expect(list.length).to.equal(0);
        expect(list.first).to.equal(undefined);
        expect(list.last).to.equal(undefined);
        expect(toArray(list)).to.deep.equal([]);
        expect(n4.list).to.equal(null);
        expect(n4.next).to.equal(null);
        expect(n4.prev).to.equal(null);
        expect(n4.value).to.equal(1);
      });
開發者ID:afshin,項目名稱:phosphor,代碼行數:57,代碼來源:linkedlist.spec.ts

示例2: find

 editorTracker.forEach(file => {
   const model = find(models, m => file.context.path === m.path);
   if (model) {
     const oldSession = activeSessions[file.id];
     // If there is a matching path, but it is the same
     // session as we previously had, do nothing.
     if (oldSession && oldSession.id === model.id) {
       return;
     }
     // Otherwise, dispose of the old session and reset to
     // a new CompletionConnector.
     if (oldSession) {
       delete activeSessions[file.id];
       oldSession.dispose();
     }
     const session = sessions.connectTo(model);
     activeSessions[file.id] = session;
   } else {
     const session = activeSessions[file.id];
     if (session) {
       session.dispose();
       delete activeSessions[file.id];
     }
   }
 });
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:25,代碼來源:index.ts

示例3: createNew

  /**
   * Create a new extension object.
   */
  createNew(nb: NotebookPanel, context: DocumentRegistry.IContext<INotebookModel>): IDisposable {
    // Create extension here

    // Add buttons to toolbar
    let buttons: ToolbarButton[] = [];
    let insertionPoint = -1;
    find(nb.toolbar.children(), (tbb, index) => {
      if (tbb.hasClass('jp-Notebook-toolbarCellType')) {
        insertionPoint = index;
        return true;
      }
      return false;
    });
    let i = 1;
    for (let id of [CommandIDs.diffNotebookCheckpoint, CommandIDs.diffNotebookGit]) {
      let button = Toolbar.createFromCommand(this.commands, id);
      if (button === null) {
        throw new Error('Cannot create button, command not registered!');
      }
      if (insertionPoint >= 0) {
        nb.toolbar.insertItem(insertionPoint + i++, this.commands.label(id), button);
      } else {
        nb.toolbar.addItem(this.commands.label(id), button);
      }
      buttons.push(button);
    }


    return new DisposableDelegate(() => {
      // Cleanup extension here
      for (let btn of buttons) {
        btn.dispose();
      }
    });
  }
開發者ID:vidartf,項目名稱:nbdime,代碼行數:38,代碼來源:plugin.ts

示例4: find

  (states, position: IColumnPosition): number => {
    const columnState: IColumnState = find(states,(stateItem: IColumnState) => (
      stateItem.position.region === position.region && stateItem.position.value === position.value
    ));

    return columnState.index;
  }
開發者ID:twosigma,項目名稱:beaker-notebook,代碼行數:7,代碼來源:selectors.ts

示例5: find

 const onRunningChanged = (
   sender: Session.IManager,
   models: Session.IModel[]
 ) => {
   const oldSession = activeSessions[widget.id];
   // Search for a matching path.
   const model = find(models, m => m.path === widget.context.path);
   if (model) {
     // If there is a matching path, but it is the same
     // session as we previously had, do nothing.
     if (oldSession && oldSession.id === model.id) {
       return;
     }
     // Otherwise, dispose of the old session and reset to
     // a new CompletionConnector.
     if (oldSession) {
       delete activeSessions[widget.id];
       oldSession.dispose();
     }
     const session = sessions.connectTo(model);
     handler.connector = new CompletionConnector({ session, editor });
     activeSessions[widget.id] = session;
   } else {
     // If we didn't find a match, make sure
     // the connector is the contextConnector and
     // dispose of any previous connection.
     handler.connector = contextConnector;
     if (oldSession) {
       delete activeSessions[widget.id];
       oldSession.dispose();
     }
   }
 };
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:33,代碼來源:index.ts

示例6: it

 it('should add a new menu', () => {
   const menu = new Menu({ commands });
   mainMenu.addMenu(menu);
   expect(find(mainMenu.menus, m => menu === m) !== undefined).to.equal(
     true
   );
 });
開發者ID:willingc,項目名稱:jupyterlab,代碼行數:7,代碼來源:mainmenu.spec.ts

示例7: findConnection

 /**
  * Find a connection which matches the given parameters.
  */
 function findConnection(connections: IConnection[], signal: Signal<any, any>, slot: Slot<any, any>, thisArg: any): IConnection | undefined {
   return find(connections, connection => (
     connection.signal === signal &&
     connection.slot === slot &&
     connection.thisArg === thisArg
   ));
 }
開發者ID:afshin,項目名稱:phosphor,代碼行數:10,代碼來源:index.ts

示例8: find

 return manager.ready.then(() => {
   let model = find(manager.sessions.running(), item => {
     return item.path === path;
   });
   if (model) {
     return createConsole(args);
   }
 });
開發者ID:samvasko,項目名稱:jupyterlab,代碼行數:8,代碼來源:index.ts

示例9: return

 return () => {
   let widget = app.shell.currentWidget;
   const extender = find(s, value => value.tracker.has(widget));
   return (
     !!extender &&
     !!extender[executor] &&
     (extender.isEnabled ? extender.isEnabled(widget) : true)
   );
 };
開發者ID:ellisonbg,項目名稱:jupyterlab,代碼行數:9,代碼來源:index.ts

示例10: find

 return manager.ready.then(() => {
   let model = find(manager.sessions.running(), item => {
     return item.path === path;
   });
   if (model) {
     return createConsole(args);
   }
   return Promise.reject(`No running kernel session for path: ${path}`);
 });
開發者ID:SylvainCorlay,項目名稱:jupyterlab,代碼行數:9,代碼來源:index.ts


注:本文中的@phosphor/algorithm.find函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。