• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript algorithm.find函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript algorithm.iter函数代码示例发布时间:2022-05-28
下一篇:
TypeScript algorithm.filter函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap