Permalink
Browse files

Breaking: Moved camelCase/underScore away from util to where actually…

… used
  • Loading branch information...
dcodeIO committed Dec 23, 2016
1 parent 4d1f5fa commit a97956b1322b6ee62d4fc9af885658cd5855e521
@@ -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 />
@@ -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 />
@@ -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 />
@@ -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;

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN -79 Bytes (99%) dist/noparse/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN -50 Bytes (100%) dist/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
BIN +0 Bytes (100%) dist/runtime/protobuf.min.js.gz
Binary file not shown.
@@ -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
@@ -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;
@@ -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.
@@ -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
@@ -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" {
/**
@@ -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

0 comments on commit a97956b

Please sign in to comment.