[Pkg-javascript-commits] [node-has-binary] 02/06: Imported Upstream version 0.1.7
Paolo Greppi
paolog-guest at moszumanska.debian.org
Fri Dec 16 08:27:17 UTC 2016
This is an automated email from the git hooks/post-receive script.
paolog-guest pushed a commit to branch master
in repository node-has-binary.
commit 5cbf1c1ca74be2286688e7ff1e16f0e46439d6cc
Author: Paolo Greppi <paolo.greppi at libpf.com>
Date: Fri Dec 16 09:10:06 2016 +0100
Imported Upstream version 0.1.7
---
.npmignore => .gitignore | 0
History.md | 8 ++++++++
fixtures/big.json | 1 -
index.js | 5 +++--
package.json | 4 ++--
test.js | 39 ++-------------------------------------
6 files changed, 15 insertions(+), 42 deletions(-)
diff --git a/.npmignore b/.gitignore
similarity index 100%
rename from .npmignore
rename to .gitignore
diff --git a/History.md b/History.md
index a1e3867..9a5f2e8 100644
--- a/History.md
+++ b/History.md
@@ -1,4 +1,12 @@
+0.1.7 / 2015-11-18
+==================
+
+ * fix toJSON [@jderuere]
+ * fix `global.isBuffer` usage [@tonetheman]
+ * fix tests on modern versions of node
+ * bump mocha
+
0.1.6 / 2015-01-24
==================
diff --git a/fixtures/big.json b/fixtures/big.json
deleted file mode 100644
index 3172879..0000000
--- a/fixtures/big.json
+++ /dev/null
@@ -1 +0,0 @@
-{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{"k":{" [...]
diff --git a/index.js b/index.js
index 7684d23..434ccfa 100644
--- a/index.js
+++ b/index.js
@@ -25,7 +25,7 @@ function hasBinary(data) {
function _hasBinary(obj) {
if (!obj) return false;
- if ( (global.Buffer && global.Buffer.isBuffer(obj)) ||
+ if ( (global.Buffer && global.Buffer.isBuffer && global.Buffer.isBuffer(obj)) ||
(global.ArrayBuffer && obj instanceof ArrayBuffer) ||
(global.Blob && obj instanceof Blob) ||
(global.File && obj instanceof File)
@@ -40,7 +40,8 @@ function hasBinary(data) {
}
}
} else if (obj && 'object' == typeof obj) {
- if (obj.toJSON) {
+ // see: https://github.com/Automattic/has-binary/pull/4
+ if (obj.toJSON && 'function' == typeof obj.toJSON) {
obj = obj.toJSON();
}
diff --git a/package.json b/package.json
index 111c225..8a19661 100644
--- a/package.json
+++ b/package.json
@@ -1,13 +1,13 @@
{
"name": "has-binary",
- "version": "0.1.6",
+ "version": "0.1.7",
"description": "A function that takes anything in javascript and returns true if its argument contains binary data.",
"dependencies": {
"isarray": "0.0.1"
},
"devDependencies": {
"better-assert": "1.0.0",
- "mocha": "1.17.1"
+ "mocha": "2.3.4"
},
"author": "Kevin Roark",
"license": "MIT"
diff --git a/test.js b/test.js
index 5320d4f..c6bd5aa 100644
--- a/test.js
+++ b/test.js
@@ -3,8 +3,6 @@ var hasBinary = require('./');
var assert = require('better-assert');
var fs = require('fs');
-var start = new Date();
-
describe('has-binarydata', function(){
it('should work with buffer', function(){
@@ -22,12 +20,12 @@ describe('has-binarydata', function(){
});
it('should work with an object that does not contain binary', function() {
- var ob = {a: 'a', b: [], c: 1234};
+ var ob = {a: 'a', b: [], c: 1234, toJSON: '{\"a\": \"a\"}'};
assert(!hasBinary(ob));
});
it('should work with an object that contains a buffer', function() {
- var ob = {a: 'a', b: new Buffer('abc'), c: 1234};
+ var ob = {a: 'a', b: new Buffer('abc'), c: 1234, toJSON: '{\"a\": \"a\"}'};
assert(hasBinary(ob));
});
@@ -60,33 +58,6 @@ describe('has-binarydata', function(){
assert(hasBinary(ob));
});
- it('should handle a very large json object with no binary', function(done) {
- this.timeout();
- fs.readFile(__dirname + '/fixtures/big.json', function(err, data) {
- if (err) {
- console.log(err);
- assert(false);
- }
- data = JSON.parse(data);
- assert(!hasBinary(data));
- done();
- });
- });
-
- it('should handle a very large json object with binary', function(done) {
- this.timeout();
- fs.readFile(__dirname + '/fixtures/big.json', function(err, data) {
- if (err) {
- console.log(err);
- assert(false);
- }
- var ob = JSON.parse(data);
- ob.bin = {bin: {bin: {bin: new Buffer('abc')}}};
- assert(hasBinary(ob));
- done();
- });
- });
-
if (global.ArrayBuffer) {
it('should work with an ArrayBuffer', function() {
assert(hasBinary(new ArrayBuffer()));
@@ -99,10 +70,4 @@ describe('has-binarydata', function(){
});
}
- it('should print the test time', function() {
- var end = new Date();
- var diff = end - start;
- console.log('\ntest time: ' + diff + ' ms');
- });
-
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-has-binary.git
More information about the Pkg-javascript-commits
mailing list