Gathering detailed insights and metrics for inflected
Gathering detailed insights and metrics for inflected
Gathering detailed insights and metrics for inflected
Gathering detailed insights and metrics for inflected
@types/inflected
TypeScript definitions for inflected
@ryancavanaugh/inflected
Type definitions for inflected 1.1.6 from https://www.github.com/DefinitelyTyped/DefinitelyTyped
inflected-nougatized
A port of ActiveSupport's inflector to Node.js and GoogleAppsScript
node-lemmatizer
A lemmatization library for Node.js to retrieve a base form from an inflected form word in English.
npm install inflected
Typescript
Module System
Node Version
NPM Version
JavaScript (99.12%)
Makefile (0.88%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
167 Stars
54 Commits
22 Forks
2 Watchers
6 Branches
5 Contributors
Updated on Apr 21, 2025
Latest Version
2.1.0
Package Id
inflected@2.1.0
Size
16.88 kB
NPM Version
6.14.5
Node Version
14.5.0
Published on
Sep 14, 2020
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
A port of ActiveSupport's inflector to Node.js. Also usable in the browser.
Install via npm:
1% npm install inflected
Or via yarn:
1% yarn add inflected
The UMD build is also available on unpkg, adding a Inflector
object to the global scope.
1<script src="https://unpkg.com/inflected/dist/umd/inflected.min.js"></script>
The module exports an object with several utility functions.
1var Inflector = require('inflected'); 2 3Inflector.pluralize('Category') // => 'Categories'
If using ES modules, you can cherry-pick only the functions you're interested in:
1import { pluralize } from 'inflected'; 2 3pluralize('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" (default: true
).
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'
As of v2.1, there's also a preserveCase
option:
1Inflector.parameterize('Donald E. Knuth', { preserveCase: true }) // => 'Donald+E+Knuth'
1string constantify(string words)
Converts words (camelCased, under_scored, or dasherized) to CONSTANT_CASE.
1Inflector.constantify('bankAccount') // => 'BANK_ACCOUNT' 2Inflector.constantify('bank-account') // => 'BANK_ACCOUNT' 3Inflector.constantify('bank_account') // => 'BANK_ACCOUNT' 4Inflector.constantify('Bank Account') // => 'BANK_ACCOUNT'
Here's a quick guide:
make install
.make test
.Released under The MIT License.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/26 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
28 existing vulnerabilities detected
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