Permalink
Browse files

New: Reader.create asserts that `buffer` is a valid buffer, see #695

  • Loading branch information...
dcodeIO committed Mar 4, 2017
1 parent 4b21e00 commit 2b5577b238a452ae86aa395fb2ad3a3f45d755dc

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN +31 Bytes (100%) dist/light/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN +33 Bytes (100%) dist/minimal/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN +7 Bytes (100%) dist/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,6 +1,6 @@
{
"name": "protobufjs",
"version": "6.6.5",
"version": "6.7.0",
"versionScheme": "~",
"description": "Protocol Buffers for JavaScript (& TypeScript).",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
@@ -87,7 +87,7 @@
"tape": "^4.6.3",
"tmp": "0.0.31",
"typescript": "^2.2.1",
"uglify-js": "^2.7.5",
"uglify-js": "^2.8.4",
"vinyl-buffer": "^1.0.0",
"vinyl-fs": "^2.4.4",
"vinyl-source-stream": "^1.1.0"
@@ -40,6 +40,18 @@ function Reader(buffer) {
this.len = buffer.length;
}
var create_array = typeof Uint8Array !== "undefined"
? function create_typed_array(buffer) {
if (buffer instanceof Uint8Array || Array.isArray(buffer))
return new Reader(buffer);
throw Error("illegal buffer");
}
: function create_array(buffer) {
if (Array.isArray(buffer))
return new Reader(buffer);
throw Error("illegal buffer");
};
/**
* Creates a new reader using the specified buffer.
* @function
@@ -51,13 +63,12 @@ Reader.create = util.Buffer
return (Reader.create = function create_buffer(buffer) {
return util.Buffer.isBuffer(buffer)
? new BufferReader(buffer)
: new Reader(buffer);
/* istanbul ignore next */
: create_array(buffer);
})(buffer);
}
/* istanbul ignore next */
: function create_array(buffer) {
return new Reader(buffer);
};
: create_array;
Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice;

0 comments on commit 2b5577b

Please sign in to comment.