Skip to content
Branch: master
Find file History
Latest commit b0c2687 Nov 2, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
src typo Nov 2, 2019 typo Nov 2, 2019
index.js simplur Nov 2, 2019
package.json runmd -> devDependencies Nov 2, 2019


Simple, versatile string pluralization


npm i simplur

Use CommonJS or ESM to import

const simplur = require('simplur');
import * as simplur from 'simplur';


simplur is applied as an ES6 template tag. Any token of the form "[singular|plural]", will be replaced with the appropriate value depending on the value of the expression being injected. For example ...

Simple case:

simplur`I have ${1} kitt[en|ies]`; // ⇨ 'I have 1 kitten'
simplur`I have ${3} kitt[en|ies]`; // ⇨ 'I have 3 kitties'

Simplur also supports look-ahead substitution:

simplur`There [is|are] ${1} m[an|en]`; // ⇨ 'There is 1 man'
simplur`There [is|are] ${5} m[an|en]`; // ⇨ 'There are 5 men'

It also works with multiple injected values (substitution uses preceeding expression value)

simplur`There [is|are] ${1} fox[|es] and ${4} octop[us|i]`; // ⇨ 'There is 1 fox and 4 octopi'
simplur`There [is|are] ${4} fox[|es] and ${1} octop[us|i]`; // ⇨ 'There are 4 foxes and 1 octopus'

Markdown generated from src/ by RunMD Logo

You can’t perform that action at this time.