是webp
检查Buffer / Uint8Array是否为映像
安装
$ npm install is-webp
用法
Node.js
const readChunk = require ( 'read-chunk' ) ;
const isWebp = require ( 'is-webp' ) ;
const buffer = readChunk . sync ( 'unicorn.webp' , 0 , 12 ) ;
isWebp ( buffer ) ;
//=> true
浏览器
const xhr = new XMLHttpRequest ( ) ;
xhr . open ( 'GET' , 'unicorn.webp' ) ;
xhr . responseType = 'arraybuffer' ;
xhr . onload = ( ) => {
isWebp
评论0
最新资源