format-number
defaults
512
returns 512.
expect(format('512')).to.be('512');
6300
returns 6,300.
expect(format('6300')).to.be('6,300');
76300
returns 76,300.
expect(format('76300')).to.be('76,300');
976300
returns 976,300.
expect(format('976300')).to.be('976,300');
1976300
returns 1,976,300.
expect(format('1976300')).to.be('1,976,300');
56.43
returns 56.43.
expect(format('56.43')).to.be('56.43');
padRight=2
512
returns 512.00.
expect(format('512')).to.be('512.00');
512.4
returns 512.40.
expect(format('512.4')).to.be('512.40');
512.43
returns 512.43.
expect(format('512.43')).to.be('512.43');
512.435
returns 512.435.
expect(format('512.435')).to.be('512.435');
truncate=2
512
returns 512.
expect(format('512')).to.be('512');
512.4
returns 512.4.
expect(format('512.4')).to.be('512.4');
512.43
returns 512.43.
expect(format('512.43')).to.be('512.43');
512.435
returns 512.43.
expect(format('512.435')).to.be('512.43');
prefix=£
512
returns £512.
expect(format('512')).to.be('£512');
-512
returns -£512.
expect(format('-512')).to.be('-£512');
with includeUnits as false
512
returns 512.
expect(format('512', false)).to.be('512');
-512
returns -512.
expect(format('-512', false)).to.be('-512');
prefix.suffix
equals "£".
expect(format.prefix).to.be('£');
suffix=" items"
512
returns 512 items.
expect(format('512')).to.be('512 items');
-512
returns -512 items.
expect(format('-512')).to.be('-512 items');
with includeUnits as false
512
returns 512.
expect(format('512', false)).to.be('512');
-512
returns -512.
expect(format('-512', false)).to.be('-512');
format.suffix
equals " items".
expect(format.suffix).to.be(' items');