【文件属性】:
文件名称:is-webp:检查BufferUint8Array是否为WebP图像
文件大小:63KB
文件格式:ZIP
更新时间:2021-05-26 08:04:56
JavaScript
是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
【文件预览】:
is-webp-main
----.gitattributes(29B)
----.github()
--------workflows()
----test.js(251B)
----license(1KB)
----fixture.png(53KB)
----.npmrc(19B)
----.editorconfig(175B)
----.gitignore(23B)
----index.js(198B)
----readme.md(980B)
----package.json(678B)
----fixture.webp(6KB)