https://github.com/kalpeshsingh/pluraljs
A micro library to produce any singular noun into plural
https://github.com/kalpeshsingh/pluraljs
inflections noun plural singular words
Last synced: 3 months ago
JSON representation
A micro library to produce any singular noun into plural
- Host: GitHub
- URL: https://github.com/kalpeshsingh/pluraljs
- Owner: kalpeshsingh
- License: mit
- Created: 2020-05-10T09:55:59.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-24T06:32:15.000Z (about 6 years ago)
- Last Synced: 2024-04-20T12:18:11.975Z (about 2 years ago)
- Topics: inflections, noun, plural, singular, words
- Language: JavaScript
- Homepage:
- Size: 1.31 MB
- Stars: 9
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PluralJS
A micro library to produce any singular noun into plural
### π‘ Motive
---
I was curious to learn about how to build a library, what are the thought-processes behind it, what are the technical stuff you need to know etc. This was the primary reason PluralJS came into conception.
### π₯ Installation
---
**via npm**
```shell
npm install pluraljs --save
```
**via yarn**
```shell
yarn add pluraljs
```
**via CDN direct link**
```html
```
**direct download**
```shell
curl -o https://unpkg.com/pluraljs/dist/pluraljs.umd.min.js
```
### π Usage
---
The PluralJS is single responsibility library.
It takes only a noun (with optional count parameter) and produce plural noun out of it.
#### API
| parameter | description | type | required | example |
| --------- | --------------------------------- | ------ | -------- | ---------------------------------------------------------- |
| word | a word to pluralize | string | yes | pluralJs('cat') // cats |
| count | pluralize the word based on count | number | no | pluralJs('cat', 3) // cats
pluralJs('cat', 1) // cat |
#### Node
```node
const pluralJs = require('pluraljs');
console.log(pluralJs('cat')); // cats
console.log(pluralJs('cat', 1)); // cat
console.log(pluralJs('cat', 3)); // cats
```
#### ES6
```js
import pluraJs from 'pluraljs';
console.log(pluralJs('cat')); // cats
console.log(pluralJs('cat', -4)); // cat
```
#### Browser
```html
console.log(pluralJs('cat')); // cats
console.log(pluralJs('cat', '4')); // cats
```
### π§‘ Show little more care in your product
---
| Product without words pluralization | Product using PluralJS |
| -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
|
### π Changelog
---
**1.1.0**
- `ENHANCEMENT` Added ability to pass count parameter
**1.0.0**
- `FEATURE` Released first stable version
### πββοΈMaintainer
---
Kalpesh Singh ([@knowkalpesh](https://twitter.com/knowkalpesh))
### π Credits
---
- The core logic and testing file are borrowed from [Blake Embrey](https://github.com/blakeembrey)'s [Pluralize](https://github.com/blakeembrey/pluralize)
- Card screenshot used from [Chakra UI](https://chakra-ui.com/)
- Those lovely cats artwork used for branding is from [Undraw](https://undraw.co/)
### βοΈ License
---
kalpeshsingh/PluralJS is licensed under the [MIT license](https://opensource.org/licenses/MIT).