Detalhes do pacote

is-dom-image

Jam311MIT1.0.0

test whether an object is a DOM image or canvas

image, dom, is, element

readme (leia-me)

is-dom-image

frozen

Returns true if the element is a DOM image, video, canvas, or ImageData.

These are the same image types supported by the WebGL 1.0 Spec.

Runs in Node and the Browser.

Example

var isDOMImage = require('is-dom-image')

if (isDOMImage(data)) {
  // got an image
  console.log(data.width, data.height)
}

Install

npm install is-dom-image --save

Usage

NPM

isDOMImage(element)

Returns true if element is an instance of HTMLImageElement, HTMLVideoElement, HTMLCanvasElement or ImageData. Otherwise returns false.

License

MIT, see LICENSE.md for details.