Comparing version 0.0.78 to 0.0.79
{ | ||
"name": "a-calc", | ||
"version": "0.0.78", | ||
"description": "JavaScript的字符串四则运算库, 支持格式化操作例如: 千分位格式化, 灵活指定小数点位数", | ||
"version": "0.0.79", | ||
"description": "JavaScript的精准四则运算库,支持格式化操作例如: 千分位格式化, 灵活指定小数点位数", | ||
"main": "./cjs/index.cjs", | ||
@@ -26,3 +26,3 @@ "exports": { | ||
"dev:w": "rollup -c -w --environment build:dev", | ||
"build": "rollup -c --environment build:build", | ||
"build": "rollup -c --environment build:build & yarn test", | ||
"build:w": "rollup -c -w --environment build:build", | ||
@@ -29,0 +29,0 @@ "test": "cross-env ava --verbose --tap test/*.mjs" |
108
README.md
@@ -160,50 +160,62 @@ # a-calc | ||
```js | ||
import { calc, fmt } from 'a-calc' | ||
import { calc, fmt } from "a-calc"; | ||
Vue.mixin({ | ||
methods: { | ||
calc (expr, obj) { | ||
let dataArr = [this] | ||
let _fmt = undefined | ||
let _error = undefined | ||
if (obj !== undefined) { | ||
dataArr.unshift(obj) | ||
if (obj._fmt !== undefined) { | ||
_fmt = obj._fmt | ||
} | ||
if (obj._error !== undefined) { | ||
_error = obj._error | ||
} | ||
} | ||
Vue.mixin( { | ||
methods: { | ||
calc ( expr, obj ) | ||
{ | ||
let dataArr = [this]; | ||
let _fmt = undefined; | ||
let _error = undefined; | ||
if ( obj !== undefined ) | ||
{ | ||
dataArr.unshift( obj ); | ||
if ( obj._fmt !== undefined ) | ||
{ | ||
_fmt = obj._fmt; | ||
} | ||
if ( obj._error !== undefined ) | ||
{ | ||
_error = obj._error; | ||
} | ||
} | ||
return calc(expr, { | ||
_fillData: dataArr, | ||
_error: _error === undefined ? '-' : _error, | ||
_fmt, // 格式化参数在没有字符串格式化的时候才有用 | ||
}) | ||
}, | ||
fmt (expr, obj) { | ||
// 专门格式化的 | ||
let dataArr = [this] | ||
let _fmt = undefined | ||
let _error = undefined | ||
if (obj !== undefined) { | ||
dataArr.unshift(obj) | ||
if (obj._fmt !== undefined) { | ||
_fmt = obj._fmt | ||
} | ||
if (obj._error !== undefined) { | ||
_error = obj._error | ||
} | ||
} | ||
return fmt(expr, | ||
{ | ||
_fillData: dataArr, | ||
_error: _error === undefined ? '-' : _error, | ||
_fmt, | ||
_unit: true | ||
}) | ||
}, | ||
}, | ||
}) | ||
return calc( expr, { | ||
_fillData: dataArr, | ||
_error: _error === undefined ? "-" : _error, | ||
_fmt, // 格式化参数在没有字符串格式化的时候才有用 | ||
} ); | ||
}, | ||
fmt ( expr, obj ) | ||
{ | ||
// 专门格式化的 | ||
let dataArr = [this]; | ||
let _fmt = undefined; | ||
let _error = undefined; | ||
if ( obj !== undefined ) | ||
{ | ||
dataArr.unshift( obj ); | ||
if ( obj._fmt !== undefined ) | ||
{ | ||
_fmt = obj._fmt; | ||
} | ||
if ( obj._error !== undefined ) | ||
{ | ||
_error = obj._error; | ||
} | ||
} | ||
return fmt( expr, | ||
{ | ||
_fillData: dataArr, | ||
_error: _error === undefined ? "-" : _error, | ||
_fmt, | ||
_unit: true | ||
} ); | ||
}, | ||
}, | ||
} ); | ||
``` | ||
@@ -213,3 +225,5 @@ | ||
* 0.0.76 | ||
* 0.0.79 | ||
* 更新文档 | ||
* 0.0.78 | ||
* 支持科学计数法的计算 | ||
@@ -216,0 +230,0 @@ * 完整的单元测试 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
142832
248
0