ph-utils 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -147,3 +147,11 @@ export function attr(elem, key, value) {
147
147
  return elem.getAttribute('data-' + key);
148
148
  }
149
149
  }
150
+ /**
151
+ * 获取指定节点的父节点
152
+ * @param el
153
+ * @returns
154
+ */
155
+ export function parent(el) {
156
+ return el.parentNode;
157
+ }
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 = Object.assign({ isPositive: false, isFloat: true }, (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);
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "module": "lib/index_m.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "browser": "lib/index_m.js",
8
- "version": "0.2.1",
8
+ "version": "0.2.2",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git+https//gitee.com/towardly/ph.git",