xmcommon
Advanced tools
Comparing version 0.0.16 to 0.0.17
@@ -20,4 +20,24 @@ | ||
let ccc = new CNYCurrency(); | ||
let y = new CNYCurrency(null); | ||
m.push(ccc); | ||
for(let mm of m) { | ||
console.log(mm.value, mm.intValue, mm.toString(), mm.format(true, true), mm.Chinese()); | ||
} | ||
for(let i = 0; i < 100000000; i++) { | ||
ccc.intValue = i; | ||
let y = ccc.yuan; | ||
let c = ccc.cent; | ||
let s = y.toString() + '.' + c.toString().padStart(2, '0'); | ||
if (i % 1000 === 0) { | ||
console.log(i); | ||
} | ||
if(s !== ccc.toString()) { | ||
console.log(console.log(ccc.toString(), s, ccc.yuan, ccc.cent)); | ||
} | ||
} | ||
console.log('finish'); |
@@ -42,2 +42,5 @@ | ||
} | ||
else if(paramValue === undefined || paramValue === null) { | ||
r.value = 0; | ||
} | ||
else { | ||
@@ -87,4 +90,7 @@ r.value = 0; | ||
class CNYCurrency { | ||
/** 构造函数 */ | ||
constructor(paramValue) { | ||
/** | ||
* 构造函数 | ||
* @param {number | string | CNYCurrency} paramValue 初始值 | ||
*/ | ||
constructor(paramValue = 0) { | ||
if(typeof paramValue === 'CNYCurrency') { | ||
@@ -109,2 +115,3 @@ this.m_IntValue = paramValue.m_IntValue; | ||
} | ||
/** 货币值 */ | ||
@@ -114,2 +121,28 @@ get value() { | ||
} | ||
/** | ||
* 赋值 | ||
* @param {number | string | CNYCurrency} paramValue 新值 | ||
* @return {CNYCurrency} 返回当前对象 | ||
*/ | ||
assign(paramValue = 0) { | ||
if(typeof paramValue === 'CNYCurrency') { | ||
this.m_IntValue = paramValue.m_IntValue; | ||
this.m_ErrFlag = paramValue.m_ErrFlag; | ||
this.m_ErrMsg = paramValue.m_ErrMsg; | ||
} | ||
else { | ||
let v = Parse(paramValue); | ||
if(v.errFlag) { | ||
this.m_IntValue = 0; | ||
this.m_ErrFlag = true; | ||
this.m_ErrMsg = v.errMsg; | ||
} | ||
else { | ||
this.m_IntValue = v.value; | ||
this.m_ErrFlag = v.errFlag; | ||
this.m_ErrMsg = ''; | ||
} | ||
} | ||
return this; | ||
} | ||
/** 货币整数值,精确到分 */ | ||
@@ -119,2 +152,6 @@ get intValue() { | ||
} | ||
// set intValue(paramValue) { | ||
// this.m_IntValue = paramValue; | ||
// } | ||
/** 是否有错 */ | ||
@@ -322,2 +359,1 @@ get isErr() { | ||
exports.CNYCurrency = CNYCurrency; | ||
{ | ||
"name": "xmcommon", | ||
"version": "0.0.16", | ||
"description": "javascript common lib for es6", | ||
"main": "index.js", | ||
"types": "./types/xmcommon/index.d.ts", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/zdhsoft/xmcommon.git" | ||
}, | ||
"keywords": [ | ||
"common", | ||
"lib" | ||
], | ||
"author": "zdhsoft", | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/zdhsoft/xmcommon/blob/master/LICENSE" | ||
} | ||
], | ||
"dependencies": { | ||
"@types/node": "^10.14.4", | ||
"lodash": "^4.17.11" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/zdhsoft/xmcommon/issues" | ||
}, | ||
"homepage": "https://github.com/zdhsoft/xmcommon#readme" | ||
"name": "xmcommon", | ||
"version": "0.0.17", | ||
"description": "javascript common lib for es6", | ||
"main": "index.js", | ||
"types": "./types/xmcommon/index.d.ts", | ||
"scripts": { | ||
"testcurr": "node ./example/testcurr.js", | ||
"test": "node ./example/test.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/zdhsoft/xmcommon.git" | ||
}, | ||
"keywords": [ | ||
"common", | ||
"lib" | ||
], | ||
"author": "zdhsoft", | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/zdhsoft/xmcommon/blob/master/LICENSE" | ||
} | ||
], | ||
"dependencies": { | ||
"@types/node": "^10.14.4", | ||
"lodash": "^4.17.11" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/zdhsoft/xmcommon/issues" | ||
}, | ||
"homepage": "https://github.com/zdhsoft/xmcommon#readme" | ||
} |
# xmcommon | ||
一个js 通用库 | ||
一个js 通用库, 将一些常用的函数之类的,移到这里方便使用 | ||
@@ -8,2 +8,6 @@ - github: https://github.com/zdhsoft/xmcommon | ||
## 目录 | ||
[TOC] | ||
## 安装 | ||
@@ -30,5 +34,15 @@ | ||
# 版本变更说明 | ||
## 0.0.17 | ||
- 2019-06-24 | ||
- \* 增加CNYCurrency构造函数默认值0, 如果传入null或undefined也视为0, 测试CNYCurrency 1-100000000之间的值 | ||
- \+ CNYCurrency 增加assign赋值函数 | ||
- \* 将index.d.ts中的utils.JsonParse的定义返回值由{}改为any | ||
## 0.0.16 | ||
- 2019-06-03 | ||
- \* 修复生成大写的bug,主要是百==>佰 千==>仟 | ||
```js | ||
@@ -51,2 +65,3 @@ let m = []; | ||
for(let mm of m) { | ||
@@ -65,3 +80,5 @@ console.log(mm.value, mm.intValue, mm.toString(), mm.format(true, true), mm.Chinese()); | ||
``` | ||
## 0.0.15 | ||
- 2019-06-01 | ||
@@ -71,2 +88,3 @@ - \+ 增加CNYCurrency 中文货币类 | ||
## 0.0.14 | ||
- 2019-04-20 | ||
@@ -78,5 +96,7 @@ - \* 优化index.d.ts部分注释, 将object变化any, 将[string]变化string[] 这样在typescript的可以正常使用 | ||
## 0.0.13 | ||
- 2019-03-28 | ||
- \* 优化index.d.ts部分注释 | ||
- \+ utils增加options对参数解析的方法 用于node启动后,传入参数的接收处理 | ||
```js | ||
@@ -89,3 +109,5 @@ let {utils} = require("../lib/utils"); | ||
``` | ||
运行结果 | ||
```json | ||
@@ -107,2 +129,3 @@ { | ||
## 0.0.12 | ||
- 2019-02-18 | ||
@@ -113,3 +136,2 @@ - \+ 修改readme.md说明 | ||
- 2019-02-18 | ||
@@ -119,2 +141,3 @@ - \+ 增加index.d.ts,使用的时候,可以在vscode有代码提示说明了 | ||
## 0.0.9 | ||
- 2019-02-10 | ||
@@ -126,2 +149,3 @@ - \+ datetimeUtils 增加diffLocalDays,CalcLocalDaysByUTC,CalcLocalDaysByDate等函数 | ||
## 0.0.8 | ||
- 2018-12-21 | ||
@@ -131,2 +155,3 @@ - \+ datetimeUtils 补全上次未能提交的函数 | ||
## 0.0.7 | ||
- 2018-12-12 | ||
@@ -136,6 +161,9 @@ - \+ datetimeUtils 增加了ToLocalTime,ToUTCTime,getTodayZeroTime,isSameDay等函数 | ||
## 0.0.6 | ||
- 2018-11-01 | ||
- \+ 增加了bitUtil对整数位处理函数,可以用于标志位处理 | ||
- \+ 增加utils中的ToInteger, ToFloat, JsonParse和mkdirsSync等几个函数 | ||
## 0.0.5 | ||
- 2018-10-31 | ||
@@ -145,4 +173,6 @@ - \* 更新依赖包 lodash 4.17.10 -->4.17.11 | ||
## 0.0.4 | ||
- 2018-10-31 | ||
- \+ 增加日志前缀缩短处理 | ||
```js | ||
@@ -155,4 +185,7 @@ //文件:example/test.js | ||
``` | ||
--- | ||
## 0.0.3 | ||
- 初始版本 |
@@ -362,3 +362,3 @@ // Type definitions for xmcommon 0.0 | ||
*/ | ||
static JsonParse (paramJsonString:string):{}; | ||
static JsonParse (paramJsonString:string): any; | ||
/** | ||
@@ -386,7 +386,7 @@ * 创建目录 | ||
/** 名称或tag */ | ||
name: string; | ||
readonly name: string; | ||
trace(...paramLog:any[]):void; | ||
debug(...paramLog:any[]):void; | ||
info(...paramLog:any[]):void; | ||
warn(...paramLog:any[]):void; | ||
info (...paramLog:any[]):void; | ||
warn (...paramLog:any[]):void; | ||
error(...paramLog:any[]):void; | ||
@@ -1007,3 +1007,2 @@ fatal(...paramLog:any[]):void; | ||
/** | ||
@@ -1044,3 +1043,3 @@ * 货币类 | ||
*/ | ||
class CNYCurrency { | ||
class CNYCurrency { | ||
/** */ | ||
@@ -1051,13 +1050,19 @@ /** | ||
*/ | ||
public constructor(paramValue: number | string | CNYCurrency); | ||
public constructor(paramValue: number | string | CNYCurrency | null | undefined); | ||
/** 货币值 */ | ||
readonly value : number; | ||
public readonly value : number; | ||
/** 货币整数值,精确到分 */ | ||
readonly intValue : number; | ||
public readonly intValue : number; | ||
/** 是否有错 */ | ||
readonly isErr : boolean | ||
public readonly isErr : boolean | ||
/** 错误信息 */ | ||
readonly errMsg : string; | ||
public readonly errMsg : string; | ||
/** 重置为0 */ | ||
Reset() : void; | ||
public Reset() : void; | ||
/** | ||
* 赋值 | ||
* @param paramValue 新值 | ||
* @return 返回当前对象 | ||
*/ | ||
public assign(paramValue: number | string | CNYCurrency | null | undefined): CNYCurrency; | ||
/** | ||
@@ -1068,3 +1073,3 @@ * 加一个值 | ||
*/ | ||
add(paramNumber: number | string | CNYCurrency): CNYCurrency; | ||
public add(paramNumber: number | string | CNYCurrency | null | undefined): CNYCurrency; | ||
/** | ||
@@ -1075,3 +1080,3 @@ * 自加一个值 | ||
*/ | ||
selfAdd(paramNumber: number | string | CNYCurrency): CNYCurrency; | ||
public selfAdd(paramNumber: number | string | CNYCurrency | null | undefined): CNYCurrency; | ||
/** | ||
@@ -1082,3 +1087,3 @@ * 减一个值 | ||
*/ | ||
sub(paramNumber: number | string | CNYCurrency): CNYCurrency; | ||
public sub(paramNumber: number | string | CNYCurrency | null | undefined): CNYCurrency; | ||
/** | ||
@@ -1089,3 +1094,3 @@ * 自减一个值 | ||
*/ | ||
selfSub(paramNumber: number | string | CNYCurrency): CNYCurrency; | ||
public selfSub(paramNumber: number | string | CNYCurrency | null | undefined): CNYCurrency; | ||
/** | ||
@@ -1096,3 +1101,3 @@ * 乘一个值 | ||
*/ | ||
mul(paramNumber: number | string | CNYCurrency): CNYCurrency; | ||
public mul(paramNumber: number | string | CNYCurrency | null | undefined): CNYCurrency; | ||
/** | ||
@@ -1103,3 +1108,3 @@ * 自乘一个值 | ||
*/ | ||
selfMul(paramNumber: number | string | CNYCurrency): CNYCurrency; | ||
public selfMul(paramNumber: number | string | CNYCurrency | null | undefined): CNYCurrency; | ||
/** | ||
@@ -1110,3 +1115,3 @@ * 除以一个值 | ||
*/ | ||
div(paramNumber: number | string | CNYCurrency): CNYCurrency; | ||
public div(paramNumber: number | string | CNYCurrency | null | undefined): CNYCurrency; | ||
/** | ||
@@ -1117,3 +1122,3 @@ * 自除以一个值 | ||
*/ | ||
selfDiv(paramNumber: number | string | CNYCurrency): CNYCurrency; | ||
public selfDiv(paramNumber: number | string | CNYCurrency | null | undefined): CNYCurrency; | ||
/** | ||
@@ -1123,7 +1128,7 @@ * 货币的整数部分 | ||
*/ | ||
readonly yuan: number; | ||
public readonly yuan: number; | ||
/** | ||
* 货币的小数部分,单位为分 | ||
*/ | ||
readonly cent: number; | ||
public readonly cent: number; | ||
/** | ||
@@ -1133,3 +1138,3 @@ * 生成中文大写数字 | ||
*/ | ||
Chinese(): string; | ||
public Chinese(): string; | ||
/** | ||
@@ -1141,4 +1146,4 @@ * 格式化输出 | ||
*/ | ||
format(paramUseSymbol: boolean, paramCNYsplit: boolean): string; | ||
public format(paramUseSymbol: boolean, paramCNYsplit: boolean): string; | ||
} | ||
} |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
124310
3659
1
177