active-inflector
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

Active Inflector CI size

Active Inflector is a library for inflecting words between plural and singular forms. Active Inflector aims to be compatible with ActiveSupport::Inflector from Ruby on Rails, including the ability to add your own inflections in your app.

Compatibility

Requirements:

As always, a consuming project can run a transpiler over dependencies.

Installation

pnpm add active-inflector

Usage

All methods are always available from the active-inflector module:

import { Inflector, singularize, pluralize } from "active-inflector";

Inflector.inflector.singularize("tacos"); // taco
Inflector.inflector.pluralize("taco"); // tacos

singularize("tacos"); // taco
pluralize("taco"); // tacos

pluralize(2, "taco"); // 2 tacos
pluralize(2, "tacos", { withoutCount: true }); // tacos

Custom Rules

If necessary you can setup special inflection rules for your application:

import { Inflector } from "active-inflector";

Inflector.inflector.irregular("person", "people");
Inflector.inflector.uncountable("sheep");

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Package Sidebar

Install

npm i active-inflector

Weekly Downloads

46

Version

0.1.0

License

MIT

Unpacked Size

35.9 kB

Total Files

10

Last publish

Collaborators

  • nullvoxpopuli