-
Notifications
You must be signed in to change notification settings - Fork 3
/
localtest.ts
26 lines (20 loc) · 982 Bytes
/
localtest.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { ShowQuantityAs } from "https://deno.land/x/humanizer/toQuantity.ts"
console.log("case".toQuantity(0))
console.log("case".toQuantity(1))
console.log("case".toQuantity(5))
console.log("man".toQuantity(0))
console.log("man".toQuantity(1))
console.log("man".toQuantity(2))
// ToQuantity can figure out whether the input word is singular or plural and will singularize or pluralize as necessary:
console.log("men".toQuantity(2))
console.log("process".toQuantity(2))
console.log("process".toQuantity(1))
console.log("processes".toQuantity(2))
console.log("processes".toQuantity(1))
/*
You can also pass a second argument, ShowQuantityAs, to toQuantity to specify how you want the provided quantity
to be outputted. The default value is ShowQuantityAs.Numeric which is what we saw above. The other two values are
ShowQuantityAs.Words and ShowQuantityAs.None.
*/
console.log("case".toQuantity(5, ShowQuantityAs.Words))
console.log("case".toQuantity(5, ShowQuantityAs.None))