1.1.3 • Published 6 years ago

quantity.js v1.1.3

Weekly downloads
86
License
Apache-2.0
Repository
github
Last release
6 years ago

Quantity.js

quantity.js provides parser/operations for k8s quantity

It is based on bignumber.js

Load

For Node.js, the library is available from npm registry

$ npm install quantity.js
var quantity = require('quantity.js')

ES6

import * as quantity from "quantity.js"

Use

parse = quantity.parseQuantity
x = parse("100Mi")

parse("0.5Mi").toString() // "512Ki"
parse("1024Ti").toString() // "1Pi"
parse("10241Mi").toString() // "10241Mi"

// add
x.add(parse("50Mi")) // "150Mi"
x.plus(parse("50Mi")) // "150Mi"

// minus
x.minus(parse("50Mi")) // "50Mi"
x.sub(parse("50Mi")) // "50Mi"

// div
x = parse("100")
x.div(parse("50")) // "2"
x.sub(parse("50Mi")) // "50Mi"

// mul
x = parse("2")
x.mul(parse("50")) // "100"
x.times(parse("50")) // "100"

// mod
x = parse("10")
x.mod(parse("3")) // "1"

Build & Test

dev

 yarn run build
 yarn run test

publish

yarn run pub
1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago