Gathering detailed insights and metrics for inflected-nougatized
Gathering detailed insights and metrics for inflected-nougatized
Gathering detailed insights and metrics for inflected-nougatized
Gathering detailed insights and metrics for inflected-nougatized
npm install inflected-nougatized
Typescript
Module System
Node Version
NPM Version
JavaScript (99.16%)
Makefile (0.84%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
32 Commits
1 Watchers
2 Branches
1 Contributors
Updated on Jun 13, 2015
Latest Version
0.1.0
Package Id
inflected-nougatized@0.1.0
Size
6.09 kB
NPM Version
2.10.1
Node Version
0.12.4
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
3
A port of ActiveSupport's inflector to Node.js and GoogleAppsScript.
Install via npm:
1% npm install inflected-nougatized
The module exports an object with several utility functions.
1var Inflector = require('inflected').Inflector; 2 3Inflector.pluralize('Category') // => 'Categories'
Here is the complete API reference:
1string pluralize(string word[, string locale])
Returns the plural form of the word in the string.
If passed an optional locale
parameter, the word will be pluralized using rules defined for that language. By default, this parameter is set to "en".
1Inflector.pluralize('post') // => 'posts' 2Inflector.pluralize('octopus') // => 'octopi' 3Inflector.pluralize('sheep') // => 'sheep' 4Inflector.pluralize('words') // => 'words' 5Inflector.pluralize('CamelOctopus') // => 'CamelOctopi' 6Inflector.pluralize('ley', 'es') // => 'leyes'
1string singularize(string word[, string locale])
The reverse of pluralize
, returns the singular form of a word in a string.
If passed an optional locale
parameter, the word will be singularized using rules defined for that language. By default, this parameter is set to "en".
1Inflector.singularize('posts') // => 'post' 2Inflector.singularize('octopi') // => 'octopus' 3Inflector.singularize('sheep') // => 'sheep' 4Inflector.singularize('word') // => 'word' 5Inflector.singularize('CamelOctopi') // => 'CamelOctopus' 6Inflector.singularize('leyes', 'es') // => 'ley'
1string camelize(string term[, boolean uppercaseFirstLetter])
By default, camelize
converts strings to UpperCamelCase. If the second argument is set to false
then camelize
produces lowerCamelCase.
1Inflector.camelize('foo_bar') // => 'FooBar' 2Inflector.camelize('foo_bar', false) // => 'fooBar'
As a rule of thumb you can think of camelize
as the inverse of underscore
, though there are cases where that does not hold:
1Inflector.camelize(Inflector.underscore('SSLError')) //=> 'SslError'
1string underscore(string camelCasedWord)
Makes an underscored, lowercase form from the expression in the string.
1Inflector.underscore('FooBar') // => 'foo_bar'
As a rule of thumb you can think of underscore
as the inverse of camelize
, though there are cases where that does not hold:
1Inflector.camelize(Inflector.underscore('SSLError')) //=> 'SslError'
1string humanize(string lowerCaseAndUnderscoredWord[, object options])
Capitalizes the first word, turns underscores into spaces, and strips a trailing "_id" if present.
Like titleize
, this is meant for creating pretty output.
The capitalization of the first word can be turned off by setting the capitalize
option key to false
. By default, this option is true
.
1Inflector.humanize('employee_salary') // => 'Employee salary' 2Inflector.humanize('author_id') // => 'Author' 3Inflector.humanize('author_id', { capitalize: false }) // => 'author'
1string titleize(string sentence)
Capitalizes all the words and replaces some characters in the string to create a nicer looking title. titleize
is meant for creating pretty output.
1Inflector.titleize('man from the boondocks') // => 'Man From The Boondocks' 2Inflector.titleize('x-men: the last stand') // => 'X Men: The Last Stand' 3Inflector.titleize('TheManWithoutAPast') // => 'The Man Without A Past' 4Inflector.titleize('raiders_of_the_lost_ark') // => 'Raiders Of The Lost Ark'
1string tableize(string className)
Create the name of a table like Rails does for models to table names. This method uses the pluralize
method on the last word in the string.
1Inflector.tableize('RawScaledScorer') // => 'raw_scaled_scorers' 2Inflector.tableize('egg_and_ham') // => 'egg_and_hams' 3Inflector.tableize('fancyCategory') // => 'fancy_categories'
1string classify(string tableName)
Create a class name from a plural table name like Rails does for table names to models.
1Inflector.classify('egg_and_hams') // => 'EggAndHam' 2Inflector.classify('posts') // => 'Post'
Singular names are not handled correctly:
1Inflector.classify('business') // => 'Busines'
1string dasherize(string underscoredWord)
Replaces underscores with dashes in the string.
1Inflector.dasherize('puni_puni') // => 'puni-puni'
1string foreignKey(string className[, boolean separateClassNameAndIdWithUnderscore])
Creates a foreign key name from a class name. separateClassNameAndIdWithUnderscore
sets whether the method should put "_" between the name and "id".
1Inflector.foreignKey('Message') // => 'message_id' 2Inflector.foreignKey('Message', false) // => 'messageid'
1string ordinal(object number)
Returns the suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
1Inflector.ordinal(1) // => 'st' 2Inflector.ordinal(2) // => 'nd' 3Inflector.ordinal(1002) // => 'nd' 4Inflector.ordinal(1003) // => 'rd' 5Inflector.ordinal(-11) // => 'th' 6Inflector.ordinal(-1021) // => 'st'
1string ordinalize(object number)
Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
1Inflector.ordinalize(1) // => '1st' 2Inflector.ordinalize(2) // => '2nd' 3Inflector.ordinalize(1002) // => '1002nd' 4Inflector.ordinalize(1003) // => '1003rd' 5Inflector.ordinalize(-11) // => '-11th' 6Inflector.ordinalize(-1021) // => '-1021st'
1Inflections inflections([string locale]) 2inflections([string locale], [function(Inflections) fn])
A singleton instance of the internal Inflections class is yielded by this function, which can then be used to specify additional inflection rules. If passed an optional locale, rules for other languages can be specified. The default locale is "en". Only rules for English are provided by this library.
1Inflector.inflections('en', function(inflect) { 2 inflect.plural(/^(ox)$/i, '$1$2en'); 3 inflect.singular /^(ox)en/i, '$1'); 4 5 inflect.irregular('octopus', 'octopi'); 6 7 inflect.uncountable('equipment', 'snow'); 8});
New rules are added at the top. So in the example above, the irregular rule for octopus will now be the first of the pluralization and singularization rules that is run. This guarantees that your rules run before any of the rules that may already have been loaded.
1string transliterate(string sentence[, object options])
Replaces non-ASCII characters with an ASCII approximation, or if none exists, a replacement character which defaults to "?".
1Inflector.transliterate('Ærøskøbing') // => 'AEroskobing'
Default approximations are provided for Western/Latin characters, e.g, "ø", "ñ", "é", "ß", etc.
This method is I18n-aware, so you can set up custom approximations for a locale. This can be useful, for example, to transliterate German's "ü" and "ö" to "ue" and "oe", or to add support for transliterating Russian to ASCII.
In order to make your custom transliterations available, you must set them using the approximate
helper function:
1Inflector.transliterations('de', function(t) { 2 t.approximate('ü', 'ue'); 3 t.approximate('ö', 'oe'); 4});
Now you can have different transliterations for each locale:
1Inflector.transliterate('Jürgen') // => 'Jurgen' 2Inflector.transliterate('Jürgen', { locale: 'de' }) // => 'Juergen'
1string parameterize(string sentence[, object options])
Replaces special characters in a string so that it may be used as part of a 'pretty' URL.
1Inflector.parameterize('Donald E. Knuth') // => 'donald-e-knuth' 2Inflector.parameterize('Donald E. Knuth', { separator: '+' }) // => 'donald+e+knuth'
Here's a quick guide:
Fork the repo and make install
.
Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate: make test
.
Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or are fixing a bug, we need a test!
Make the test pass.
Push to your fork and submit a pull request.
Released under The MIT License.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More