super-toolkit 1.0.1 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -9
- package/index.d.ts +35 -90
- package/index.ts +13 -7
- package/lib/super-toolkit.min.js +1 -1
- package/package.json +2 -2
- package/src/data.ts +39 -7
- package/src/event.ts +2 -2
- package/src/random.ts +19 -0
- package/test.html +0 -20
package/README.md
CHANGED
|
@@ -42,20 +42,29 @@ npm i super-toolkit -S
|
|
|
42
42
|
* @return:{Array}
|
|
43
43
|
*/
|
|
44
44
|
```
|
|
45
|
-
#####
|
|
45
|
+
##### deepClone
|
|
46
46
|
```js
|
|
47
47
|
/**
|
|
48
|
-
* @desc
|
|
49
|
-
* @param:{
|
|
50
|
-
* @return:{
|
|
48
|
+
* @desc:深克隆
|
|
49
|
+
* @param:{Any} value
|
|
50
|
+
* @return:{Any}
|
|
51
51
|
*/
|
|
52
52
|
```
|
|
53
|
-
#####
|
|
53
|
+
##### isEmpty
|
|
54
54
|
```js
|
|
55
55
|
/**
|
|
56
|
-
* @desc
|
|
57
|
-
* @param:{
|
|
58
|
-
* @return:{
|
|
56
|
+
* @desc:判断是否为空字符串、null、undefined、空对象、空数组
|
|
57
|
+
* @param:{String | Number | Array | Object | null | undefined} value
|
|
58
|
+
* @return:{Boolean}
|
|
59
|
+
*/
|
|
60
|
+
```
|
|
61
|
+
##### group
|
|
62
|
+
```js
|
|
63
|
+
/**
|
|
64
|
+
* @desc:数据分组筛选
|
|
65
|
+
* @param:{Array} array
|
|
66
|
+
* @param:{Array} keys
|
|
67
|
+
* @return:{Array}
|
|
59
68
|
*/
|
|
60
69
|
```
|
|
61
70
|
##### getElementContent
|
|
@@ -67,7 +76,7 @@ npm i super-toolkit -S
|
|
|
67
76
|
* @return:{String} content
|
|
68
77
|
*/
|
|
69
78
|
```
|
|
70
|
-
#####
|
|
79
|
+
##### onDebounce or onThrottle
|
|
71
80
|
```js
|
|
72
81
|
/**
|
|
73
82
|
* @desc:防抖 or 节流函数
|
|
@@ -137,6 +146,21 @@ npm i super-toolkit -S
|
|
|
137
146
|
* @return:{void}
|
|
138
147
|
*/
|
|
139
148
|
```
|
|
149
|
+
##### getRandomColor
|
|
150
|
+
```js
|
|
151
|
+
/**
|
|
152
|
+
* @desc:随机生成16进制颜色
|
|
153
|
+
* @return:{String}
|
|
154
|
+
*/
|
|
155
|
+
```
|
|
156
|
+
##### getRandomString
|
|
157
|
+
```js
|
|
158
|
+
/**
|
|
159
|
+
* @desc:随机生成指定长度的字符串
|
|
160
|
+
* @param:{Number} size
|
|
161
|
+
* @return:{String}
|
|
162
|
+
*/
|
|
163
|
+
```
|
|
140
164
|
##### validate
|
|
141
165
|
```js
|
|
142
166
|
/**
|
package/index.d.ts
CHANGED
|
@@ -1,125 +1,70 @@
|
|
|
1
1
|
|
|
2
|
-
type Format='YYYY/MM/DD HH:MM:SS' | 'YYYY-MM-DD HH:MM:SS' | 'YYYY/MM/DD' | 'YYYY-MM-DD' | 'MM/DD' | 'MM-DD' | 'MM' | 'DD'
|
|
3
|
-
|
|
2
|
+
type Format = 'YYYY/MM/DD HH:MM:SS' | 'YYYY-MM-DD HH:MM:SS' | 'YYYY/MM/DD' | 'YYYY-MM-DD' | 'MM/DD' | 'MM-DD' | 'MM' | 'DD'
|
|
3
|
+
declare module "super-toolkit" {
|
|
4
4
|
/** 数组去重 */
|
|
5
|
-
unique
|
|
5
|
+
export const unique: <T>(oldArr: Record<string, any>[], key?: string) => T
|
|
6
6
|
/** 数组升序排序 */
|
|
7
|
-
minSort
|
|
7
|
+
export const minSort: <T extends Record<string, any>[] | (string | number)[]>(arr: T, key: string) => T
|
|
8
8
|
/** 数组降序排序 */
|
|
9
|
-
maxSort
|
|
9
|
+
export const maxSort: <T extends Record<string, any>[] | (string | number)[]>(arr: T, key: string) => T
|
|
10
10
|
|
|
11
|
-
/** 获取指定长度的随机数 */
|
|
12
|
-
getRandomSixNum:(size: number) => string,
|
|
13
11
|
/** 深克隆 */
|
|
14
|
-
deepClone
|
|
12
|
+
export const deepClone: <T>(val: T) => T
|
|
13
|
+
/** 判断是否为空字符串、null、undefined、空对象、空数组 */
|
|
14
|
+
export const isEmpty: (value: string | number | any[] | Record<string, any> | null | undefined) => boolean
|
|
15
|
+
/** 数据分组筛选 */
|
|
16
|
+
export const group: <T extends Record<string, any>[] = any[]>(array: T, keys: string[]) => {group: string;data: T;}[]
|
|
15
17
|
|
|
16
18
|
/** 获取指定节点内容 */
|
|
17
|
-
getElementContent:(msg: string, el: string) => string | null
|
|
19
|
+
export const getElementContent: (msg: string, el: string) => string | null
|
|
18
20
|
|
|
19
21
|
/** 防抖 */
|
|
20
|
-
|
|
22
|
+
export const onDebounce: (fn: Function, wait: number) => (this: Window) => void
|
|
21
23
|
/** 节流 */
|
|
22
|
-
|
|
24
|
+
export const onThrottle: (fn: Function, wait: number) => (this: Window) => void
|
|
23
25
|
|
|
24
26
|
/** 根据url获取指定的application类型 */
|
|
25
|
-
getApplication:(url: string) => string | null
|
|
26
|
-
/** file转base64 */
|
|
27
|
-
fileToBase64: (file: File | Blob) => Promise<string>,
|
|
28
|
-
/** base64转blob */
|
|
29
|
-
base64ToBlob:(dataURL: string, mimeType?: string) => Blob,
|
|
30
|
-
/** blob转File */
|
|
31
|
-
blobToFile: (blob: Blob, fileName: string, mimeType: string) => File,
|
|
32
|
-
/** base64转file */
|
|
33
|
-
base64ToFile:(dataURL: string, fileName: string, mimeType?: string) => File,
|
|
34
|
-
|
|
35
|
-
/** 获取浏览器localStorage的数据 */
|
|
36
|
-
getLocalStorage:<T>(key: string) => T | null,
|
|
37
|
-
/** 设置浏览器localStorage的数据 */
|
|
38
|
-
setLocalStorage:<T = any>(key: string, value: T) => never,
|
|
39
|
-
|
|
40
|
-
/** 验证整数 */
|
|
41
|
-
validateInt:(value: string) => boolean,
|
|
42
|
-
/** 验证正整数 */
|
|
43
|
-
validateRightInt:(value: string) => boolean,
|
|
44
|
-
/** 验证负整数 */
|
|
45
|
-
alidateLeftInt:(value: string) => boolean,
|
|
46
|
-
/** 验证手机号 */
|
|
47
|
-
validatePhone:(value: string) => boolean,
|
|
48
|
-
/** 验证整数 */
|
|
49
|
-
validateIDCard:(value: string) => boolean,
|
|
50
|
-
/** 验证邮箱地址 */
|
|
51
|
-
validateEmail:(value: string) => boolean,
|
|
52
|
-
/** 验证金额 */
|
|
53
|
-
validateAmount:(value: string) => boolean,
|
|
54
|
-
/** 验证邮政编码 */
|
|
55
|
-
validatePostCode:(value: string) => boolean,
|
|
56
|
-
|
|
57
|
-
/** 获取指定格式的时间 */
|
|
58
|
-
getDate:(date: string | Date, format: Format, day?: number) => string,
|
|
59
|
-
/** 获取当月指定周数的开始时间与结束时间 */
|
|
60
|
-
getMonday:(type: "s" | "e", start?: number | undefined) => string,
|
|
61
|
-
/** 获取时间对应的星期几 */
|
|
62
|
-
getWeek:(date: string | Date) => string
|
|
63
|
-
}
|
|
64
|
-
declare const superToolkit:SuperToolkit
|
|
65
|
-
declare module "superToolkit" {
|
|
66
|
-
/** 数组去重 */
|
|
67
|
-
export const unique:<T>(oldArr: Record<string, any>[], key?: string) => T
|
|
68
|
-
/** 数组升序排序 */
|
|
69
|
-
export const minSort:<T extends Record<string, any>[] | (string | number)[]>(arr: T, key: string) => T
|
|
70
|
-
/** 数组降序排序 */
|
|
71
|
-
export const maxSort:<T extends Record<string, any>[] | (string | number)[]>(arr: T, key: string) => T
|
|
72
|
-
|
|
73
|
-
/** 获取指定长度的随机数 */
|
|
74
|
-
export const getRandomSixNum:(size: number) => string
|
|
75
|
-
/** 深克隆 */
|
|
76
|
-
export const deepClone:<T>(val: T) => T
|
|
77
|
-
|
|
78
|
-
/** 获取指定节点内容 */
|
|
79
|
-
export const getElementContent:(msg: string, el: string) => string | null
|
|
80
|
-
|
|
81
|
-
/** 防抖 */
|
|
82
|
-
export const debounce:(fn: Function, wait: number) => (this: Window) => void
|
|
83
|
-
/** 节流 */
|
|
84
|
-
export const throttle:(fn: Function, wait: number) => (this: Window) => void
|
|
85
|
-
|
|
86
|
-
/** 根据url获取指定的application类型 */
|
|
87
|
-
export const getApplication:(url: string) => string | null
|
|
27
|
+
export const getApplication: (url: string) => string | null
|
|
88
28
|
/** file转base64 */
|
|
89
29
|
export const fileToBase64: (file: File | Blob) => Promise<string>
|
|
90
30
|
/** base64转blob */
|
|
91
|
-
export const base64ToBlob:(dataURL: string, mimeType?: string) => Blob
|
|
31
|
+
export const base64ToBlob: (dataURL: string, mimeType?: string) => Blob
|
|
92
32
|
/** blob转File */
|
|
93
33
|
export const blobToFile: (blob: Blob, fileName: string, mimeType: string) => File
|
|
94
34
|
/** base64转file */
|
|
95
|
-
export const base64ToFile:(dataURL: string, fileName: string, mimeType?: string) => File
|
|
35
|
+
export const base64ToFile: (dataURL: string, fileName: string, mimeType?: string) => File
|
|
96
36
|
|
|
97
37
|
/** 获取浏览器localStorage的数据 */
|
|
98
|
-
export const getLocalStorage
|
|
38
|
+
export const getLocalStorage: <T>(key: string) => T | null
|
|
99
39
|
/** 设置浏览器localStorage的数据 */
|
|
100
|
-
export const setLocalStorage
|
|
40
|
+
export const setLocalStorage: <T = any>(key: string, value: T) => void
|
|
41
|
+
|
|
42
|
+
/** 随机生成指定长度的字符串 */
|
|
43
|
+
export const getRandomString: (size: number) => string
|
|
44
|
+
/** 随机生成16进制颜色 */
|
|
45
|
+
export const getRandomColor: () => string
|
|
101
46
|
|
|
102
47
|
/** 验证整数 */
|
|
103
|
-
export const validateInt:(value: string) => boolean
|
|
48
|
+
export const validateInt: (value: string) => boolean
|
|
104
49
|
/** 验证正整数 */
|
|
105
|
-
export const validateRightInt:(value: string) => boolean
|
|
50
|
+
export const validateRightInt: (value: string) => boolean
|
|
106
51
|
/** 验证负整数 */
|
|
107
|
-
export const validateLeftInt:(value: string) => boolean
|
|
52
|
+
export const validateLeftInt: (value: string) => boolean
|
|
108
53
|
/** 验证手机号 */
|
|
109
|
-
export const validatePhone:(value: string) => boolean
|
|
110
|
-
/**
|
|
111
|
-
export const validateIDCard:(value: string) => boolean
|
|
54
|
+
export const validatePhone: (value: string) => boolean
|
|
55
|
+
/** 验证身份证号 */
|
|
56
|
+
export const validateIDCard: (value: string) => boolean
|
|
112
57
|
/** 验证邮箱地址 */
|
|
113
|
-
export const validateEmail:(value: string) => boolean
|
|
58
|
+
export const validateEmail: (value: string) => boolean
|
|
114
59
|
/** 验证金额 */
|
|
115
|
-
export const validateAmount:(value: string) => boolean
|
|
60
|
+
export const validateAmount: (value: string) => boolean
|
|
116
61
|
/** 验证邮政编码 */
|
|
117
|
-
export const validatePostCode:(value: string) => boolean
|
|
62
|
+
export const validatePostCode: (value: string) => boolean
|
|
118
63
|
|
|
119
64
|
/** 获取指定格式的时间 */
|
|
120
|
-
export const getDate:(date: string | Date, format: Format, day?: number) => string
|
|
65
|
+
export const getDate: (date: string | Date, format: Format, day?: number) => string
|
|
121
66
|
/** 获取当月指定周数的开始时间与结束时间 */
|
|
122
|
-
export const getMonday:(type: "s" | "e", start?: number | undefined) => string
|
|
67
|
+
export const getMonday: (type: "s" | "e", start?: number | undefined) => string
|
|
123
68
|
/** 获取时间对应的星期几 */
|
|
124
|
-
export const getWeek:(date: string | Date) => string
|
|
69
|
+
export const getWeek: (date: string | Date) => string
|
|
125
70
|
}
|
package/index.ts
CHANGED
|
@@ -4,16 +4,17 @@ import * as elelemt from './src/element'
|
|
|
4
4
|
import * as event from './src/event'
|
|
5
5
|
import * as file from './src/file'
|
|
6
6
|
import * as localStorage from './src/localStorage'
|
|
7
|
+
import * as random from './src/random'
|
|
7
8
|
import * as reg from './src/reg'
|
|
8
9
|
import * as time from './src/time'
|
|
9
10
|
|
|
10
|
-
|
|
11
11
|
const {unique,minSort,maxSort}=array
|
|
12
|
-
const {
|
|
12
|
+
const {deepClone,isEmpty,group}=data
|
|
13
13
|
const {getElementContent}=elelemt
|
|
14
|
-
const {
|
|
14
|
+
const {onDebounce,onThrottle}=event
|
|
15
15
|
const { getApplication,fileToBase64,base64ToBlob,blobToFile,base64ToFile } = file
|
|
16
16
|
const { getLocalStorage, setLocalStorage } = localStorage
|
|
17
|
+
const {getRandomColor,getRandomString} = random
|
|
17
18
|
const {validateInt,validateRightInt,validateLeftInt,validatePhone,validateIDCard,validateEmail,validateAmount,validatePostCode}=reg
|
|
18
19
|
const { getDate, getMonday, getWeek } = time
|
|
19
20
|
const superToolkit = {
|
|
@@ -23,8 +24,9 @@ const superToolkit = {
|
|
|
23
24
|
...event,
|
|
24
25
|
...file,
|
|
25
26
|
...localStorage,
|
|
27
|
+
...random,
|
|
28
|
+
...reg,
|
|
26
29
|
...time,
|
|
27
|
-
...reg
|
|
28
30
|
}
|
|
29
31
|
export {
|
|
30
32
|
superToolkit as default,
|
|
@@ -33,13 +35,14 @@ export {
|
|
|
33
35
|
minSort,
|
|
34
36
|
maxSort,
|
|
35
37
|
|
|
36
|
-
getRandomSixNum,
|
|
37
38
|
deepClone,
|
|
39
|
+
isEmpty,
|
|
40
|
+
group,
|
|
38
41
|
|
|
39
42
|
getElementContent,
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
onDebounce,
|
|
45
|
+
onThrottle,
|
|
43
46
|
|
|
44
47
|
getApplication,
|
|
45
48
|
fileToBase64,
|
|
@@ -50,6 +53,9 @@ export {
|
|
|
50
53
|
getLocalStorage,
|
|
51
54
|
setLocalStorage,
|
|
52
55
|
|
|
56
|
+
getRandomColor,
|
|
57
|
+
getRandomString,
|
|
58
|
+
|
|
53
59
|
validateInt,
|
|
54
60
|
validateRightInt,
|
|
55
61
|
validateLeftInt,
|
package/lib/super-toolkit.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["super-toolkit"]=e():t["super-toolkit"]=e()}(this,(function(){return function(){"use strict";var t={d:function(e,n){for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{base64ToBlob:function(){return K},base64ToFile:function(){return V},blobToFile:function(){return Q},debounce:function(){return W},deepClone:function(){return U},default:function(){return dt},fileToBase64:function(){return G},getApplication:function(){return X},getDate:function(){return lt},getElementContent:function(){return q},getLocalStorage:function(){return tt},getMonday:function(){return ft},getRandomSixNum:function(){return _},getWeek:function(){return st},maxSort:function(){return z},minSort:function(){return B},setLocalStorage:function(){return et},throttle:function(){return Z},unique:function(){return J},validateAmount:function(){return ut},validateEmail:function(){return ct},validateIDCard:function(){return at},validateInt:function(){return nt},validateLeftInt:function(){return rt},validatePhone:function(){return it},validatePostCode:function(){return pt},validateRightInt:function(){return ot}});var n={};t.r(n),t.d(n,{maxSort:function(){return s},minSort:function(){return f},unique:function(){return l}});var o={};t.r(o),t.d(o,{deepClone:function(){return y},getRandomSixNum:function(){return m}});var r={};t.r(r),t.d(r,{getElementContent:function(){return g}});var i={};t.r(i),t.d(i,{debounce:function(){return v},throttle:function(){return b}});var a={};t.r(a),t.d(a,{base64ToBlob:function(){return w},base64ToFile:function(){return x},blobToFile:function(){return S},fileToBase64:function(){return h},getApplication:function(){return D}});var c={};t.r(c),t.d(c,{getLocalStorage:function(){return M},setLocalStorage:function(){return O}});var u={};t.r(u),t.d(u,{validateAmount:function(){return E},validateEmail:function(){return A},validateIDCard:function(){return T},validateInt:function(){return j},validateLeftInt:function(){return P},validatePhone:function(){return Y},validatePostCode:function(){return C},validateRightInt:function(){return k}});var p={};function l(t,e){if(e){for(var n=JSON.parse(JSON.stringify(t)),o=0;o<n.length;o++)for(var r=o+1;r<n.length;r++)n[o][e]==n[r][e]&&(n.splice(r,1),r--);return n}for(var i=JSON.parse(JSON.stringify(t)),a=0;a<i.length;a++)for(var c=a+1;c<i.length;c++)i[a]==i[c]&&(i.splice(c,1),c--);return i}function f(t,e){if(e){var n=t;return n.sort((function(t,n){var o=t[e],r=n[e],i=0;return o>r?i=1:o<r&&(i=-1),i})),n}return t.sort((function(t,e){return t-e}))}function s(t,e){if(e){var n=t;return n.sort((function(t,n){var o=t[e],r=n[e],i=0;return o>r?i=1:o<r&&(i=-1),-1*i})),n}return t.sort((function(t,e){return e-t}))}function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}t.r(p),t.d(p,{getDate:function(){return N},getMonday:function(){return F},getWeek:function(){return I}});var m=function(t){for(var e="",n=0;n<t;n++)e+=String(Math.floor(10*Math.random()));return e};function y(t){if(Array.isArray(t)){for(var e=[],n=0;n<t.length;n++)e[n]=y(t[n]);return e}if("object"===d(t)&&null!==t){var o={};for(var r in t)o[r]=y(t[r]);return o}return t}function g(t,e){var n=new RegExp("<"+e+"[\\s\\S]*<\\/"+e+">");console.log(n);var o=n.exec(t);return null!=o&&o.length?o[0]:null}function v(t,e){var n=null;return function(){var o=this;clearTimeout(n),n=setTimeout((function(){t.apply(o,arguments)}),e)}}function b(t,e){var n,o=new Date;return function(){var r=this,i=new Date;clearTimeout(n),i-o>=e?(t.apply(r,arguments),o=i):n=setTimeout((function(){t.apply(r,arguments)}),e)}}function h(t){return new Promise((function(e,n){var o=new FileReader;o.readAsDataURL(t),o.onload=function(t){var n;e(null===(n=t.target)||void 0===n?void 0:n.result)}}))}function w(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=t.split(","),o=n[0].match(/:(.*?);/)[1],r=atob(n[1]),i=r.length,a=new Uint8Array(i);i--;)a[i]=r.charCodeAt(i);return new Blob([a],{type:e||o})}function S(t,e,n){return new File([t],e,{type:n})}function x(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=t.split(","),r=o[0].match(/:(.*?);/)[1],i=atob(o[1]),a=i.length,c=new Uint8Array(a);a--;)c[a]=i.charCodeAt(a);return new File([c],e,{type:n||r})}function D(t){var e=t.split(".").pop(),n=[{type:"doc",application:"application/msword"},{type:"docx",application:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},{type:"dot",application:"application/msword"},{type:"dotx",application:"application/vnd.openxmlformats-officedocument.wordprocessingml.template"},{type:"xls",application:"application/vnd.ms-excel"},{type:"xlsx",application:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},{type:"ppt",application:"application/vnd.ms-powerpoint"},{type:"pptx",application:"application/vnd.openxmlformats-officedocument.presentationml.presentation"},{type:"pdf",application:"application/pdf"},{type:"txt",application:"text/plain"},{type:"gif",application:"image/gif"},{type:"jpeg",application:"image/jpeg"},{type:"jpg",application:"image/jpeg"},{type:"png",application:"image/png"},{type:"css",application:"text/css"},{type:"html",application:"text/html"},{type:"htm",application:"text/html"},{type:"xsl",application:"text/xml"},{type:"xml",application:"text/xml"},{type:"mpeg",application:"video/mpeg"},{type:"mpg",application:"video/mpeg"},{type:"avi",application:"video/x-msvideo"},{type:"movie",application:"video/x-sgi-movie"},{type:"bin",application:"application/octet-stream"},{type:"exe",application:"application/octet-stream"},{type:"so",application:"application/octet-stream"},{type:"dll",application:"application/octet-stream"},{type:"ai",application:"application/postscript"},{type:"dir",application:"application/x-director"},{type:"js",application:"application/x-javascript"},{type:"swf",application:"application/x-shockwave-flash"},{type:"xhtml",application:"application/xhtml+xml"},{type:"xht",application:"application/xhtml+xml"},{type:"zip",application:"application/zip"},{type:"mid",application:"audio/midi"},{type:"midi",application:"audio/midi"},{type:"mp3",application:"audio/mpeg"},{type:"rm",application:"audio/x-pn-realaudio"},{type:"rpm",application:"audio/x-pn-realaudio-plugin"},{type:"wav",application:"audio/x-wav"},{type:"bmp",application:"image/bmp"}].find((function(t){return t.type==e}));return(null==n?void 0:n.type)||null}var M=function(t){if(!window)throw new Error("非web环境禁止使用localStorage");if(!t)throw new Error("key的值不能为空");var e=localStorage.getItem(t);return e?JSON.parse(e):null},O=function(t,e){if(!window)throw new Error("非web环境禁止使用localStorage");if(!t||!e)throw new Error("key or value的值不能为空");var n=JSON.stringify(e);localStorage.setItem(t,n)};function j(t){return/^-?[1-9]\d*|0$/.test(t)}function k(t){return/^[1-9]\d*$/.test(t)}function P(t){return/^-[1-9]\d*$/.test(t)}function Y(t){return/^(86)?1[3-9]\d{9}$/.test(t)}function T(t){return/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}(\d|X|x)$/.test(t)}function A(t){return/^[\w.-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(t)}function E(t){return/^[0-9]+(.[0-9]{1,2})?$/.test(t)}function C(t){return/[1-9]\d{5}(?!\d)/.test(t)}function I(t){var e="";switch(new Date(t).getDay()){case 0:e="周日";break;case 1:e="周一";break;case 2:e="周二";break;case 3:e="周三";break;case 4:e="周四";break;case 5:e="周五";break;case 6:e="周六"}return e}function F(t,e){if(!t)throw new Error("getMonday的type参数必传");var n=new Date,o=n.getTime(),r=n.getDay(),i=864e5,a=6048e5*(e||0),c=0;"s"==t&&(c=o-(r-1)*i+a),"e"==t&&(c=o+(7-r)*i+a);var u=new Date(c),p=u.getFullYear(),l=u.getMonth()+1,f=u.getDate();return p+"-"+(l=l<10?"0"+l:l)+"-"+(f=f<10?"0"+f:f)}function N(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=new Date(t).getTime()+864e5*n,r=new Date(o),i=r.getFullYear(),a=r.getMonth()+1<10?"0"+(r.getMonth()+1):r.getMonth()+1,c=r.getDate()<10?"0"+r.getDate():r.getDate(),u=r.getHours()<10?"0"+r.getHours():r.getHours(),p=r.getMinutes()<10?"0"+r.getMinutes():r.getMinutes(),l=r.getSeconds()<10?"0"+r.getSeconds():r.getSeconds(),f="";switch(e){case"YYYY/MM/DD HH:MM:SS":f="".concat(i,"/").concat(a,"/").concat(c," ").concat(u,":").concat(p,":").concat(l);break;case"YYYY-MM-DD HH:MM:SS":f="".concat(i,"-").concat(a,"-").concat(c," ").concat(u,":").concat(p,":").concat(l);break;case"YYYY/MM/DD":f="".concat(i,"/").concat(a,"/").concat(c);break;case"YYYY-MM-DD":f="".concat(i,"-").concat(a,"-").concat(c);break;case"MM/DD":f="".concat(a,"/").concat(c);break;case"MM-DD":f="".concat(a,"-").concat(c);break;case"MM":f="".concat(p);case"DD":f="".concat(c)}return f}function H(t){return H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},H(t)}function L(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function R(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?L(Object(n),!0).forEach((function(e){$(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function $(t,e,n){return(e=function(t){var e=function(t,e){if("object"!==H(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!==H(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===H(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var J=l,B=f,z=s,_=m,U=y,q=g,W=v,Z=b,X=D,G=h,K=w,Q=S,V=x,tt=M,et=O,nt=j,ot=k,rt=P,it=Y,at=T,ct=A,ut=E,pt=C,lt=N,ft=F,st=I,dt=R(R(R(R(R(R(R(R({},n),o),r),i),a),c),p),u);return e}()}));
|
|
1
|
+
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["super-toolkit"]=n():t["super-toolkit"]=n()}(this,(function(){return function(){"use strict";var t={d:function(n,e){for(var r in e)t.o(e,r)&&!t.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:e[r]})},o:function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};t.r(n),t.d(n,{base64ToBlob:function(){return et},base64ToFile:function(){return ot},blobToFile:function(){return rt},deepClone:function(){return Z},default:function(){return wt},fileToBase64:function(){return nt},getApplication:function(){return tt},getDate:function(){return vt},getElementContent:function(){return K},getLocalStorage:function(){return it},getMonday:function(){return bt},getRandomColor:function(){return ct},getRandomString:function(){return ut},getWeek:function(){return ht},group:function(){return G},isEmpty:function(){return X},maxSort:function(){return W},minSort:function(){return q},onDebounce:function(){return Q},onThrottle:function(){return V},setLocalStorage:function(){return at},unique:function(){return U},validateAmount:function(){return mt},validateEmail:function(){return yt},validateIDCard:function(){return dt},validateInt:function(){return pt},validateLeftInt:function(){return ft},validatePhone:function(){return st},validatePostCode:function(){return gt},validateRightInt:function(){return lt}});var e={};t.r(e),t.d(e,{maxSort:function(){return d},minSort:function(){return s},unique:function(){return f}});var r={};t.r(r),t.d(r,{deepClone:function(){return m},group:function(){return v},isEmpty:function(){return g}});var o={};t.r(o),t.d(o,{getElementContent:function(){return b}});var i={};t.r(i),t.d(i,{onDebounce:function(){return h},onThrottle:function(){return w}});var a={};t.r(a),t.d(a,{base64ToBlob:function(){return x},base64ToFile:function(){return M},blobToFile:function(){return D},fileToBase64:function(){return S},getApplication:function(){return j}});var c={};t.r(c),t.d(c,{getLocalStorage:function(){return O},setLocalStorage:function(){return k}});var u={};t.r(u),t.d(u,{getRandomColor:function(){return P},getRandomString:function(){return T}});var p={};t.r(p),t.d(p,{validateAmount:function(){return R},validateEmail:function(){return F},validateIDCard:function(){return I},validateInt:function(){return E},validateLeftInt:function(){return A},validatePhone:function(){return C},validatePostCode:function(){return H},validateRightInt:function(){return Y}});var l={};function f(t,n){if(n){for(var e=JSON.parse(JSON.stringify(t)),r=0;r<e.length;r++)for(var o=r+1;o<e.length;o++)e[r][n]==e[o][n]&&(e.splice(o,1),o--);return e}for(var i=JSON.parse(JSON.stringify(t)),a=0;a<i.length;a++)for(var c=a+1;c<i.length;c++)i[a]==i[c]&&(i.splice(c,1),c--);return i}function s(t,n){if(n){var e=t;return e.sort((function(t,e){var r=t[n],o=e[n],i=0;return r>o?i=1:r<o&&(i=-1),i})),e}return t.sort((function(t,n){return t-n}))}function d(t,n){if(n){var e=t;return e.sort((function(t,e){var r=t[n],o=e[n],i=0;return r>o?i=1:r<o&&(i=-1),-1*i})),e}return t.sort((function(t,n){return n-t}))}function y(t){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(t)}function m(t){if(Array.isArray(t)){for(var n=[],e=0;e<t.length;e++)n[e]=m(t[e]);return n}if("object"===y(t)&&null!==t){var r={};for(var o in t)r[o]=m(t[o]);return r}return t}function g(t){return""===t||null==t||"object"===y(t)&&(Array.isArray(t)?0===t.length:0===Object.keys(t).length)}function v(t,n){var e=[];return t.forEach((function(t){var r=e.map((function(t){return t.group})),o=n.map((function(n){return t[n]}));if(o.includes(void 0))throw Error("传入的keys有误");r.includes(o.join(","))?e.forEach((function(n){n.group==t.age&&n.data.push(t)})):e.push({group:o.join(","),data:[t]})})),e}function b(t,n){var e=new RegExp("<"+n+"[\\s\\S]*<\\/"+n+">");console.log(e);var r=e.exec(t);return null!=r&&r.length?r[0]:null}function h(t,n){var e=null;return function(){var r=this;clearTimeout(e),e=setTimeout((function(){t.apply(r,arguments)}),n)}}function w(t,n){var e,r=new Date;return function(){var o=this,i=new Date;clearTimeout(e),i-r>=n?(t.apply(o,arguments),r=i):e=setTimeout((function(){t.apply(o,arguments)}),n)}}function S(t){return new Promise((function(n,e){var r=new FileReader;r.readAsDataURL(t),r.onload=function(t){var e;n(null===(e=t.target)||void 0===e?void 0:e.result)}}))}function x(t){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",e=t.split(","),r=e[0].match(/:(.*?);/)[1],o=atob(e[1]),i=o.length,a=new Uint8Array(i);i--;)a[i]=o.charCodeAt(i);return new Blob([a],{type:n||r})}function D(t,n,e){return new File([t],n,{type:e})}function M(t,n){for(var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=t.split(","),o=r[0].match(/:(.*?);/)[1],i=atob(r[1]),a=i.length,c=new Uint8Array(a);a--;)c[a]=i.charCodeAt(a);return new File([c],n,{type:e||o})}function j(t){var n=t.split(".").pop(),e=[{type:"doc",application:"application/msword"},{type:"docx",application:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},{type:"dot",application:"application/msword"},{type:"dotx",application:"application/vnd.openxmlformats-officedocument.wordprocessingml.template"},{type:"xls",application:"application/vnd.ms-excel"},{type:"xlsx",application:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},{type:"ppt",application:"application/vnd.ms-powerpoint"},{type:"pptx",application:"application/vnd.openxmlformats-officedocument.presentationml.presentation"},{type:"pdf",application:"application/pdf"},{type:"txt",application:"text/plain"},{type:"gif",application:"image/gif"},{type:"jpeg",application:"image/jpeg"},{type:"jpg",application:"image/jpeg"},{type:"png",application:"image/png"},{type:"css",application:"text/css"},{type:"html",application:"text/html"},{type:"htm",application:"text/html"},{type:"xsl",application:"text/xml"},{type:"xml",application:"text/xml"},{type:"mpeg",application:"video/mpeg"},{type:"mpg",application:"video/mpeg"},{type:"avi",application:"video/x-msvideo"},{type:"movie",application:"video/x-sgi-movie"},{type:"bin",application:"application/octet-stream"},{type:"exe",application:"application/octet-stream"},{type:"so",application:"application/octet-stream"},{type:"dll",application:"application/octet-stream"},{type:"ai",application:"application/postscript"},{type:"dir",application:"application/x-director"},{type:"js",application:"application/x-javascript"},{type:"swf",application:"application/x-shockwave-flash"},{type:"xhtml",application:"application/xhtml+xml"},{type:"xht",application:"application/xhtml+xml"},{type:"zip",application:"application/zip"},{type:"mid",application:"audio/midi"},{type:"midi",application:"audio/midi"},{type:"mp3",application:"audio/mpeg"},{type:"rm",application:"audio/x-pn-realaudio"},{type:"rpm",application:"audio/x-pn-realaudio-plugin"},{type:"wav",application:"audio/x-wav"},{type:"bmp",application:"image/bmp"}].find((function(t){return t.type==n}));return(null==e?void 0:e.type)||null}t.r(l),t.d(l,{getDate:function(){return $},getMonday:function(){return N},getWeek:function(){return L}});var O=function(t){if(!window)throw new Error("非web环境禁止使用localStorage");if(!t)throw new Error("key的值不能为空");var n=localStorage.getItem(t);return n?JSON.parse(n):null},k=function(t,n){if(!window)throw new Error("非web环境禁止使用localStorage");if(!t||!n)throw new Error("key or value的值不能为空");var e=JSON.stringify(n);localStorage.setItem(t,e)};function P(){for(var t="#",n=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],e=0;e<6;e++){t+=n[Math.floor(16*Math.random())]}return t}var T=function(t){for(var n="",e=0;e<t;e++)n+=String(Math.floor(10*Math.random()));return n};function E(t){return/^-?[1-9]\d*|0$/.test(t)}function Y(t){return/^[1-9]\d*$/.test(t)}function A(t){return/^-[1-9]\d*$/.test(t)}function C(t){return/^(86)?1[3-9]\d{9}$/.test(t)}function I(t){return/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}(\d|X|x)$/.test(t)}function F(t){return/^[\w.-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(t)}function R(t){return/^[0-9]+(.[0-9]{1,2})?$/.test(t)}function H(t){return/[1-9]\d{5}(?!\d)/.test(t)}function L(t){var n="";switch(new Date(t).getDay()){case 0:n="周日";break;case 1:n="周一";break;case 2:n="周二";break;case 3:n="周三";break;case 4:n="周四";break;case 5:n="周五";break;case 6:n="周六"}return n}function N(t,n){if(!t)throw new Error("getMonday的type参数必传");var e=new Date,r=e.getTime(),o=e.getDay(),i=864e5,a=6048e5*(n||0),c=0;"s"==t&&(c=r-(o-1)*i+a),"e"==t&&(c=r+(7-o)*i+a);var u=new Date(c),p=u.getFullYear(),l=u.getMonth()+1,f=u.getDate();return p+"-"+(l=l<10?"0"+l:l)+"-"+(f=f<10?"0"+f:f)}function $(t,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=new Date(t).getTime()+864e5*e,o=new Date(r),i=o.getFullYear(),a=o.getMonth()+1<10?"0"+(o.getMonth()+1):o.getMonth()+1,c=o.getDate()<10?"0"+o.getDate():o.getDate(),u=o.getHours()<10?"0"+o.getHours():o.getHours(),p=o.getMinutes()<10?"0"+o.getMinutes():o.getMinutes(),l=o.getSeconds()<10?"0"+o.getSeconds():o.getSeconds(),f="";switch(n){case"YYYY/MM/DD HH:MM:SS":f="".concat(i,"/").concat(a,"/").concat(c," ").concat(u,":").concat(p,":").concat(l);break;case"YYYY-MM-DD HH:MM:SS":f="".concat(i,"-").concat(a,"-").concat(c," ").concat(u,":").concat(p,":").concat(l);break;case"YYYY/MM/DD":f="".concat(i,"/").concat(a,"/").concat(c);break;case"YYYY-MM-DD":f="".concat(i,"-").concat(a,"-").concat(c);break;case"MM/DD":f="".concat(a,"/").concat(c);break;case"MM-DD":f="".concat(a,"-").concat(c);break;case"MM":f="".concat(p);case"DD":f="".concat(c)}return f}function J(t){return J="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},J(t)}function B(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function z(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?B(Object(e),!0).forEach((function(n){_(t,n,e[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):B(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}))}return t}function _(t,n,e){return(n=function(t){var n=function(t,n){if("object"!==J(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,n||"default");if("object"!==J(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"===J(n)?n:String(n)}(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}var U=f,q=s,W=d,Z=m,X=g,G=v,K=b,Q=h,V=w,tt=j,nt=S,et=x,rt=D,ot=M,it=O,at=k,ct=P,ut=T,pt=E,lt=Y,ft=A,st=C,dt=I,yt=F,mt=R,gt=H,vt=$,bt=N,ht=L,wt=z(z(z(z(z(z(z(z(z({},e),r),o),i),a),c),u),p),l);return n}()}));
|
package/package.json
CHANGED
package/src/data.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export const getRandomSixNum = (size: number) => {
|
|
2
|
-
let RandomSixStr = ''
|
|
3
|
-
for (let i = 0; i < size; i++) {
|
|
4
|
-
RandomSixStr += String(Math.floor(Math.random() * 10))
|
|
5
|
-
}
|
|
6
|
-
return RandomSixStr
|
|
7
|
-
}
|
|
8
1
|
/** 深拷贝 */
|
|
9
2
|
export function deepClone<T>(val: T):T {
|
|
10
3
|
if (Array.isArray(val)) {
|
|
@@ -22,4 +15,43 @@ export function deepClone<T>(val: T):T {
|
|
|
22
15
|
return obj as T
|
|
23
16
|
}
|
|
24
17
|
return val
|
|
18
|
+
}
|
|
19
|
+
/** 判断是否为空字符串、null、undefined、空对象、空数组 */
|
|
20
|
+
export function isEmpty(value: string | number | null | undefined | Array<any> | Record<string, any>) {
|
|
21
|
+
if (value === '' || value === null || value === undefined) {
|
|
22
|
+
return true;
|
|
23
|
+
} else if (typeof value === 'object') {
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
return value.length === 0;
|
|
26
|
+
} else {
|
|
27
|
+
return Object.keys(value).length === 0;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
/** 数据分组筛选 */
|
|
33
|
+
export function group <T extends Array<Record<string,any>> = any[]>(array:T, keys:string[]) {
|
|
34
|
+
const data:{
|
|
35
|
+
group:string
|
|
36
|
+
data:T
|
|
37
|
+
}[] = []
|
|
38
|
+
array.forEach(item => {
|
|
39
|
+
const groups = data.map(t => t.group)
|
|
40
|
+
const values = keys.map(t => item[t])
|
|
41
|
+
if(values.includes(undefined)) throw Error('传入的keys有误')
|
|
42
|
+
if (groups.includes(values.join(','))) {
|
|
43
|
+
data.forEach(ct => {
|
|
44
|
+
if (ct.group == item.age) {
|
|
45
|
+
ct.data.push(item)
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
data.push({
|
|
51
|
+
group: values.join(','),
|
|
52
|
+
data: [item] as T
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
return data
|
|
25
57
|
}
|
package/src/event.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**防抖方法,其中形参fn为要执行的方法,wait则代表时间间隔,v2使用方法:methods:debounce(()=>{},500),v3使用方法:const methods=debounce(()=>{},500)*/
|
|
2
|
-
export function
|
|
2
|
+
export function onDebounce(fn: Function, wait: number) {
|
|
3
3
|
var timer: any = null;
|
|
4
4
|
return function (this: Window) {
|
|
5
5
|
var _that = this;
|
|
@@ -12,7 +12,7 @@ export function debounce(fn: Function, wait: number) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**节流方法,其中形参fn为要执行的方法,wait则代表时间间隔,v2使用方法:methods:throttle(()=>{},500),v3使用方法:const methods=throttle(()=>{},500)*/
|
|
15
|
-
export function
|
|
15
|
+
export function onThrottle(fn: Function, wait: number) {
|
|
16
16
|
var timeout: any, startTime = new Date() as any;
|
|
17
17
|
return function (this: Window) {
|
|
18
18
|
var _that = this;
|
package/src/random.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** 随机生成16进制颜色 */
|
|
2
|
+
export function getRandomColor(){
|
|
3
|
+
let color = "#";
|
|
4
|
+
const arr = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
|
|
5
|
+
for (let i = 0; i < 6; i++){
|
|
6
|
+
let num = Math.floor(Math.random() * 16)
|
|
7
|
+
color += arr[num]
|
|
8
|
+
}
|
|
9
|
+
return color;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** 随机生成指定长度的字符串 */
|
|
13
|
+
export const getRandomString = (size: number) => {
|
|
14
|
+
let RandomStr = ''
|
|
15
|
+
for (let i = 0; i < size; i++) {
|
|
16
|
+
RandomStr += String(Math.floor(Math.random() * 10))
|
|
17
|
+
}
|
|
18
|
+
return RandomStr
|
|
19
|
+
}
|
package/test.html
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
|
-
<title>Document</title>
|
|
9
|
-
</head>
|
|
10
|
-
|
|
11
|
-
<body>
|
|
12
|
-
<script src="./lib/super-toolkit.min.js"></script>
|
|
13
|
-
<script>
|
|
14
|
-
const reg=/^[0-9]+(.[0-9]{1,2})?$/
|
|
15
|
-
const str='1asdf'
|
|
16
|
-
console.log(window['super-toolkit'].validatePostCode);
|
|
17
|
-
</script>
|
|
18
|
-
</body>
|
|
19
|
-
|
|
20
|
-
</html>
|