Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

andriy2/node-number-case

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

number-case

Simple prototype for number case

Usage

You can use module in different ways

As function:

let caser = require('number-case')()

caser(1, 'st', 'nd', 'th');  // '1st'
caser(2, 'st', 'nd', 'th');  // '2nd'
caser(5, 'st', 'nd', 'th');  // '5th'
let caser = require('number-case')({space: ' '})

caser(1, 'number', 'numbers');  // '1 number'
caser(2, 'number', 'numbers');  // '2 numbers'
caser(5, 'number', 'numbers');  // '5 numbers'

As prototype:

Number.prototype.case = require('number-case')({isPrototype: true})

1..case('st', 'nd', 'th');  // '1st'
2..case('st', 'nd', 'th');  // '2nd'
5..case('st', 'nd', 'th');  // '5th'
Number.prototype.case = require('number-case')({space: ' ', isPrototype: true})

1..case('number', 'numbers');  // '1 number'
2..case('number', 'numbers');  // '2 numbers'
5..case('number', 'numbers');  // '5 numbers'

Default parameters:

{
  space: '',
  isPrototype: false
}

About

Simple prototype for number case

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published