codemaker
Advanced tools
Comparing version 0.13.4 to 0.14.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [0.14.0](https://github.com/awslabs/jsii/compare/v0.13.4...v0.14.0) (2019-07-08) | ||
### Features | ||
* **python:** idiomatic capitalization for structs ([#586](https://github.com/awslabs/jsii/issues/586)) ([51211a0](https://github.com/awslabs/jsii/commit/51211a0)), closes [#537](https://github.com/awslabs/jsii/issues/537) [#577](https://github.com/awslabs/jsii/issues/577) [#578](https://github.com/awslabs/jsii/issues/578) [#588](https://github.com/awslabs/jsii/issues/588) | ||
## [0.13.4](https://github.com/awslabs/jsii/compare/v0.13.3...v0.13.4) (2019-07-03) | ||
@@ -8,0 +19,0 @@ |
@@ -5,2 +5,7 @@ "use strict"; | ||
const decamelize = require("decamelize"); | ||
const COMMON_ABBREVIATIONS = [ | ||
'KiB', | ||
'MiB', | ||
'GiB', | ||
]; | ||
function toCamelCase(...args) { | ||
@@ -15,4 +20,13 @@ return camelcase_1.default(args); | ||
function toSnakeCase(s, sep = '_') { | ||
// Save common abbrevations | ||
s = s.replace(ABBREV_RE, (_, before, abbr, after) => before + ucfirst(abbr.toLowerCase()) + after); | ||
return decamelize(s, sep); | ||
} | ||
exports.toSnakeCase = toSnakeCase; | ||
function regexQuote(s) { | ||
return s.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); | ||
} | ||
const ABBREV_RE = new RegExp('(^|[^A-Z])(' + COMMON_ABBREVIATIONS.map(regexQuote).join('|') + ')($|[^a-z])', 'g'); | ||
function ucfirst(s) { | ||
return s.substr(0, 1).toUpperCase() + s.substr(1).toLowerCase(); | ||
} |
{ | ||
"name": "codemaker", | ||
"version": "0.13.4", | ||
"version": "0.14.0", | ||
"description": "A tiny utility for generating source code", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -5,3 +5,3 @@ "use strict"; | ||
module.exports = nodeunit.testCase({ | ||
toCamelCase(test) { | ||
'toCamelCase'(test) { | ||
test.equal(caseUtils.toCamelCase('EXAMPLE_VALUE'), 'exampleValue'); | ||
@@ -11,7 +11,21 @@ test.equal(caseUtils.toCamelCase('example', 'value'), 'exampleValue'); | ||
}, | ||
toPascalCase(test) { | ||
'toPascalCase'(test) { | ||
test.equal(caseUtils.toPascalCase('EXAMPLE_VALUE'), 'ExampleValue'); | ||
test.equal(caseUtils.toPascalCase('example', 'value'), 'ExampleValue'); | ||
test.done(); | ||
}, | ||
'toSnakeCase'(test) { | ||
test.equal(caseUtils.toSnakeCase('EXAMPLE_VALUE'), 'example_value'); | ||
test.equal(caseUtils.toSnakeCase('exampleValue'), 'example_value'); | ||
test.equal(caseUtils.toSnakeCase('ExampleValue'), 'example_value'); | ||
test.equal(caseUtils.toSnakeCase('EPSConduit'), 'eps_conduit'); | ||
test.equal(caseUtils.toSnakeCase('SomeEBSVolume'), 'some_ebs_volume'); | ||
test.done(); | ||
}, | ||
'reserved word snake-casing'(test) { | ||
test.equal(caseUtils.toSnakeCase('SizeMiB'), 'size_mib'); | ||
test.equal(caseUtils.toSnakeCase('SizeMiBiBytes'), 'size_mi_bi_bytes'); | ||
test.equal(caseUtils.toSnakeCase('MiBSize'), 'mib_size'); | ||
test.done(); | ||
} | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
144851
522