@daysnap/utils 0.0.35 → 0.0.37

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.
@@ -0,0 +1,4 @@
1
+ /**
2
+ *去除字符串空格
3
+ */
4
+ export declare function stringTrim(str: string, type?: 1 | 2 | 3 | 4): string;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.stringTrim = stringTrim;
7
+ /**
8
+ *去除字符串空格
9
+ */
10
+ function stringTrim(str, type) {
11
+ var _type;
12
+ // 1-所有空格,2-前后空格,3-前空格,4-后空格
13
+ // eslint-disable-next-line no-param-reassign
14
+ type = (_type = type) !== null && _type !== void 0 ? _type : 1;
15
+ switch (type) {
16
+ case 1:
17
+ return str.replace(/\s+/g, '');
18
+ case 2:
19
+ return str.replace(/(^\s*)|(\s*$)/g, '');
20
+ case 3:
21
+ return str.replace(/(^\s*)/g, '');
22
+ case 4:
23
+ return str.replace(/(\s*$)/g, '');
24
+ default:
25
+ return str;
26
+ }
27
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 判断类型
3
+ * @param val 待判断数据
4
+ * @returns 'undefined'|'null'|'boolean'|'string'|'number'|'object'|'array'|'function'|'symbol'|'map'|'weakmap'|'bigint'|'regexp'|'date'
5
+ */
6
+ export declare function typeOf<T>(val: T): val is T;
package/lib/typeOf.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.typeOf = typeOf;
7
+ /**
8
+ * 判断类型
9
+ * @param val 待判断数据
10
+ * @returns 'undefined'|'null'|'boolean'|'string'|'number'|'object'|'array'|'function'|'symbol'|'map'|'weakmap'|'bigint'|'regexp'|'date'
11
+ */
12
+ function typeOf(val) {
13
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase();
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daysnap/utils",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "通用的工具库",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",