ph-utils 0.2.1 → 0.2.2
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/lib/dom.d.ts +7 -1
- package/lib/dom.js +8 -0
- package/lib/index.d.ts +1 -1
- package/lib/index_m.d.ts +1 -1
- package/lib/index_m.js +1 -1
- package/package.json +1 -1
package/lib/dom.d.ts
CHANGED
@@ -58,7 +58,7 @@ export declare function text(element: HTMLElement, textstr?: string): string;
|
|
58
58
|
* @param elems
|
59
59
|
* @param fn 遍历到节点时的回调,回调第一个参数为遍历到的节点,第2个参数为 index;如果回调函数返回 true,则会终止遍历(break)
|
60
60
|
*/
|
61
|
-
export declare function iterate(elems: NodeList, fn: (el: HTMLElement, index: number) => any): void;
|
61
|
+
export declare function iterate(elems: NodeList | HTMLElement[], fn: (el: HTMLElement, index: number) => any): void;
|
62
62
|
/**
|
63
63
|
* 设置或获取节点 data-* 属性
|
64
64
|
* @param elem
|
@@ -67,3 +67,9 @@ export declare function iterate(elems: NodeList, fn: (el: HTMLElement, index: nu
|
|
67
67
|
* @returns
|
68
68
|
*/
|
69
69
|
export declare function attr(elem: HTMLElement, key: string, value?: string): string;
|
70
|
+
/**
|
71
|
+
* 获取指定节点的父节点
|
72
|
+
* @param el
|
73
|
+
* @returns
|
74
|
+
*/
|
75
|
+
export declare function parent(el: HTMLElement): HTMLElement;
|
package/lib/dom.js
CHANGED
package/lib/index.d.ts
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
* @param str 待验证的字符串
|
7
7
|
* @param ignoreWhitespace 是否忽略空格(包括空白字符串以及[\r\t\n]之类的制表符),默认为true
|
8
8
|
*/
|
9
|
-
export declare function isBlank(str?: string, ignoreWhitespace?: boolean): boolean;
|
9
|
+
export declare function isBlank(str?: string | null, ignoreWhitespace?: boolean): boolean;
|
10
10
|
/**
|
11
11
|
* 屏蔽手机号,中间部分用 * 展示
|
12
12
|
* @param mobile 待屏蔽的手机号
|
package/lib/index_m.d.ts
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
* @param str 待验证的字符串
|
7
7
|
* @param ignoreWhitespace 是否忽略空格(包括空白字符串以及[\r\t\n]之类的制表符),默认为true
|
8
8
|
*/
|
9
|
-
export declare function isBlank(str?: string, ignoreWhitespace?: boolean): boolean;
|
9
|
+
export declare function isBlank(str?: string | null, ignoreWhitespace?: boolean): boolean;
|
10
10
|
/**
|
11
11
|
* 屏蔽手机号,中间部分用 * 展示
|
12
12
|
* @param mobile 待屏蔽的手机号
|
package/lib/index_m.js
CHANGED
@@ -36,7 +36,7 @@ export function shieldMobile(mobile) {
|
|
36
36
|
* @returns true 是数字, false 不是数字
|
37
37
|
*/
|
38
38
|
export function isNumeric(str, numericParam) {
|
39
|
-
numericParam =
|
39
|
+
numericParam = { isPositive: false, isFloat: true, ...(numericParam || {}) };
|
40
40
|
let symbol = numericParam.isPositive ? '[+]?' : '[+-]?';
|
41
41
|
let main = numericParam.isFloat ? '([0-9]*[.])?[0-9]+' : '[0-9]+';
|
42
42
|
return new RegExp('^' + symbol + main + '$').test(str);
|