inflection
Advanced tools
Comparing version 1.2.4 to 1.2.5
# History | ||
## 1.2.5 / 2013-01-09 | ||
- [refactoring] Allow all caps strings to be returned from underscore | ||
## 1.2.4 / 2013-01-06 | ||
@@ -4,0 +10,0 @@ |
@@ -320,2 +320,4 @@ /*! | ||
* @param {String} str The subject string. | ||
* @param {Boolean} allUpperCase Default is to lowercase and add underscore prefix.(optional) | ||
* Passing true will return as entered. | ||
* @returns {String} Camel cased words are returned as lower cased and underscored. | ||
@@ -329,4 +331,7 @@ * additionally '::' is translated to '/'. | ||
* inflection.underscore( 'messageProperties' ); // === 'message_properties' | ||
* inflection.underscore( 'MP', true ); // === 'MP' | ||
*/ | ||
underscore : function ( str ){ | ||
underscore : function ( str, allUpperCase ){ | ||
if( allUpperCase && str === str.toUpperCase()) return str; | ||
var str_path = str.split( '::' ); | ||
@@ -333,0 +338,0 @@ var i = 0; |
{ | ||
"name" : "inflection", | ||
"version" : "1.2.4", | ||
"version" : "1.2.5", | ||
"description": "A port of inflection-js to node.js module", | ||
@@ -14,3 +14,5 @@ "keywords" : [ | ||
{ "name": "Ben Lin", "email": "ben@dreamerslab.com" }, | ||
{ "name": "Lance Pollard", "email": "lancejpollard@gmail.com" } | ||
{ "name": "Lance Pollard", "email": "lancejpollard@gmail.com" }, | ||
{ "name": "brandondewitt" } | ||
], | ||
@@ -17,0 +19,0 @@ "dependencies" : {}, |
192
Readme.md
@@ -22,3 +22,3 @@ # inflection | ||
npm install inflection | ||
npm install inflection | ||
@@ -33,3 +33,3 @@ | ||
- inflection.camelize( str, lowFirstLetter ); | ||
- inflection.underscore( str ); | ||
- inflection.underscore( str, allUpperCase ); | ||
- inflection.humanize( str, lowFirstLetter ); | ||
@@ -51,3 +51,3 @@ - inflection.capitalize( str ); | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
@@ -64,26 +64,26 @@ | ||
type: Array | ||
desc: The subject array. | ||
type: Array | ||
desc: The subject array. | ||
> item | ||
type: Object | ||
desc: Object to locate in the Array. | ||
type: Object | ||
desc: Object to locate in the Array. | ||
> fromIndex | ||
type: Number | ||
desc: Starts checking from this position in the Array.(optional) | ||
type: Number | ||
desc: Starts checking from this position in the Array.(optional) | ||
> compareFunc | ||
type: Function | ||
desc: Function used to compare Array item vs passed item.(optional) | ||
type: Function | ||
desc: Function used to compare Array item vs passed item.(optional) | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.indexOf([ 'hi','there' ], 'guys' ); // === -1 | ||
inflection.indexOf([ 'hi','there' ], 'hi' ); // === 0 | ||
inflection.indexOf([ 'hi','there' ], 'guys' ); // === -1 | ||
inflection.indexOf([ 'hi','there' ], 'hi' ); // === 0 | ||
@@ -100,18 +100,18 @@ | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
> plural | ||
type: String | ||
desc: Overrides normal output with said String.(optional) | ||
type: String | ||
desc: Overrides normal output with said String.(optional) | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.pluralize( 'person' ); // === 'people' | ||
inflection.pluralize( 'octopus' ); // === "octopi" | ||
inflection.pluralize( 'Hat' ); // === 'Hats' | ||
inflection.pluralize( 'person', 'guys' ); // === 'guys' | ||
inflection.pluralize( 'person' ); // === 'people' | ||
inflection.pluralize( 'octopus' ); // === "octopi" | ||
inflection.pluralize( 'Hat' ); // === 'Hats' | ||
inflection.pluralize( 'person', 'guys' ); // === 'guys' | ||
@@ -128,18 +128,18 @@ | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
> singular | ||
type: String | ||
desc: Overrides normal output with said String.(optional) | ||
type: String | ||
desc: Overrides normal output with said String.(optional) | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.singularize( 'people' ); // === 'person' | ||
inflection.singularize( 'octopi' ); // === "octopus" | ||
inflection.singularize( 'Hats' ); // === 'Hat' | ||
inflection.singularize( 'guys', 'person' ); // === 'person' | ||
inflection.singularize( 'people' ); // === 'person' | ||
inflection.singularize( 'octopi' ); // === "octopus" | ||
inflection.singularize( 'Hats' ); // === 'Hat' | ||
inflection.singularize( 'guys', 'person' ); // === 'person' | ||
@@ -156,20 +156,20 @@ | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
> lowFirstLetter | ||
type: Boolean | ||
desc: Default is to capitalize the first letter of the results. Passing true will lowercase it. (optional) | ||
type: Boolean | ||
desc: Default is to capitalize the first letter of the results. Passing true will lowercase it. (optional) | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.camelize( 'message_properties' ); // === 'MessageProperties' | ||
inflection.camelize( 'message_properties', true ); // === 'messageProperties' | ||
inflection.camelize( 'message_properties' ); // === 'MessageProperties' | ||
inflection.camelize( 'message_properties', true ); // === 'messageProperties' | ||
### inflection.underscore( str ); | ||
### inflection.underscore( str, allUpperCase ); | ||
@@ -182,11 +182,20 @@ This function adds underscore support to every String object. | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
> allUpperCase | ||
type: Boolean | ||
desc: Default is to lowercase and add underscore prefix | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.underscore( 'MessageProperties' ); // === 'message_properties' | ||
inflection.underscore( 'messageProperties' ); // === 'message_properties' | ||
inflection.underscore( 'MessageProperties' ); // === 'message_properties' | ||
inflection.underscore( 'messageProperties' ); // === 'message_properties' | ||
inflection.underscore( 'MP' ); // === 'm_p' | ||
inflection.underscore( 'MP', true ); // === 'MP' | ||
@@ -203,16 +212,16 @@ | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
> lowFirstLetter | ||
type: Boolean | ||
desc: Default is to capitalize the first letter of the results. Passing true will lowercase it. (optional) | ||
type: Boolean | ||
desc: Default is to capitalize the first letter of the results. Passing true will lowercase it. (optional) | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.humanize( 'message_properties' ); // === 'Message properties' | ||
inflection.humanize( 'message_properties', true ); // === 'message properties' | ||
inflection.humanize( 'message_properties' ); // === 'Message properties' | ||
inflection.humanize( 'message_properties', true ); // === 'message properties' | ||
@@ -229,11 +238,11 @@ | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.capitalize( 'message_properties' ); // === 'Message_properties' | ||
inflection.capitalize( 'message properties', true ); // === 'Message properties' | ||
inflection.capitalize( 'message_properties' ); // === 'Message_properties' | ||
inflection.capitalize( 'message properties', true ); // === 'Message properties' | ||
@@ -250,11 +259,11 @@ | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.dasherize( 'message_properties' ); // === 'message-properties' | ||
inflection.dasherize( 'Message Properties' ); // === 'Message-Properties' | ||
inflection.dasherize( 'message_properties' ); // === 'message-properties' | ||
inflection.dasherize( 'Message Properties' ); // === 'Message-Properties' | ||
@@ -271,11 +280,11 @@ | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.titleize( 'message_properties' ); // === 'Message Properties' | ||
inflection.titleize( 'message properties to keep' ); // === 'Message Properties to Keep' | ||
inflection.titleize( 'message_properties' ); // === 'Message Properties' | ||
inflection.titleize( 'message properties to keep' ); // === 'Message Properties to Keep' | ||
@@ -292,10 +301,10 @@ | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.demodulize( 'Message::Bus::Properties' ); // === 'Properties' | ||
inflection.demodulize( 'Message::Bus::Properties' ); // === 'Properties' | ||
@@ -312,10 +321,10 @@ | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.tableize( 'MessageBusProperty' ); // === 'message_bus_properties' | ||
inflection.tableize( 'MessageBusProperty' ); // === 'message_bus_properties' | ||
@@ -332,10 +341,10 @@ | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.classify( 'message_bus_properties' ); // === 'MessageBusProperty' | ||
inflection.classify( 'message_bus_properties' ); // === 'MessageBusProperty' | ||
@@ -352,16 +361,16 @@ | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
> lowFirstLetter | ||
type: Boolean | ||
desc: Default is to seperate id with an underbar at the end of the class name, you can pass true to skip it.(optional) | ||
type: Boolean | ||
desc: Default is to seperate id with an underbar at the end of the class name, you can pass true to skip it.(optional) | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.foreign_key( 'MessageBusProperty' ); // === 'message_bus_property_id' | ||
inflection.foreign_key( 'MessageBusProperty', true ); // === 'message_bus_propertyid' | ||
inflection.foreign_key( 'MessageBusProperty' ); // === 'message_bus_property_id' | ||
inflection.foreign_key( 'MessageBusProperty', true ); // === 'message_bus_propertyid' | ||
@@ -378,10 +387,10 @@ | ||
type: String | ||
desc: The subject string. | ||
type: String | ||
desc: The subject string. | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
var inflection = require( 'inflection' ); | ||
inflection.ordinalize( 'the 1 pitch' ); // === 'the 1st pitch' | ||
inflection.ordinalize( 'the 1 pitch' ); // === 'the 1st pitch' | ||
@@ -394,2 +403,3 @@ | ||
- Lance Pollard <lancejpollard@gmail.com> (Browser support) | ||
- brandondewitt | ||
@@ -421,2 +431,2 @@ | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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
32110
513
414