ph-utils 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/date.js +4 -4
- package/lib/dom.d.ts +7 -0
- package/lib/dom.js +9 -0
- package/lib/index.d.ts +1 -1
- package/lib/index_m.d.ts +1 -1
- package/lib/server.js +1 -1
- package/package.json +3 -3
- package/LICENSE +0 -21
package/lib/date.js
CHANGED
@@ -100,10 +100,10 @@ function startOf(date, unit, isEnd = false) {
|
|
100
100
|
exports.startOf = startOf;
|
101
101
|
/**
|
102
102
|
* 日期加上指定时间后的日期
|
103
|
-
* @param date
|
104
|
-
* @param num
|
105
|
-
* @param unit
|
106
|
-
* @param fmt
|
103
|
+
* @param date 指定的日期
|
104
|
+
* @param num 需要添加的数字, 如果这个参数传递一个小于0的数字,则就是日期减去相应的数字
|
105
|
+
* @param unit 需要添加的单位,date - 加减天数
|
106
|
+
* @param fmt 可选参数,如果传递了格式化的单位,则返回格式化后的日期, 格式化字符串 yyyy - 年, mm - 月, dd - 日, HH - 小时, MM - 分钟, ss - 秒
|
107
107
|
* @returns {Date | string} 如果传递了 fmt 参数,则返回 string,否则返回 Date
|
108
108
|
*/
|
109
109
|
function add(date, num, unit, fmt) {
|
package/lib/dom.d.ts
CHANGED
@@ -15,6 +15,13 @@ export declare function addClass(elem: HTMLElement, clazz: string): void;
|
|
15
15
|
* @param {string} clazz 需要移除的 class
|
16
16
|
*/
|
17
17
|
export declare function removeClass(elem: HTMLElement, clazz: string): void;
|
18
|
+
/**
|
19
|
+
* 判断节点是否包含某个 class
|
20
|
+
* @param elem 待判断 class 的节点
|
21
|
+
* @param clazz 待判断的 class
|
22
|
+
* @returns
|
23
|
+
*/
|
24
|
+
export declare function hasClass(elem: HTMLElement, clazz: string): boolean;
|
18
25
|
/**
|
19
26
|
* 为节点添加 transition 属性,包括浏览器前缀
|
20
27
|
* @param {HTMLElement} element 需要添加 css Transition 属性的节点
|
package/lib/dom.js
CHANGED
@@ -32,6 +32,15 @@ export function addClass(elem, clazz) {
|
|
32
32
|
export function removeClass(elem, clazz) {
|
33
33
|
elem.classList.remove(clazz);
|
34
34
|
}
|
35
|
+
/**
|
36
|
+
* 判断节点是否包含某个 class
|
37
|
+
* @param elem 待判断 class 的节点
|
38
|
+
* @param clazz 待判断的 class
|
39
|
+
* @returns
|
40
|
+
*/
|
41
|
+
export function hasClass(elem, clazz) {
|
42
|
+
return elem.classList.contains(clazz);
|
43
|
+
}
|
35
44
|
/**
|
36
45
|
* 为节点添加 transition 属性,包括浏览器前缀
|
37
46
|
* @param {HTMLElement} element 需要添加 css Transition 属性的节点
|
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
|
9
|
+
export declare function isBlank(str?: string, 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
|
9
|
+
export declare function isBlank(str?: string, ignoreWhitespace?: boolean): boolean;
|
10
10
|
/**
|
11
11
|
* 屏蔽手机号,中间部分用 * 展示
|
12
12
|
* @param mobile 待屏蔽的手机号
|
package/lib/server.js
CHANGED
@@ -59,7 +59,7 @@ module.exports = {
|
|
59
59
|
options = { ...(options || {}) };
|
60
60
|
const errorName = options.errorName || 'ExecError';
|
61
61
|
delete options.errorName;
|
62
|
-
child_process_1.exec(cmd, options, (error, stdout, stderr) => {
|
62
|
+
(0, child_process_1.exec)(cmd, options, (error, stdout, stderr) => {
|
63
63
|
let err = null;
|
64
64
|
let rs = null;
|
65
65
|
if (error) {
|
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.
|
8
|
+
"version": "0.2.3",
|
9
9
|
"repository": {
|
10
10
|
"type": "git",
|
11
11
|
"url": "git+https//gitee.com/towardly/ph.git",
|
@@ -18,8 +18,8 @@
|
|
18
18
|
},
|
19
19
|
"homepage": "https://gitee.com/towardly/ph/tree/master/packages/utils",
|
20
20
|
"devDependencies": {
|
21
|
-
"@types/node": "^
|
22
|
-
"typescript": "^4.
|
21
|
+
"@types/node": "^17.0.21",
|
22
|
+
"typescript": "^4.5.5"
|
23
23
|
},
|
24
24
|
"scripts": {
|
25
25
|
"build": "node scripts/build.js"
|
package/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2021 Tenny
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|