inflection / 1.10.0 last updated 3 months ago created on Jan 18th 2012
Install
npm install --save inflection
Clone
git clone git@github.com:dreamerslab/node.inflection.git
dependencies
No dependencies listed.
maintainers
versions
33 total
| 1.10.0 | 3 months ago | dreamerslab |
| 1.9.0 | 3 months ago | dreamerslab |
| 1.8.0 | 8 months ago | dreamerslab |
| 1.7.2 | 9 months ago | dreamerslab |
| 1.7.1 | a year ago | dreamerslab |
| 1.7.0 | a year ago | dreamerslab |
| 1.6.0 | a year ago | dreamerslab |
| 1.5.3 | 2 years ago | dreamerslab |
| 1.5.2 | 2 years ago | dreamerslab |
| 1.5.1 | 2 years ago | dreamerslab |
| 1.5.0 | 2 years ago | dreamerslab |
| 1.4.2 | 2 years ago | dreamerslab |
| 1.4.1 | 2 years ago | dreamerslab |
| 1.4.0 | 2 years ago | dreamerslab |
| 1.3.8 | 2 years ago | dreamerslab |
| 1.3.7 | 2 years ago | dreamerslab |
| 1.3.6 | 2 years ago | dreamerslab |
| 1.3.5 | 2 years ago | dreamerslab |
| 1.3.4 | 2 years ago | dreamerslab |
| 1.3.3 | 2 years ago | dreamerslab |
| 1.3.2 | 3 years ago | dreamerslab |
| 1.3.1 | 3 years ago | dreamerslab |
| 1.3.0 | 3 years ago | dreamerslab |
| 1.2.7 | 3 years ago | dreamerslab |
| 1.2.6 | 3 years ago | dreamerslab |
| 1.2.5 | 4 years ago | dreamerslab |
| 1.2.4 | 4 years ago | dreamerslab |
| 1.2.1 | 4 years ago | dreamerslab |
| 1.2.0 | 4 years ago | dreamerslab |
| 1.1.1 | 4 years ago | dreamerslab |
| 1.1.0 | 4 years ago | dreamerslab |
| 1.0.0 | 4 years ago | dreamerslab |
| 0.0.1 | 5 years ago | dreamerslab |
readme
inflection
A port of inflection-js to node.js module
Description
inflection-js is a port of the functionality from Ruby on Rails' Active Support Inflection classes into Javascript. inflection is a port of inflection-js to node.js npm package. Instead of extending JavaScript native String object like inflection-js does, inflection separate the methods to a independent package to avoid unexpected behaviors.
Note: This library uses Wiktionary as its reference.
Requires
Checkout package.json for dependencies.
Angular Support
Checkout ngInflection from konsumer
Meteor Support
Checkout Meteor Inflector from Veaceslav Cotruta
Installation
Install inflection through npm
API
- inflection.indexOf( arr, item, from_index, compare_func );
- inflection.pluralize( str, plural );
- inflection.singularize( str, singular );
- inflection.inflect( str, count, singular, plural );
- inflection.camelize( str, low_first_letter );
- inflection.underscore( str, all_upper_case );
- inflection.humanize( str, low_first_letter );
- inflection.capitalize( str );
- inflection.dasherize( str );
- inflection.titleize( str );
- inflection.demodulize( str );
- inflection.tableize( str );
- inflection.classify( str );
- inflection.foreign_key( str, drop_id_ubar );
- inflection.ordinalize( str );
- inflection.transform( str, arr );
Usage
Require the module before using
inflection.indexOf( arr, item, from_index, compare_func );
This lets us detect if an Array contains a given element.
Arguments
arr
item
from_index
compare_func
Example code
inflection.pluralize( str, plural );
This function adds pluralization support to every String object.
Arguments
str
plural
Example code
inflection.singularize( str, singular );
This function adds singularization support to every String object.
Arguments
str
singular
Example code
inflection.inflect( str, count, singular, plural );
This function will pluralize or singularlize a String appropriately based on an integer value.
Arguments
str
count type: Number desc: The number to base pluralization off of.
singular
plural
Example code
inflection.camelize( str, low_first_letter );
This function transforms String object from underscore to camelcase.
Arguments
str
low_first_letter
Example code
inflection.underscore( str, all_upper_case );
This function transforms String object from camelcase to underscore.
Arguments
str
all_upper_case
Example code
inflection.humanize( str, low_first_letter );
This function adds humanize support to every String object.
Arguments
str
low_first_letter
Example code
inflection.capitalize( str );
This function adds capitalization support to every String object.
Arguments
str
Example code
inflection.dasherize( str );
This function replaces underscores with dashes in the string.
Arguments
str
Example code
inflection.titleize( str );
This function adds titleize support to every String object.
Arguments
str
Example code
inflection.demodulize( str );
This function adds demodulize support to every String object.
Arguments
str
Example code
inflection.tableize( str );
This function adds tableize support to every String object.
Arguments
str
Example code
inflection.classify( str );
This function adds classification support to every String object.
Arguments
str
Example code
inflection.foreign_key( str, drop_id_ubar );
This function adds foreign key support to every String object.
Arguments
str
low_first_letter
Example code
inflection.ordinalize( str );
This function adds ordinalize support to every String object.
Arguments
str
Example code
inflection.transform( str, arr );
This function performs multiple inflection methods on a string.
Arguments
str
arr
Example code
Credit
- Ryan Schuft ryan.schuft@gmail.com
- Lance Pollard lancejpollard@gmail.com (Browser support)
- Dane O'Connor dane.oconnor@gmail.com
- brandondewitt
- luk3thomas
- Marcel Klehr
- Raymond Feng
- Kane Cohen kanecohen@gmail.com
- Gianni Chiappetta gianni@runlevel6.org
- Eric Brody
- overlookmotel
- Patrick Mowrer
- Greger Olsson
- Jason Crawford jason@jasoncrawford.org
- Ray Myers ray.myers@gmail.com
License
(The MIT License)
Copyright (c) 2011 dreamerslab <ben@dreamerslab.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.