inflection
Advanced tools
Comparing version 1.2.6 to 1.2.7
# History | ||
## 1.2.7 / 2013-12-11 | ||
- [new feature] Added transform, thnaks to `luk3thomas` | ||
- [update packages] should->v2.1.1 | ||
## 1.2.6 / 2013-05-24 | ||
- [bug fix] Use instance instead of `this` | ||
## 1.2.5 / 2013-01-09 | ||
@@ -4,0 +17,0 @@ |
@@ -244,3 +244,3 @@ /*! | ||
* inflection.pluralize( 'person' ); // === 'people' | ||
* inflection.pluralize( 'octopus' ); // === "octopi" | ||
* inflection.pluralize( 'octopus' ); // === 'octopi' | ||
* inflection.pluralize( 'Hat' ); // === 'Hats' | ||
@@ -267,3 +267,3 @@ * inflection.pluralize( 'person', 'guys' ); // === 'guys' | ||
* inflection.singularize( 'people' ); // === 'person' | ||
* inflection.singularize( 'octopi' ); // === "octopus" | ||
* inflection.singularize( 'octopi' ); // === 'octopus' | ||
* inflection.singularize( 'Hats' ); // === 'Hat' | ||
@@ -552,3 +552,3 @@ * inflection.singularize( 'guys', 'person' ); // === 'person' | ||
* @param {String} str The subject string. | ||
* @returns {String} Return all found numbers their sequence like "22nd". | ||
* @returns {String} Return all found numbers their sequence like '22nd'. | ||
* @example | ||
@@ -588,2 +588,30 @@ * | ||
return str_arr.join( ' ' ); | ||
}, | ||
/** | ||
* This function performs multiple inflection methods on a string | ||
* @public | ||
* @function | ||
* @param {String} str The subject string. | ||
* @param {Array} arr An array of inflection methods. | ||
* @returns {String} | ||
* @example | ||
* | ||
* var inflection = require( 'inflection' ); | ||
* | ||
* inflection.transform( 'all job', [ 'pluralize', 'capitalize', 'dasherize' ]); // === 'All-jobs' | ||
*/ | ||
transform : function ( str, arr ){ | ||
var i = 0; | ||
var j = arr.length; | ||
for( ;i < j; i++ ){ | ||
var method = arr[ i ]; | ||
if( this.hasOwnProperty( method )){ | ||
str = this[ method ]( str ); | ||
} | ||
} | ||
return str; | ||
} | ||
@@ -597,3 +625,3 @@ }; | ||
*/ | ||
inflector.version = "1.2.5"; | ||
inflector.version = '1.2.7'; | ||
/** | ||
@@ -600,0 +628,0 @@ * Exports module. |
{ | ||
"name" : "inflection", | ||
"version" : "1.2.6", | ||
"version" : "1.2.7", | ||
"description": "A port of inflection-js to node.js module", | ||
@@ -20,3 +20,3 @@ "keywords" : [ | ||
"node.flow": "1.2.2", | ||
"should" : "1.2.2" | ||
"should" : "2.1.1" | ||
}, | ||
@@ -23,0 +23,0 @@ "main" : "./lib/inflection.js", |
@@ -42,2 +42,3 @@ # inflection | ||
- inflection.ordinalize( str ); | ||
- inflection.transform( str, arr ); | ||
@@ -383,2 +384,26 @@ | ||
### inflection.transform( str, arr ); | ||
This function performs multiple inflection methods on a string. | ||
#### Arguments | ||
> str | ||
type: String | ||
desc: The subject string. | ||
> arr | ||
type: Array | ||
desc: An array of inflection methods. | ||
#### Example code | ||
var inflection = require( 'inflection' ); | ||
inflection.transform( 'all job', [ 'pluralize', 'capitalize', 'dasherize' ]); // === 'All-jobs' | ||
## Credit | ||
@@ -389,5 +414,5 @@ | ||
- brandondewitt | ||
- luk3thomas | ||
## License | ||
@@ -394,0 +419,0 @@ |
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
33384
535
439