Comparing version 5.0.0-rc19 to 5.0.0
@@ -14,28 +14,2 @@ /* jshint browserify: true */ | ||
// Since there are no utf8 and binary functions on browserify's `Buffer`, we | ||
// must patch in tap methods using the generic slice and write methods. | ||
(function polyfillTap() { | ||
var Tap = require('../../lib/utils').Tap; | ||
Tap.prototype.readString = function () { | ||
var len = this.readLong(); | ||
var pos = this.pos; | ||
var buf = this.buf; | ||
this.pos += len; | ||
if (this.pos > buf.length) { | ||
return; | ||
} | ||
return this.buf.slice(pos, pos + len).toString(); | ||
}; | ||
Tap.prototype.writeBinary = function (s, len) { | ||
var pos = this.pos; | ||
this.pos += len; | ||
if (this.pos > this.buf.length) { | ||
return; | ||
} | ||
this.buf.write(s, pos, len, 'binary'); | ||
}; | ||
})(); | ||
/** Basic parse method, only supporting JSON parsing. */ | ||
@@ -42,0 +16,0 @@ function parse(any, opts) { |
@@ -550,12 +550,27 @@ /* jshint node: true */ | ||
Tap.prototype.readString = function () { | ||
var len = this.readLong(); | ||
var pos = this.pos; | ||
var buf = this.buf; | ||
this.pos += len; | ||
if (this.pos > buf.length) { | ||
return; | ||
} | ||
return this.buf.utf8Slice(pos, pos + len); | ||
}; | ||
/* istanbul ignore else */ | ||
if (typeof Buffer.prototype.utf8Slice == 'function') { | ||
// Use this optimized function when available. | ||
Tap.prototype.readString = function () { | ||
var len = this.readLong(); | ||
var pos = this.pos; | ||
var buf = this.buf; | ||
this.pos += len; | ||
if (this.pos > buf.length) { | ||
return; | ||
} | ||
return this.buf.utf8Slice(pos, pos + len); | ||
}; | ||
} else { | ||
Tap.prototype.readString = function () { | ||
var len = this.readLong(); | ||
var pos = this.pos; | ||
var buf = this.buf; | ||
this.pos += len; | ||
if (this.pos > buf.length) { | ||
return; | ||
} | ||
return this.buf.slice(pos, pos + len).toString(); | ||
}; | ||
} | ||
@@ -602,20 +617,35 @@ Tap.prototype.skipString = function () { | ||
// Helper used to speed up writing defaults. | ||
Tap.prototype.writeBinary = function (str, len) { | ||
var pos = this.pos; | ||
this.pos += len; | ||
if (this.pos > this.buf.length) { | ||
return; | ||
} | ||
/* istanbul ignore else */ | ||
if (this.buf.latin1Write) { | ||
// `binaryWrite` has been renamed to `latin1Write` in Node v6.4.0, see | ||
// https://github.com/nodejs/node/pull/7111. Note that the `'binary'` | ||
// encoding argument still works however. | ||
/* istanbul ignore else */ | ||
if (typeof Buffer.prototype.latin1Write == 'function') { | ||
// `binaryWrite` has been renamed to `latin1Write` in Node v6.4.0, see | ||
// https://github.com/nodejs/node/pull/7111. Note that the `'binary'` | ||
// encoding argument still works however. | ||
Tap.prototype.writeBinary = function (str, len) { | ||
var pos = this.pos; | ||
this.pos += len; | ||
if (this.pos > this.buf.length) { | ||
return; | ||
} | ||
this.buf.latin1Write(str, pos, len); | ||
} else { | ||
}; | ||
} else if (typeof Buffer.prototype.binaryWrite == 'function') { | ||
Tap.prototype.writeBinary = function (str, len) { | ||
var pos = this.pos; | ||
this.pos += len; | ||
if (this.pos > this.buf.length) { | ||
return; | ||
} | ||
this.buf.binaryWrite(str, pos, len); | ||
} | ||
}; | ||
}; | ||
} else { | ||
// Slowest implementation. | ||
Tap.prototype.writeBinary = function (s, len) { | ||
var pos = this.pos; | ||
this.pos += len; | ||
if (this.pos > this.buf.length) { | ||
return; | ||
} | ||
this.buf.write(s, pos, len, 'binary'); | ||
}; | ||
} | ||
@@ -622,0 +652,0 @@ // Binary comparison methods. |
{ | ||
"name": "avsc", | ||
"version": "5.0.0-rc19", | ||
"version": "5.0.0", | ||
"description": "Avro for JavaScript", | ||
@@ -53,3 +53,3 @@ "homepage": "https://github.com/mtth/avsc", | ||
"benchmark": "^2.1.3", | ||
"coveralls": "^2.11.15", | ||
"coveralls": "^2.12.0", | ||
"istanbul": "^0.4.5", | ||
@@ -56,0 +56,0 @@ "mocha": "^3.1.2", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
238180
7431
0