Skip to content

Commit

Permalink
New: Added global ParseOptions#keepCase fallback as protobuf.parse.ke…
Browse files Browse the repository at this point in the history
…epCase, see #608
  • Loading branch information
dcodeIO committed Jan 3, 2017
1 parent 1a3effd commit a4d6a2a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/parse.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"use strict";
module.exports = parse;

parse.keepCase = false;

var tokenize = require("./tokenize"),
Root = require("./root"),
Type = require("./type"),
Expand Down Expand Up @@ -61,14 +63,16 @@ function camelCase(str) {
* @param {ParseOptions} [options] Parse options
* @returns {ParserResult} Parser result
* @property {string} filename=null Currently processing file name for error reporting, if known
* @property {boolean} keepCase=false When set to `true`, always keeps field casing instead of converting to camel case when no {@link ParseOptions} are specified
*/
function parse(source, root, options) {
/* eslint-disable callback-return */
if (!(root instanceof Root)) {
options = root;
root = new Root();
options = root || {};
} else if (!options)
options = {};
}
if (!options)
options = { keepCase: parse.keepCase };

var tn = tokenize(source),
next = tn.next,
Expand Down

0 comments on commit a4d6a2a

Please sign in to comment.