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.1.1 to 0.2.0

test/files/Physical-Representations-of-Data.png

12

index.js

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

this.buffer = buffer || new Buffer(0);
this.pointer = 0; //
this.pointer = 0;
this.isGIF = false;
}

@@ -30,2 +31,9 @@

;
if (this.buffer.length > 4)
this.isGIF = this.buffer.slice(0, 3).toString() === 'GIF';
if (this.isGIF === false)
return next();
if (result.animated)

@@ -39,2 +47,4 @@ this.emit('animated');

buffer = Buffer.isBuffer(buffer) ? buffer : new Buffer(buffer);
if (buffer.slice(0, 3).toString() !== 'GIF')
return false;
return isAnimated(buffer).animated;

@@ -41,0 +51,0 @@ };

2

package.json
{
"name": "animated-gif-detector",
"version": "0.1.1",
"version": "0.2.0",
"description": "Detect animated GIFs from JavaScript buffers.",

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

@@ -93,4 +93,4 @@ var path = require('path')

test('sync => false (non-GIF)', function(t) {
var filePath = path.join(process.cwd(), 'test', 'files', '240px-Felis_silvestris_silvestris_small_gradual_decrease_of_quality.png');
test('sync => false (non-GIF: PNG)', function(t) {
var filePath = path.join(process.cwd(), 'test', 'files', 'Physical-Representations-of-Data.png');
var buffer = fs.readFileSync(filePath);

@@ -101,2 +101,16 @@ t.notOk(new A().sync(buffer), 'is NOT animated');

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

@@ -103,0 +117,0 @@ var filePath = path.join(process.cwd(), 'test', 'files', 'file.txt');

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