vue-lazy-calc
this is a just support simple calculation in lazy way.
(inspired by lodash)
features
- vue friendly
- strong typed
- lazy evaluation
- chaining methods
Install
npm install vue-lazy-calc --save |
Quick Start
import lzCalc from "vue-lazy-calc" |
Methods
- this.\$lzCalc in Component context.
- Vue.\$lzCalc in global.
API list
interface ILazyCalc { |
- lazy => init a new instance with optional initValue
- add/subtract/divide/multiple => + - * / (simple calculation)
- round/floor/ceil => deal with precision of the float number
- value => excute the declared method chain with optional fallBack value(if the result is NaN)
- do => accept a custormized function for the number
Examples
(1+3)*2/3 with precision 2
const result = this.$lzCalc |
- when declare the result variable, no calculation excuted until value()
- you can reuse the declare variable