Registry / serialization / active-inflector

active-inflector

JSON →
library0.1.0jsnpmunverified

Active Inflector is a JavaScript/TypeScript library for pluralizing and singularizing words, aiming for full compatibility with Ruby on Rails' ActiveSupport::Inflector. Version 0.1.0 is the latest stable release, with infrequent updates. It provides both default export of an Inflector class with static methods and convenient standalone singularize/pluralize functions. Key differentiators: Rails-compatible custom rules (irregular, uncountable, uncountable), supports numeric pluralization (e.g., pluralize(2, 'taco') → '2 tacos'), and ships TypeScript types. Requires ESM and environment support for JS private fields.

npm install active-inflector
INSTALL
IMPORT
SIG · ACTIVE-INFLECTOR
A
active-inflector
serializationjavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Inflector
import { Inflector } from 'active-inflector'
const Inflector = require('active-inflector')
Package is ESM-only; CJS require() will fail.
singularize
import { singularize } from 'active-inflector'
import singularize from 'active-inflector/singularize'
Singularize is a named export, not a default export from a subpath.
pluralize
import { pluralize } from 'active-inflector'
Pluralize supports both string and numeric overloading; e.g., pluralize(2, 'taco').

Demonstrates basic singularize/pluralize, numeric pluralization, and custom irregular/uncountable rules.

import { Inflector, singularize, pluralize } from 'active-inflector'; // Basic singularization/pluralization console.log(singularize('tacos')); // 'taco' console.log(pluralize('taco')); // 'tacos' // Numeric pluralization console.log(pluralize(2, 'taco')); // '2 tacos' console.log(pluralize(2, 'tacos', { withoutCount: true })); // 'tacos' // Custom irregular and uncountable rules Inflector.inflector.irregular('person', 'people'); Inflector.inflector.uncountable('sheep'); console.log(pluralize('person')); // 'people' console.log(pluralize('sheep')); // 'sheep'
Debug
Known issues
breakingPackage is ESM-only. CJS require() causes runtime error 'ERR_REQUIRE_ESM'.
fix
Use dynamic import() or switch to ESM in your project.
affects: >=0.0.1
gotchaInflector.inflector.singularize() vs singularize() directly: both work, but the static method via Inflector.inflector is the only way to access custom rules after they are set.
fix
Use Inflector.inflector.singularize() when you need custom rules to apply, otherwise standalone singularize() is fine.
affects: >=0.0.1
gotchaNumeric pluralize overload expects count as first argument. Passing a string number will not work correctly.
fix
Ensure the first argument is a number, not a string. E.g., pluralize(2, 'taco') not pluralize('2', 'taco').
affects: >=0.0.1
breakingRequires JavaScript environment that supports private class fields (e.g., Node.js 12+, modern browsers). Running in older environments may throw SyntaxError.
fix
Transpile with Babel/TypeScript targeting older environments, or use a polyfill for private fields.
affects: >=0.0.1
deprecatedPackage is very early (v0.1.0); API may change without major version bump.
fix
Pin to exact version and monitor releases.
affects: >=0.0.1
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Trying to require() an ESM-only package.
fix
Use import { Inflector } from 'active-inflector' or dynamic import().
TypeError: Inflector.inflector is undefined
Using default import instead of named import Inflector class.
fix
Ensure import is correct: import { Inflector } from 'active-inflector'. The Inflector class is exported as a named export, not default.
SyntaxError: Unexpected private field
Environment does not support JavaScript private class fields (# syntax).
fix
Use a transpiler like Babel with @babel/plugin-proposal-private-methods or target a newer runtime (Node >=12, modern browsers).
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
52 hits · last 30 days
node
44
Amazon
1
Resources
active-inflector — npm install active-inflector · libregistry