1.3.0 • Published 4 years ago

kopeiky.js v1.3.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

kopeiky.js

If your're happy coding with js, proably see something like this:

> 0.20 + 0.01
< 0.21000000000000002

This library can help with that

Example

import kopeiky from "./index";

kopeiky(0.2).add(0.01).toNormal(); // 0.21
JSON.stringify({ money: kopeiky(0.2).add(0.01) }); // "{money: 0.21}"

Some trick:

> kopeiky(1) + 1
< 2

kopeiky API

Factory

kopeiky(number|kopeiky, {{ rank?: number }}): Kopeiky - default rank is 2

Instance Methods:

add(number|kopeiky): Kopeiky - add to current kopeiky
sub(number|kopeiky): Kopeiky subtract from current kopeiky
muliply(number): Kopeiky - muliply kopeiky
divide(number): Kopeiky - divide kopeiky
clone(): Kopeiky - return new instance of Kopeiky
valueOf(): number - return primitive number
toNormal(): number - return primitive number
toString(): string - return a number using fixed-point notation toString(): string - for normalize on json.stringify

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago