Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-gif

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-gif - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

license

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"
}
}

38

readme.md

@@ -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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc