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


TypeScript array.any函数代码示例

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


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

示例1: _init_tools

  _init_tools() {
    for (const tool of this.tools) {
      if (tool instanceof InspectTool) {
        if (!any(this.inspectors, t => t.id === tool.id))
          this.inspectors = this.inspectors.concat([tool]);
      } else if (tool instanceof HelpTool) {
        if (!any(this.help, t => t.id === tool.id))
          this.help = this.help.concat([tool]);
      } else if (tool instanceof ActionTool) {
        if (!any(this.actions, t => t.id === tool.id))
          this.actions = this.actions.concat([tool]);
      } else if (tool instanceof GestureTool) {
        let event_types = tool.event_type
        let multi = true
        if (typeof event_types === "string") {
          event_types = [event_types]
          multi = false
        }

        for (let et of event_types) {
          if (!(et in this.gestures)) {
            logger.warn(`Toolbar: unknown event type '${et}' for tool: ${tool.type} (${tool.id})`)
            continue
          }

          if (multi)
            et = "multi"

          if (!any(this.gestures[et].tools, t => t.id === tool.id))
            this.gestures[et].tools = this.gestures[et].tools.concat([tool]);
        }
      }
    }
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:34,代码来源:toolbar_box.ts

示例2: get_scroll_index

  get_scroll_index(grid_range, selected_indices) {
    if (!this.scroll_to_selection || (selected_indices.length === 0)) {
      return null;
    }

    if (!any(selected_indices, i => grid_range.top <= i && i <= grid_range.bottom)) {
      return Math.max(0, Math.min(...selected_indices || []) - 1);
    }

    return null;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:11,代码来源:data_table.ts

示例3: _init_tools

  protected _init_tools(): void {
    for (const tool of this.tools) {
      if (tool instanceof InspectTool) {
        if (!any(this.inspectors, (t) => t.id == tool.id))
          this.inspectors = this.inspectors.concat([tool])
      } else if (tool instanceof HelpTool) {
        if (!any(this.help, (t) => t.id == tool.id))
          this.help = this.help.concat([tool])
      } else if (tool instanceof ActionTool) {
        if (!any(this.actions, (t) => t.id == tool.id))
          this.actions = this.actions.concat([tool])
      } else if (tool instanceof GestureTool) {
        let event_types: GestureType[]
        let multi: boolean
        if (isString(tool.event_type)) {
          event_types = [tool.event_type]
          multi = false
        } else {
          event_types = tool.event_type || []
          multi = true
        }

        for (let et of event_types) {
          if (!(et in this.gestures)) {
            logger.warn(`Toolbar: unknown event type '${et}' for tool: ${tool.type} (${tool.id})`)
            continue
          }

          if (multi)
            et = "multi"

          if (!any(this.gestures[et].tools, (t) => t.id == tool.id))
            this.gestures[et].tools = this.gestures[et].tools.concat([tool])
        }
      }
    }
  }
开发者ID:Zyell,项目名称:bokeh,代码行数:37,代码来源:toolbar_box.ts

示例4: _init_tools

  _init_tools() {
    for (const tool of this.tools) {
      if (tool instanceof InspectTool) {
        if (!any(this.inspectors, t => t.id === tool.id)) {
          this.inspectors = this.inspectors.concat([tool]);
        }
      } else if (tool instanceof HelpTool) {
        if (!any(this.help, t => t.id === tool.id)) {
          this.help = this.help.concat([tool]);
        }
      } else if (tool instanceof ActionTool) {
        if (!any(this.actions, t => t.id === tool.id)) {
          this.actions = this.actions.concat([tool]);
        }
      } else if (tool instanceof GestureTool) {
        let event_types = tool.event_type;
        let multi = true;
        if (typeof event_types === 'string') {
          event_types = [event_types];
          multi = false;
        }

        for (let et of event_types) {
          if (!(et in this.gestures)) {
            logger.warn(`Toolbar: unknown event type '${et}' for tool: ${tool.type} (${tool.id})`);
            continue;
          }

          if (multi)
            et = "multi"

          if (!any(this.gestures[et].tools, t => t.id === tool.id))
            this.gestures[et].tools = this.gestures[et].tools.concat([tool]);

          this.connect(tool.properties.active.change, this._active_change.bind(this, tool));
        }
      }
    }

    if (this.active_inspect === 'auto') {
      // do nothing as all tools are active be default

    } else if (this.active_inspect instanceof InspectTool) {
      this.inspectors.map(inspector => { if (inspector !== this.active_inspect) { return inspector.active = false; } });
    } else if (this.active_inspect instanceof Array) {
      this.inspectors.map(inspector => { if (!includes(this.active_inspect, inspector)) { return inspector.active = false; } });
    } else if (this.active_inspect === null) {
      this.inspectors.map(inspector => inspector.active = false);
    }

    const _activate_gesture = tool => {
      if (tool.active) {
        // tool was activated by a proxy, but we need to finish configuration manually
        return this._active_change(tool);
      } else {
        return tool.active = true;
      }
    };

    for (const et in this.gestures) {
      const { tools } = this.gestures[et];
      if (tools.length === 0) {
        continue;
      }
      this.gestures[et].tools = sortBy(tools, tool => tool.default_order);

      if (et === 'tap') {
        if (this.active_tap === null) {
          continue;
        }
        if (this.active_tap === 'auto') {
          _activate_gesture(this.gestures[et].tools[0]);
        } else {
          _activate_gesture(this.active_tap);
        }
      }

      if (et === 'pan') {
        if (this.active_drag === null) {
          continue;
        }
        if (this.active_drag === 'auto') {
          _activate_gesture(this.gestures[et].tools[0]);
        } else {
          _activate_gesture(this.active_drag);
        }
      }

      if (et == 'pinch' || et == 'scroll') {
        if ((this.active_scroll === null) || (this.active_scroll === 'auto')) {
          continue;
        }
        _activate_gesture(this.active_scroll);
      }
    }

    return null;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:98,代码来源:toolbar.ts

示例5: _init_tools

  protected _init_tools(): void {
    for (const tool of this.tools) {
      if (tool instanceof InspectTool) {
        if (!any(this.inspectors, (t) => t.id == tool.id)) {
          this.inspectors = this.inspectors.concat([tool])
        }
      } else if (tool instanceof HelpTool) {
        if (!any(this.help, (t) => t.id == tool.id)) {
          this.help = this.help.concat([tool])
        }
      } else if (tool instanceof ActionTool) {
        if (!any(this.actions, (t) => t.id == tool.id)) {
          this.actions = this.actions.concat([tool])
        }
      } else if (tool instanceof GestureTool) {
        let event_types: GestureType[]
        let multi: boolean
        if (isString(tool.event_type)) {
          event_types = [tool.event_type]
          multi = false
        } else {
          event_types = tool.event_type || []
          multi = true
        }

        for (let et of event_types) {
          if (!(et in this.gestures)) {
            logger.warn(`Toolbar: unknown event type '${et}' for tool: ${tool.type} (${tool.id})`)
            continue
          }

          if (multi)
            et = "multi"

          if (!any(this.gestures[et].tools, (t) => t.id == tool.id))
            this.gestures[et].tools = this.gestures[et].tools.concat([tool])

          this.connect(tool.properties.active.change, this._active_change.bind(this, tool))
        }
      }
    }

    if (this.active_inspect == 'auto') {
      // do nothing as all tools are active be default
    } else if (this.active_inspect instanceof InspectTool) {
      for (const inspector of this.inspectors) {
        if (inspector != this.active_inspect)
          inspector.active = false
      }
    } else if (isArray(this.active_inspect)) {
      for (const inspector of this.inspectors) {
        if (!includes(this.active_inspect, inspector))
          inspector.active = false
      }
    } else if (this.active_inspect == null) {
      for (const inspector of this.inspectors)
        inspector.active = false
    }

    const _activate_gesture = (tool: Tool) => {
      if (tool.active) {
        // tool was activated by a proxy, but we need to finish configuration manually
        this._active_change(tool)
      } else
        tool.active = true
    }

    for (const et in this.gestures) {
      const gesture = this.gestures[et as GestureType]

      if (gesture.tools.length == 0)
        continue

      gesture.tools = sortBy(gesture.tools, (tool) => tool.default_order)

      if (et == 'tap') {
        if (this.active_tap == null)
          continue

        if (this.active_tap == 'auto')
          _activate_gesture(gesture.tools[0])
        else
          _activate_gesture(this.active_tap)
      }

      if (et == 'pan') {
        if (this.active_drag == null)
          continue

        if (this.active_drag == 'auto')
          _activate_gesture(gesture.tools[0])
        else
          _activate_gesture(this.active_drag)
      }

      if (et == 'pinch' || et == 'scroll') {
        if (this.active_scroll == null || this.active_scroll == 'auto')
          continue
        _activate_gesture(this.active_scroll)
      }
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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