protobufjs 7.2.4 → 7.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "protobufjs",
3
- "version": "7.2.4",
3
+ "version": "7.2.6",
4
4
  "versionScheme": "~",
5
5
  "description": "Protocol Buffers for JavaScript (& TypeScript).",
6
6
  "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
package/src/converter.js CHANGED
@@ -62,7 +62,7 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
62
62
  break;
63
63
  case "uint64":
64
64
  isUnsigned = true;
65
- // eslint-disable-line no-fallthrough
65
+ // eslint-disable-next-line no-fallthrough
66
66
  case "int64":
67
67
  case "sint64":
68
68
  case "fixed64":
@@ -176,7 +176,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
176
176
  break;
177
177
  case "uint64":
178
178
  isUnsigned = true;
179
- // eslint-disable-line no-fallthrough
179
+ // eslint-disable-next-line no-fallthrough
180
180
  case "int64":
181
181
  case "sint64":
182
182
  case "fixed64":
package/src/parse.js CHANGED
@@ -227,7 +227,7 @@ function parse(source, root, options) {
227
227
  break;
228
228
  case "public":
229
229
  next();
230
- // eslint-disable-line no-fallthrough
230
+ // eslint-disable-next-line no-fallthrough
231
231
  default:
232
232
  whichImports = imports || (imports = []);
233
233
  break;
@@ -621,6 +621,9 @@ function parse(source, root, options) {
621
621
  if (!nameRe.test(token = next())) {
622
622
  throw illegal(token, "name");
623
623
  }
624
+ if (token === null) {
625
+ throw illegal(token, "end of input");
626
+ }
624
627
 
625
628
  var value;
626
629
  var propName = token;
package/src/reader.js CHANGED
@@ -312,9 +312,14 @@ Reader.prototype.bytes = function read_bytes() {
312
312
  this.pos += length;
313
313
  if (Array.isArray(this.buf)) // plain array
314
314
  return this.buf.slice(start, end);
315
- return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1
316
- ? new this.buf.constructor(0)
317
- : this._slice.call(this.buf, start, end);
315
+
316
+ if (start === end) { // fix for IE 10/Win8 and others' subarray returning array of size 1
317
+ var nativeBuffer = util.Buffer;
318
+ return nativeBuffer
319
+ ? nativeBuffer.alloc(0)
320
+ : new this.buf.constructor(0);
321
+ }
322
+ return this._slice.call(this.buf, start, end);
318
323
  };
319
324
 
320
325
  /**
package/src/root.js CHANGED
@@ -98,10 +98,10 @@ Root.prototype.load = function load(filename, options, callback) {
98
98
  /* istanbul ignore if */
99
99
  if (!callback)
100
100
  return;
101
- var cb = callback;
102
- callback = null;
103
101
  if (sync)
104
102
  throw err;
103
+ var cb = callback;
104
+ callback = null;
105
105
  cb(err, root);
106
106
  }
107
107
 
package/src/tokenize.js CHANGED
@@ -197,9 +197,7 @@ function tokenize(source, alternateCommentMode) {
197
197
 
198
198
  // see if remaining line matches comment pattern
199
199
  var lineText = source.substring(startOffset, endOffset);
200
- // look for 1 or 2 slashes since startOffset would already point past
201
- // the first slash that started the comment.
202
- var isComment = /^\s*\/{1,2}/.test(lineText);
200
+ var isComment = /^\s*\/\//.test(lineText);
203
201
  return isComment;
204
202
  }
205
203
 
@@ -268,7 +266,7 @@ function tokenize(source, alternateCommentMode) {
268
266
  // check for double-slash comments, consolidating consecutive lines
269
267
  start = offset;
270
268
  isDoc = false;
271
- if (isDoubleSlashCommentLine(offset)) {
269
+ if (isDoubleSlashCommentLine(offset - 1)) {
272
270
  isDoc = true;
273
271
  do {
274
272
  offset = findEndOfLine(offset);