Skip to content

Commit a97956b

Browse files
committed
Breaking: Moved camelCase/underScore away from util to where actually used
1 parent 4d1f5fa commit a97956b

19 files changed

+42
-101
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/ea7ba8b83890084d61012cb5386dc11dadfb3908) Fixed release links in README files<br />
2222

2323
## New
24+
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/442471363f99e67fa97044f234a47b3c9b929dfa) Added a noparse build for completeness<br />
2425
[: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 />
2526
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/aed134aa1cd7edd801de77c736cf5efe6fa61cb0) Updated non-bundled google types folder with missing descriptors and added wrappers to core<br />
2627
[: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 />
@@ -39,6 +40,7 @@
3940
[: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 />
4041

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

4951
## Other
52+
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/deb2e82ed7eda41d065a09d120e91c0f7ecf1e6a) Commented out float assertions in float test including explanation<br />
53+
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/d3ebd5745b024033fbc2410ecad4d4e02abd67db) Expose array implementation used with (older) browsers on util for tests<br />
5054
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/b1b6a813c93da4c7459755186aa02ef2f3765c94) Updated test cases<br />
5155
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/99dc5faa7b39fdad8ebc102de4463f8deb7f48ff) Added assumptions to float test case<br />
5256
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/948ca2e3c5c62fedcd918d75539c261abf1a7347) Updated travis config to use C++11<br />

Diff for: cli/targets/proto.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ var Namespace = protobuf.Namespace,
1414
Method = protobuf.Method,
1515
types = protobuf.types,
1616
util = protobuf.util;
17-
var underScore = protobuf.util.underScore;
17+
18+
function underScore(str) {
19+
return str.substring(0,1)
20+
+ str.substring(1)
21+
.replace(/([A-Z])(?=[a-z]|$)/g, function($0, $1) { return "_" + $1.toLowerCase(); });
22+
}
1823

1924
var out = [];
2025
var indent = 0;

Diff for: dist/noparse/protobuf.js

+2-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/noparse/protobuf.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/noparse/protobuf.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/noparse/protobuf.min.js.gz

-79 Bytes
Binary file not shown.

Diff for: dist/noparse/protobuf.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/protobuf.js

+9-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/protobuf.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/protobuf.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/protobuf.min.js.gz

-50 Bytes
Binary file not shown.

Diff for: dist/protobuf.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/runtime/protobuf.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/runtime/protobuf.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/runtime/protobuf.min.js.gz

0 Bytes
Binary file not shown.

Diff for: src/parse.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ function lower(token) {
2929
return token === null ? null : token.toLowerCase();
3030
}
3131

32+
function camelCase(str) {
33+
return str.substring(0,1)
34+
+ str.substring(1)
35+
.replace(/_([a-z])(?=[a-z]|$)/g, function($0, $1) { return $1.toUpperCase(); });
36+
}
37+
3238
/**
3339
* Result object returned from {@link parse}.
3440
* @typedef ParserResult
@@ -82,7 +88,7 @@ function parse(source, root, options) {
8288

8389
var ptr = root;
8490

85-
var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase;
91+
var applyCase = options.keepCase ? function(name) { return name; } : camelCase;
8692

8793
function illegal(token, name) {
8894
var filename = parse.filename;

Diff for: src/root.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function SYNC() {} // eslint-disable-line no-empty-function
6565
var initParser = function() { // excluded (throws) in noparse builds
6666
try { parse = require("./parse"); } catch (e) {} // eslint-disable-line no-empty
6767
initParser = null;
68-
}
68+
};
6969

7070
/**
7171
* Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.

Diff for: src/util.js

-22
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,6 @@ util.safeProp = function safeProp(prop) {
7272
return "[\"" + prop.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"]";
7373
};
7474

75-
/**
76-
* Converts a string to camel case notation.
77-
* @param {string} str String to convert
78-
* @returns {string} Converted string
79-
*/
80-
util.camelCase = function camelCase(str) {
81-
return str.substring(0,1)
82-
+ str.substring(1)
83-
.replace(/_([a-z])(?=[a-z]|$)/g, function($0, $1) { return $1.toUpperCase(); });
84-
};
85-
86-
/**
87-
* Converts a string to underscore notation.
88-
* @param {string} str String to convert
89-
* @returns {string} Converted string
90-
*/
91-
util.underScore = function underScore(str) {
92-
return str.substring(0,1)
93-
+ str.substring(1)
94-
.replace(/([A-Z])(?=[a-z]|$)/g, function($0, $1) { return "_" + $1.toLowerCase(); });
95-
};
96-
9775
/**
9876
* Converts the second character of a string to lower case.
9977
* @param {string} str String to convert

Diff for: types/protobuf.js.d.ts

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// $> pbts --name protobufjs --out types/protobuf.js.d.ts src
2-
// Generated Thu, 22 Dec 2016 22:48:48 UTC
2+
// Generated Fri, 23 Dec 2016 11:04:01 UTC
33
declare module "protobufjs" {
44

55
/**
@@ -2353,20 +2353,6 @@ declare module "protobufjs" {
23532353
*/
23542354
function safeProp(prop: string): string;
23552355

2356-
/**
2357-
* Converts a string to camel case notation.
2358-
* @param {string} str String to convert
2359-
* @returns {string} Converted string
2360-
*/
2361-
function camelCase(str: string): string;
2362-
2363-
/**
2364-
* Converts a string to underscore notation.
2365-
* @param {string} str String to convert
2366-
* @returns {string} Converted string
2367-
*/
2368-
function underScore(str: string): string;
2369-
23702356
/**
23712357
* Converts the second character of a string to lower case.
23722358
* @param {string} str String to convert

0 commit comments

Comments
 (0)