animated-gif-detector
Advanced tools
Comparing version 1.0.0 to 1.1.0
12
index.js
@@ -31,3 +31,5 @@ var Writable = require('stream').Writable | ||
var isAnimated = function(buffer, pointer) { | ||
var result = false; | ||
var result = false | ||
, count = 0 | ||
; | ||
for (var i = 0; i < buffer.length; i++) { | ||
@@ -38,8 +40,10 @@ result = pointer == BLOCK_TERMINATOR.value && | ||
buffer.toString('hex', i + DELAY_TIME.head, i + DELAY_TIME.tail) > DELAY_TIME.value; | ||
pointer = buffer.toString('hex', i, i + 1); | ||
if (result) | ||
count += 1; | ||
if (count > 1) | ||
break; | ||
pointer = buffer.toString('hex', i, i + 1); | ||
} | ||
return { pointer: pointer, animated: result }; | ||
return { pointer: pointer, animated: count > 1 }; | ||
} | ||
@@ -46,0 +50,0 @@ |
{ | ||
"name": "animated-gif-detector", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Detect animated GIFs from JavaScript buffers.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -223,2 +223,15 @@ var path = require('path') | ||
test('generic-header.gif', function(t) { | ||
var file = path.join(process.cwd(), 'test', 'files', 'generic-header.gif') | ||
, result = false | ||
; | ||
fs.createReadStream(file) | ||
.pipe(animated()) | ||
.once('animated', function() { result = true; }) | ||
.on('finish', function() { | ||
t.notOk(result, 'is NOT animated'); | ||
t.end(); | ||
}); | ||
}); | ||
test('sync => true', function(t) { | ||
@@ -225,0 +238,0 @@ var filePath = path.join(process.cwd(), 'test', 'files', 'example.gif'); |
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
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
1549974
26
319