Class WebUSB

Implements

  • USB

Constructors

Properties

authorisedDevices: Set<USBDeviceFilter> = ...
emitter: EventEmitter<DefaultEventMap> = ...
knownDevices: Map<Device, WebUSBDevice> = ...

Accessors

  • set onconnect(fn): void
  • Parameters

    • fn: ((ev: USBConnectionEvent) => void)
        • (ev): void
        • Parameters

          • ev: USBConnectionEvent

          Returns void

    Returns void

  • set ondisconnect(fn): void
  • Parameters

    • fn: ((ev: USBConnectionEvent) => void)
        • (ev): void
        • Parameters

          • ev: USBConnectionEvent

          Returns void

    Returns void

Methods

  • Parameters

    • type: "connect" | "disconnect"
    • listener: ((this: this, ev: USBConnectionEvent) => void)
        • (this, ev): void
        • Parameters

          • this: this
          • ev: USBConnectionEvent

          Returns void

    Returns void

  • Parameters

    • type: "connect" | "disconnect"
    • listener: EventListener

    Returns void

  • Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

    MDN Reference

    Parameters

    • _event: Event

    Returns boolean

  • Gets all allowed Web USB devices which are connected

    Returns Promise<USBDevice[]>

    Promise containing an array of devices

  • Parameters

    • type: "connect" | "disconnect"
    • callback: ((this: this, ev: USBConnectionEvent) => void)
        • (this, ev): void
        • Parameters

          • this: this
          • ev: USBConnectionEvent

          Returns void

    Returns void

  • Parameters

    • type: "connect" | "disconnect"
    • callback: EventListener

    Returns void

  • Requests a single Web USB device

    Parameters

    • Optionaloptions: USBDeviceRequestOptions

      The options to use when scanning

    Returns Promise<USBDevice>

    Promise containing the selected device