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

animated-gif-detector

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

animated-gif-detector - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

20

index.js

@@ -8,3 +8,3 @@ var Writable = require('stream').Writable

Writable.call(this, options);
this.buffer = buffer || new Buffer(0);
this.buffer = new Buffer(0);
this.pointer = 0;

@@ -44,9 +44,11 @@ this.isGIF = false;

AnimatedGifDetector.prototype.sync = function(buffer) {
buffer = Buffer.isBuffer(buffer) ? buffer : new Buffer(buffer);
if (buffer.slice(0, 3).toString() !== 'GIF')
return false;
return isAnimated(buffer).animated;
};
module.exports = AnimatedGifDetector;
module.exports = function(buffer) {
if (buffer) {
buffer = Buffer.isBuffer(buffer) ? buffer : new Buffer(buffer);
if (buffer.slice(0, 3).toString() !== 'GIF')
return false;
else
return isAnimated(buffer).animated;
}
return new AnimatedGifDetector;
}
{
"name": "animated-gif-detector",
"version": "0.2.0",
"version": "0.3.0",
"description": "Detect animated GIFs from JavaScript buffers.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -21,6 +21,6 @@ animated-gif-detector

var fs = require('fs')
, Animated = require('animated-gif-detector')
, animated = require('animated-gif-detector')
;
fs.createReadStream('file.gif')
.pipe(new Animated)
.pipe(animated())
.on('animated', function() {

@@ -36,6 +36,6 @@ console.log('detected animation!');

var http = require('http')
, Animated = require('animated-gif-detector')
, animated = require('animated-gif-detector')
;
var req = http.get('http://domain.com/file.gif')
.pipe(new Animated)
.pipe(animated())
.once('animated', function() {

@@ -54,6 +54,6 @@ req.abort();

var fs = require('fs')
, Animated = require('animated-gif-detector')
, animated = require('animated-gif-detector')
;
new Animated().sync(fs.readFileSync('file.gif')) // => true!
animated(fs.readFileSync('file.gif')) // => true!
```

@@ -60,0 +60,0 @@

var path = require('path')
, fs = require('fs')
, test = require('tap').test
, A = require(path.join(process.cwd(), 'index'))
, animated = require(path.join(process.cwd(), 'index'))
;
test('ctor', function(t) {
t.ok(new A, 'object is a thing');
t.ok(animated(), 'object is a thing');
t.end();

@@ -14,9 +14,9 @@ });

var file = path.join(process.cwd(), 'test', 'files', 'example.gif')
, animated = false
, result = false
;
fs.createReadStream(file)
.pipe(new A)
.once('animated', function() { animated = true; })
.pipe(animated())
.once('animated', function() { result = true; })
.on('finish', function() {
t.ok(animated, 'is animated');
t.ok(result, 'is animated');
t.end();

@@ -28,9 +28,9 @@ });

var file = path.join(process.cwd(), 'test', 'files', 'GifSample.gif')
, animated = false
, result = false
;
fs.createReadStream(file)
.pipe(new A)
.once('animated', function() { animated = true; })
.pipe(animated())
.once('animated', function() { result = true; })
.on('finish', function() {
t.notOk(animated, 'is NOT animated');
t.notOk(result, 'is NOT animated');
t.end();

@@ -42,9 +42,9 @@ });

var file = path.join(process.cwd(), 'test', 'files', 'Quilt_design_as_46x46_uncompressed_GIF.gif')
, animated = false
, result = false
;
fs.createReadStream(file)
.pipe(new A)
.once('animated', function() { animated = true; })
.pipe(animated())
.once('animated', function() { result = true; })
.on('finish', function() {
t.notOk(animated, 'is NOT animated');
t.notOk(result, 'is NOT animated');
t.end();

@@ -57,9 +57,9 @@ });

var file = path.join(process.cwd(), 'test', 'files', 'SmallFullColourGIF.gif')
, animated = false
, result = false
;
fs.createReadStream(file)
.pipe(new A)
.once('animated', function() { animated = true; })
.pipe(animated())
.once('animated', function() { result = true; })
.on('finish', function() {
t.ok(animated, 'is animated');
t.ok(result, 'is animated');
t.end();

@@ -72,9 +72,9 @@ });

var file = path.join(process.cwd(), 'test', 'files', 'Sunflower_as_gif_websafe.gif')
, animated = false
, result = false
;
fs.createReadStream(file)
.pipe(new A)
.once('animated', function() { animated = true; })
.pipe(animated())
.once('animated', function() { result = true; })
.on('finish', function() {
t.notOk(animated, 'is animated');
t.notOk(result, 'is animated');
t.end();

@@ -87,3 +87,3 @@ });

var buffer = fs.readFileSync(filePath);
t.ok(new A().sync(buffer), 'is animated');
t.ok(animated(buffer), 'is animated');
t.end();

@@ -95,3 +95,3 @@ });

var buffer = fs.readFileSync(filePath);
t.notOk(new A().sync(buffer), 'is NOT animated');
t.notOk(animated(buffer), 'is NOT animated');
t.end();

@@ -103,3 +103,3 @@ });

var buffer = fs.readFileSync(filePath);
t.notOk(new A().sync(buffer), 'is NOT animated');
t.notOk(animated(buffer), 'is NOT animated');
t.end();

@@ -110,9 +110,9 @@ });

var filePath = path.join(process.cwd(), 'test', 'files', 'Physical-Representations-of-Data.png')
, animated = false
, result = false
;
fs.createReadStream(filePath)
.pipe(new A)
.once('animated', function() { animated = true; })
.pipe(animated())
.once('animated', function() { result = true; })
.on('finish', function() {
t.notOk(animated, 'is animated');
t.notOk(result, 'is animated');
t.end();

@@ -126,3 +126,3 @@ })

var buffer = fs.readFileSync(filePath);
t.notOk(new A().sync(buffer), 'is NOT animated');
t.notOk(animated(buffer), 'is NOT animated');
t.end();

@@ -132,4 +132,4 @@ });

test('sync => false (non-buffer)', function(t) {
t.notOk(new A().sync({foo: 'bar' }), 'is NOT animated');
t.notOk(animated({foo: 'bar' }), 'is NOT animated');
t.end();
});
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