Skip to content

A micro library to produce any singular noun into plural

License

Notifications You must be signed in to change notification settings

kalpeshsingh/PluralJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PluralJS

npm version File size npm downloads

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

npm install pluraljs --save

via yarn

yarn add pluraljs

via CDN direct link

<script src="https://cdn.jsdelivr.net/npm/pluraljs/dist/pluraljs.umd.min.js"></script>
<!-- or -->
<script src="https://unpkg.com/pluraljs/dist/pluraljs.umd.min.js"></script>

direct download

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

const pluralJs = require('pluraljs');
console.log(pluralJs('cat')); // cats

console.log(pluralJs('cat', 1)); // cat
console.log(pluralJs('cat', 3)); // cats

ES6

import pluraJs from 'pluraljs';
console.log(pluralJs('cat')); // cats

console.log(pluralJs('cat', -4)); // cat

Browser

<script src="https://cdn.jsdelivr.net/npm/pluraljs/dist/pluraljs.umd.min.js"></script>
<script>
	console.log(pluralJs('cat')); // cats
	console.log(pluralJs('cat', '4')); // cats
</script>

🧡 Show little more care in your product


Product without words pluralization Product using PluralJS
Screenshot - Product not using PluralJS Screenshot - 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)

🙇 Credits


⚖️ License


kalpeshsingh/PluralJS is licensed under the MIT license.

About

A micro library to produce any singular noun into plural

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published