Skip to content

Commit

Permalink
Breaking: Moved camelCase/underScore away from util to where actually…
Browse files Browse the repository at this point in the history
… used
  • Loading branch information
dcodeIO committed Dec 23, 2016
1 parent 4d1f5fa commit a97956b
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 101 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/ea7ba8b83890084d61012cb5386dc11dadfb3908) Fixed release links in README files<br />

## New
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/442471363f99e67fa97044f234a47b3c9b929dfa) Added a noparse build for completeness<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/bfee1cc3624d0fa21f9553c2f6ce2fcf7fcc09b7) Now compresses .gz files using zopfli to make them useful beyond being just a reference<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/aed134aa1cd7edd801de77c736cf5efe6fa61cb0) Updated non-bundled google types folder with missing descriptors and added wrappers to core<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/0b0de2458a1ade1ccd4ceb789697be13290f856b) Replaced the ieee754 implementation for old browsers with a faster, use-case specific one + simple test case<br />
Expand All @@ -39,6 +40,7 @@
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/99ad9cc08721b834a197d4bbb67fa152d7ad79aa) Made pbjs use loadSync for deterministic outputs, see [#573](https://github.com/dcodeIO/protobuf.js/issues/573)<br />

## Docs
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/4d1f5facfcaaf5f2ab6a70b12443ff1b66e7b94e) Updated documentation on runtime and noparse builds<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/c59647a7542cbc4292248787e5f32bb99a9b8d46) Fixed an issue with the changelog generator skipping some commits<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/24f2c03af9f13f5404259866fdc8fed33bfaae25) Added notes on how to use pbjs and pbts programmatically<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/3544576116146b209246d71c7f7a9ed687950b26) Manually sorted old changelog entries<br />
Expand All @@ -47,6 +49,8 @@
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/7939a4bd8baca5f7e07530fc93f27911a6d91c6f) Updated README and bundler according to dynamic require calls<br />

## Other
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/deb2e82ed7eda41d065a09d120e91c0f7ecf1e6a) Commented out float assertions in float test including explanation<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/d3ebd5745b024033fbc2410ecad4d4e02abd67db) Expose array implementation used with (older) browsers on util for tests<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/b1b6a813c93da4c7459755186aa02ef2f3765c94) Updated test cases<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/99dc5faa7b39fdad8ebc102de4463f8deb7f48ff) Added assumptions to float test case<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/948ca2e3c5c62fedcd918d75539c261abf1a7347) Updated travis config to use C++11<br />
Expand Down
7 changes: 6 additions & 1 deletion cli/targets/proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ var Namespace = protobuf.Namespace,
Method = protobuf.Method,
types = protobuf.types,
util = protobuf.util;
var underScore = protobuf.util.underScore;

function underScore(str) {
return str.substring(0,1)
+ str.substring(1)
.replace(/([A-Z])(?=[a-z]|$)/g, function($0, $1) { return "_" + $1.toLowerCase(); });
}

var out = [];
var indent = 0;
Expand Down
26 changes: 2 additions & 24 deletions dist/noparse/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/noparse/protobuf.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/noparse/protobuf.min.js

Large diffs are not rendered by default.

Binary file modified dist/noparse/protobuf.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/noparse/protobuf.min.js.map

Large diffs are not rendered by default.

34 changes: 9 additions & 25 deletions dist/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/protobuf.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/protobuf.min.js

Large diffs are not rendered by default.

Binary file modified dist/protobuf.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/protobuf.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/runtime/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/runtime/protobuf.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/runtime/protobuf.min.js.gz
Binary file not shown.
8 changes: 7 additions & 1 deletion src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ function lower(token) {
return token === null ? null : token.toLowerCase();
}

function camelCase(str) {
return str.substring(0,1)
+ str.substring(1)
.replace(/_([a-z])(?=[a-z]|$)/g, function($0, $1) { return $1.toUpperCase(); });
}

/**
* Result object returned from {@link parse}.
* @typedef ParserResult
Expand Down Expand Up @@ -82,7 +88,7 @@ function parse(source, root, options) {

var ptr = root;

var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase;
var applyCase = options.keepCase ? function(name) { return name; } : camelCase;

function illegal(token, name) {
var filename = parse.filename;
Expand Down
2 changes: 1 addition & 1 deletion src/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function SYNC() {} // eslint-disable-line no-empty-function
var initParser = function() { // excluded (throws) in noparse builds
try { parse = require("./parse"); } catch (e) {} // eslint-disable-line no-empty
initParser = null;
}
};

/**
* Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.
Expand Down
22 changes: 0 additions & 22 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,6 @@ util.safeProp = function safeProp(prop) {
return "[\"" + prop.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"]";
};

/**
* Converts a string to camel case notation.
* @param {string} str String to convert
* @returns {string} Converted string
*/
util.camelCase = function camelCase(str) {
return str.substring(0,1)
+ str.substring(1)
.replace(/_([a-z])(?=[a-z]|$)/g, function($0, $1) { return $1.toUpperCase(); });
};

/**
* Converts a string to underscore notation.
* @param {string} str String to convert
* @returns {string} Converted string
*/
util.underScore = function underScore(str) {
return str.substring(0,1)
+ str.substring(1)
.replace(/([A-Z])(?=[a-z]|$)/g, function($0, $1) { return "_" + $1.toLowerCase(); });
};

/**
* Converts the second character of a string to lower case.
* @param {string} str String to convert
Expand Down
16 changes: 1 addition & 15 deletions types/protobuf.js.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// $> pbts --name protobufjs --out types/protobuf.js.d.ts src
// Generated Thu, 22 Dec 2016 22:48:48 UTC
// Generated Fri, 23 Dec 2016 11:04:01 UTC
declare module "protobufjs" {

/**
Expand Down Expand Up @@ -2353,20 +2353,6 @@ declare module "protobufjs" {
*/
function safeProp(prop: string): string;

/**
* Converts a string to camel case notation.
* @param {string} str String to convert
* @returns {string} Converted string
*/
function camelCase(str: string): string;

/**
* Converts a string to underscore notation.
* @param {string} str String to convert
* @returns {string} Converted string
*/
function underScore(str: string): string;

/**
* Converts the second character of a string to lower case.
* @param {string} str String to convert
Expand Down

0 comments on commit a97956b

Please sign in to comment.