Skip to content

Commit a4d6a2a

Browse files
committed
New: Added global ParseOptions#keepCase fallback as protobuf.parse.keepCase, see #608
1 parent 1a3effd commit a4d6a2a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/parse.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"use strict";
22
module.exports = parse;
33

4+
parse.keepCase = false;
5+
46
var tokenize = require("./tokenize"),
57
Root = require("./root"),
68
Type = require("./type"),
@@ -61,14 +63,16 @@ function camelCase(str) {
6163
* @param {ParseOptions} [options] Parse options
6264
* @returns {ParserResult} Parser result
6365
* @property {string} filename=null Currently processing file name for error reporting, if known
66+
* @property {boolean} keepCase=false When set to `true`, always keeps field casing instead of converting to camel case when no {@link ParseOptions} are specified
6467
*/
6568
function parse(source, root, options) {
6669
/* eslint-disable callback-return */
6770
if (!(root instanceof Root)) {
71+
options = root;
6872
root = new Root();
69-
options = root || {};
70-
} else if (!options)
71-
options = {};
73+
}
74+
if (!options)
75+
options = { keepCase: parse.keepCase };
7276

7377
var tn = tokenize(source),
7478
next = tn.next,

0 commit comments

Comments
 (0)