tools-for-js 1.5.2 → 1.5.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/lib/index.js +8 -2
- package/lib/utils/array.js +1 -1
- package/lib/utils/object.js +18 -4
- package/lib/utils/string.js +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -213,10 +213,16 @@ Object.defineProperty(exports, "isExpires", {
|
|
|
213
213
|
return _time.isExpires;
|
|
214
214
|
}
|
|
215
215
|
});
|
|
216
|
-
Object.defineProperty(exports, "
|
|
216
|
+
Object.defineProperty(exports, "isJsonString", {
|
|
217
217
|
enumerable: true,
|
|
218
218
|
get: function get() {
|
|
219
|
-
return _object.
|
|
219
|
+
return _object.isJsonString;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
Object.defineProperty(exports, "jsonParse", {
|
|
223
|
+
enumerable: true,
|
|
224
|
+
get: function get() {
|
|
225
|
+
return _object.jsonParse;
|
|
220
226
|
}
|
|
221
227
|
});
|
|
222
228
|
Object.defineProperty(exports, "lowercaseKeys", {
|
package/lib/utils/array.js
CHANGED
|
@@ -43,7 +43,7 @@ var deWeightArray = exports.deWeightArray = function deWeightArray(list, key, ca
|
|
|
43
43
|
tempList.push(item);
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
-
IsType('Function', callback) && callback(tempList);
|
|
46
|
+
(0, _common.IsType)('Function', callback) && callback(tempList);
|
|
47
47
|
return _toConsumableArray(map.values()); //将map对象转换回数组再返回
|
|
48
48
|
};
|
|
49
49
|
|
package/lib/utils/object.js
CHANGED
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getValByKey = void 0;
|
|
7
|
-
exports.
|
|
7
|
+
exports.isJsonString = isJsonString;
|
|
8
|
+
exports.jsonParse = jsonParse;
|
|
8
9
|
exports.objectToQs = void 0;
|
|
9
10
|
/*******
|
|
10
11
|
* @description: 将对象转换为查询字符串
|
|
@@ -42,11 +43,24 @@ var getValByKey = exports.getValByKey = function getValByKey(obj, key) {
|
|
|
42
43
|
* @param {String} str
|
|
43
44
|
* @return {Object|Boolean}
|
|
44
45
|
*/
|
|
45
|
-
function
|
|
46
|
+
function isJsonString(str) {
|
|
46
47
|
try {
|
|
47
|
-
|
|
48
|
-
return res;
|
|
48
|
+
return Boolean(JSON.parse(str));
|
|
49
49
|
} catch (e) {
|
|
50
50
|
return false;
|
|
51
51
|
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/*******
|
|
55
|
+
* @description: 将字符串解析为对象
|
|
56
|
+
* @author: 琴时
|
|
57
|
+
* @param {String} str
|
|
58
|
+
* @return {Object}
|
|
59
|
+
*/
|
|
60
|
+
function jsonParse(str) {
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(str);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
52
66
|
}
|
package/lib/utils/string.js
CHANGED