Comparing version 1.0.0 to 2.0.0
10
index.js
'use strict'; | ||
module.exports = function (buf) { | ||
if (!buf || buf.length < 3) { | ||
return false; | ||
} | ||
const fileType = require('file-type'); | ||
return buf[0] === 71 && | ||
buf[1] === 73 && | ||
buf[2] === 70; | ||
}; | ||
module.exports = input => fileType(input).ext === 'gif'; |
{ | ||
"name": "is-gif", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Check if a Buffer/Uint8Array is a GIF image", | ||
@@ -10,9 +10,9 @@ "license": "MIT", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "http://sindresorhus.com" | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "xo && ava" | ||
}, | ||
@@ -40,5 +40,8 @@ "files": [ | ||
"devDependencies": { | ||
"mocha": "*", | ||
"read-chunk": "^1.0.0" | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"dependencies": { | ||
"file-type": "^7.4.0" | ||
} | ||
} |
@@ -5,10 +5,8 @@ # is-gif [![Build Status](https://travis-ci.org/sindresorhus/is-gif.svg?branch=master)](https://travis-ci.org/sindresorhus/is-gif) | ||
Used by [image-type](https://github.com/sindresorhus/image-type). | ||
## Install | ||
```sh | ||
$ npm install --save is-gif | ||
``` | ||
$ npm install is-gif | ||
``` | ||
@@ -18,9 +16,7 @@ | ||
##### Node.js | ||
```js | ||
var readChunk = require('read-chunk'); // npm install read-chunk | ||
var isGif = require('is-gif'); | ||
var buffer = readChunk.sync('unicorn.gif', 0, 3); | ||
const readChunk = require('read-chunk'); | ||
const isGif = require('is-gif'); | ||
const buffer = readChunk.sync('unicorn.gif', 0, 3); | ||
isGif(buffer); | ||
@@ -30,25 +26,17 @@ //=> true | ||
##### Browser | ||
```js | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open('GET', 'unicorn.gif'); | ||
xhr.responseType = 'arraybuffer'; | ||
## API | ||
xhr.onload = function () { | ||
isGif(new Uint8Array(this.response)); | ||
//=> true | ||
}; | ||
### isGif(input) | ||
xhr.send(); | ||
``` | ||
#### input | ||
Type: `Buffer` `Uint8Array` | ||
## API | ||
It only needs the first 3 bytes. | ||
### isGif(buffer) | ||
Accepts a Buffer (Node.js) or Uint8Array. | ||
## Related | ||
It only needs the first 3 bytes. | ||
- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array | ||
@@ -58,2 +46,2 @@ | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2683
4
1
3
44
+ Addedfile-type@^7.4.0
+ Addedfile-type@7.7.1(transitive)