8000 GitHub - zoumo/quantity.js
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

zoumo/quantity.js

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
0