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