{"id":24885,"library":"active-inflector","title":"active-inflector","description":"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.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"git://github.com/NullVoxPopuli/active-inflector","tags":["javascript","inflector","inflection","string","active-record","rails","active-inflection","active","plural","typescript"],"install":[{"cmd":"npm install active-inflector","lang":"bash","label":"npm"},{"cmd":"yarn add active-inflector","lang":"bash","label":"yarn"},{"cmd":"pnpm add active-inflector","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only; CJS require() will fail.","wrong":"const Inflector = require('active-inflector')","symbol":"Inflector","correct":"import { Inflector } from 'active-inflector'"},{"note":"Singularize is a named export, not a default export from a subpath.","wrong":"import singularize from 'active-inflector/singularize'","symbol":"singularize","correct":"import { singularize } from 'active-inflector'"},{"note":"Pluralize supports both string and numeric overloading; e.g., pluralize(2, 'taco').","symbol":"pluralize","correct":"import { pluralize } from 'active-inflector'"}],"quickstart":{"code":"import { Inflector, singularize, pluralize } from 'active-inflector';\n\n// Basic singularization/pluralization\nconsole.log(singularize('tacos')); // 'taco'\nconsole.log(pluralize('taco')); // 'tacos'\n\n// Numeric pluralization\nconsole.log(pluralize(2, 'taco')); // '2 tacos'\nconsole.log(pluralize(2, 'tacos', { withoutCount: true })); // 'tacos'\n\n// Custom irregular and uncountable rules\nInflector.inflector.irregular('person', 'people');\nInflector.inflector.uncountable('sheep');\nconsole.log(pluralize('person')); // 'people'\nconsole.log(pluralize('sheep')); // 'sheep'","lang":"typescript","description":"Demonstrates basic singularize/pluralize, numeric pluralization, and custom irregular/uncountable rules."},"warnings":[{"fix":"Use dynamic import() or switch to ESM in your project.","message":"Package is ESM-only. CJS require() causes runtime error 'ERR_REQUIRE_ESM'.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Use Inflector.inflector.singularize() when you need custom rules to apply, otherwise standalone singularize() is fine.","message":"Inflector.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.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Ensure the first argument is a number, not a string. E.g., pluralize(2, 'taco') not pluralize('2', 'taco').","message":"Numeric pluralize overload expects count as first argument. Passing a string number will not work correctly.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Transpile with Babel/TypeScript targeting older environments, or use a polyfill for private fields.","message":"Requires JavaScript environment that supports private class fields (e.g., Node.js 12+, modern browsers). Running in older environments may throw SyntaxError.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Pin to exact version and monitor releases.","message":"Package is very early (v0.1.0); API may change without major version bump.","severity":"deprecated","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use import { Inflector } from 'active-inflector' or dynamic import().","cause":"Trying to require() an ESM-only package.","error":"ERR_REQUIRE_ESM"},{"fix":"Ensure import is correct: import { Inflector } from 'active-inflector'. The Inflector class is exported as a named export, not default.","cause":"Using default import instead of named import Inflector class.","error":"TypeError: Inflector.inflector is undefined"},{"fix":"Use a transpiler like Babel with @babel/plugin-proposal-private-methods or target a newer runtime (Node >=12, modern browsers).","cause":"Environment does not support JavaScript private class fields (# syntax).","error":"SyntaxError: Unexpected private field"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}