https://github.com/nullvoxpopuli/active-inflector
https://github.com/nullvoxpopuli/active-inflector
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/nullvoxpopuli/active-inflector
- Owner: NullVoxPopuli
- License: mit
- Created: 2023-08-17T20:46:33.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-13T23:25:06.000Z (over 1 year ago)
- Last Synced: 2025-04-14T00:34:54.728Z (over 1 year ago)
- Language: TypeScript
- Size: 779 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Active Inflector [](https://github.com/NullVoxPopuli/active-inflector/actions/) 
Active Inflector is a library for inflecting words between plural and singular forms. Active Inflector aims to be compatible with [ActiveSupport::Inflector](http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html) from Ruby on Rails, including the ability to add your own inflections in your app.
## Compatibility
Requirements:
- ESM
- [Private Fields](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Public_class_fields#browser_compatibility)
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:
```javascript
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:
```javascript
import { Inflector } from "active-inflector";
Inflector.inflector.irregular("person", "people");
Inflector.inflector.uncountable("sheep");
```
## Contributing
See the [Contributing](CONTRIBUTING.md) guide for details.
## License
This project is licensed under the [MIT License](LICENSE.md).