@fanpian/js-handle
Advanced tools
Comparing version 1.0.8 to 1.0.9
{ | ||
"name": "@fanpian/js-handle", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "js-handle的操作库", | ||
@@ -11,5 +11,5 @@ "author": { | ||
"build": "vue-cli-service build --target lib --name js-handle src/index.ts", | ||
"test": "vue-cli-service test:unit", | ||
"lint": "vue-cli-service lint", | ||
"dev": "vue-cli-service serve" | ||
"dev": "vue-cli-service serve", | ||
"test": "vue-cli-service test:unit" | ||
}, | ||
@@ -21,6 +21,4 @@ "main": "dist/js-handle.umd.min.js", | ||
], | ||
"types": "./dist/types/index.d.ts", | ||
"dependencies": { | ||
"core-js": "^3.6.5", | ||
"lodash": "^4.17.15", | ||
"vue": "^2.6.11" | ||
@@ -34,7 +32,7 @@ }, | ||
"@typescript-eslint/parser": "^2.33.0", | ||
"@vue/cli-plugin-babel": "~4.4.0", | ||
"@vue/cli-plugin-eslint": "~4.4.0", | ||
"@vue/cli-plugin-typescript": "~4.4.0", | ||
"@vue/cli-plugin-unit-mocha": "^4.4.0", | ||
"@vue/cli-service": "~4.4.0", | ||
"@vue/cli-plugin-babel": "^4.4.1", | ||
"@vue/cli-plugin-eslint": "^4.4.1", | ||
"@vue/cli-plugin-typescript": "^4.4.1", | ||
"@vue/cli-plugin-unit-mocha": "^4.4.1", | ||
"@vue/cli-service": "^4.4.1", | ||
"@vue/eslint-config-standard": "^5.1.2", | ||
@@ -50,3 +48,3 @@ "@vue/eslint-config-typescript": "^5.0.2", | ||
"eslint-plugin-vue": "^6.2.2", | ||
"typescript": "~3.9.2", | ||
"typescript": "~3.9.3", | ||
"vue-template-compiler": "^2.6.11" | ||
@@ -58,3 +56,4 @@ }, | ||
"url": "ssh://git@github.com:fanpian/js-handle.git" | ||
} | ||
} | ||
}, | ||
"types": "./dist/types/index.d.ts" | ||
} |
@@ -11,2 +11,4 @@ # js-handle | ||
**因为该会在对象上添加数据,所以请务必在操作前将数据进行深度拷贝** | ||
`until.arrayToTree` | ||
@@ -16,7 +18,7 @@ | ||
`base64Library.toUint8Array` | ||
`until.base64ToUint8Array` | ||
## 将 Unit8 数组转成 Base64 字符串 | ||
`arrayBufferLibrary.toBase64` | ||
`until.byteArrayToBase64` | ||
@@ -40,1 +42,17 @@ ## 验证 validate | ||
`validate.idCard` | ||
### 验证电子邮箱 | ||
`validate.email` | ||
### 验证 IP 地址 | ||
0:仅验证 IPV4 | ||
1:仅验证 IPV6 | ||
2:IPV4 或 IPV6 | ||
`validate.ip` | ||
### 验证 MAC 地址 | ||
`validate.mac` |
@@ -1,2 +0,1 @@ | ||
import { cloneDeep } from 'lodash'; | ||
import { Options, DefaultOption } from './ArrayToTreeOption'; | ||
@@ -17,14 +16,13 @@ | ||
return filterDelete.map(item => { | ||
const target = cloneDeep(item); | ||
target[option.idTo] = item[option.idFrom]; | ||
target[option.labelTo] = item[option.labelFrom]; | ||
target[option.parentTo] = item[option.parentFrom]; | ||
target[option.childTo] = []; | ||
item[option.idTo] = item[option.idFrom]; | ||
item[option.labelTo] = item[option.labelFrom]; | ||
item[option.parentTo] = item[option.parentFrom]; | ||
item[option.childTo] = []; | ||
const disabledItem = option.disabledNodes.find(function find(node) { | ||
return node.key === target[option.idTo]; | ||
return node.key === item[option.idTo]; | ||
}); | ||
if (disabledItem) { | ||
target[disabledItem.fieldName] = disabledItem.fieldVaule; | ||
item[disabledItem.fieldName] = disabledItem.fieldVaule; | ||
} | ||
return target; | ||
return item; | ||
}); | ||
@@ -65,2 +63,3 @@ }; | ||
* 将数组转换成Tree节点 | ||
* 因为该操作会改变对象属性,请务必在传参前进行深度拷贝 | ||
* @param source 源数据 | ||
@@ -71,3 +70,3 @@ * @param option 配置项 | ||
const defaultOption = new DefaultOption(); | ||
const options = cloneDeep(Object.assign({}, defaultOption, option)); | ||
const options = Object.assign({}, defaultOption, option); | ||
@@ -74,0 +73,0 @@ const node = extendArray(source, options); |
@@ -32,2 +32,22 @@ /** | ||
/** | ||
* IPv4验证 | ||
*/ | ||
export const ip_v4_regexp = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; | ||
/** | ||
* IPv6验证 | ||
*/ | ||
export const ip_v6_regexp = /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/i; | ||
/** | ||
* MAC地址的正则表达式 | ||
*/ | ||
export const mac_regexp = /^((([a-f0-9]{2}:){5})|(([a-f0-9]{2}-){5}))[a-f0-9]{2}$/i; | ||
/** | ||
* 电子邮箱的正则表达式 | ||
*/ | ||
export const email_regexp = /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/g; | ||
/** | ||
* 正则表达式集合 | ||
@@ -64,3 +84,22 @@ */ | ||
*/ | ||
most_loose_phone: most_loose_phone_regexp | ||
most_loose_phone: most_loose_phone_regexp, | ||
/** | ||
* IPV4正则表达式 | ||
*/ | ||
ip_v4: ip_v4_regexp, | ||
/** | ||
* IPV6正则表达式 | ||
*/ | ||
ip_v6: ip_v6_regexp, | ||
/** | ||
* MAC地址正则表达式 | ||
*/ | ||
mac: mac_regexp, | ||
/** | ||
* 电子邮箱正则表达式 | ||
*/ | ||
email: email_regexp | ||
}; |
@@ -51,2 +51,34 @@ /** | ||
/** | ||
* IP验证类型 | ||
*/ | ||
export enum IpValidateType { | ||
/** | ||
* 仅IpV4 | ||
*/ | ||
v4 = 0, | ||
/** | ||
* 仅IPV6 | ||
*/ | ||
v6 = 1, | ||
/** | ||
* IPV4或者IPV6 | ||
*/ | ||
v4_or_v6 = 2 | ||
} | ||
/** | ||
* IP地址的验证接口 | ||
*/ | ||
export interface IpValidate { | ||
/** | ||
* | ||
* @param value 需要验证的值 | ||
* @param ipValidateType IP验证类型。0:仅IPV4;1:仅IPV6;2:V4 or V6 | ||
*/ | ||
validate(value: string, ipValidateType?: IpValidateType): boolean; | ||
} | ||
/** | ||
* 使用正则表达式验证字符串 | ||
@@ -53,0 +85,0 @@ * @param reg 正则表达式 |
@@ -5,2 +5,5 @@ import cardNo from './card_no'; | ||
import phone from './phone'; | ||
import ip from './ip'; | ||
import email from './email'; | ||
import mac from './mac'; | ||
@@ -11,5 +14,8 @@ const validate = { | ||
idCard, | ||
phone | ||
phone, | ||
ip, | ||
email, | ||
mac | ||
}; | ||
export default validate; |
@@ -13,12 +13,9 @@ import validate, { PhoneValidate, PhoneValidateType } from '../utils/validate'; | ||
validate: (value: string, phoneValidateType?: PhoneValidateType) => { | ||
const phoneTemp = PhoneValidateType.loose; | ||
const temp = PhoneValidateType[phoneTemp]; | ||
const phoneType = (PhoneValidateType[phoneValidateType || 0] || | ||
0) as number; | ||
if (phoneType === 0) { | ||
const phoneType = | ||
PhoneValidateType[phoneValidateType || PhoneValidateType.sober]; | ||
if (phoneType === PhoneValidateType[PhoneValidateType.sober]) { | ||
return sober_phone_regexp.test(value); | ||
} else if (phoneType === 1) { | ||
} else if (phoneType === PhoneValidateType[PhoneValidateType.loose]) { | ||
return loose_phone_regexp.test(value); | ||
} else if (phoneType === 2) { | ||
} else if (phoneType === PhoneValidateType[PhoneValidateType.mostLoose]) { | ||
return most_loose_phone_regexp.test(value); | ||
@@ -25,0 +22,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
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
2
56
165860
26
1784
1
- Removedlodash@^4.17.15
- Removedlodash@4.17.21(transitive)