hsu-utils 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
package/dist/hsu-utils.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
*
|
3
|
-
* hsu-utils v0.0.
|
3
|
+
* hsu-utils v0.0.1
|
4
4
|
*
|
5
5
|
* some front-end uilts
|
6
6
|
*
|
@@ -63,9 +63,9 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar
|
|
63
63
|
/*!*********************************!*\
|
64
64
|
!*** ./tools/DeepCopy/index.ts ***!
|
65
65
|
\*********************************/
|
66
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
66
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
67
67
|
|
68
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar
|
68
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar Typeof_1 = __importDefault(__webpack_require__(/*! ../Typeof */ \"./tools/Typeof/index.ts\"));\nfunction deepCopy(data) {\n if ((0, Typeof_1.default)(data) === 'date') {\n return new Date(data.toISOString());\n }\n else if ((0, Typeof_1.default)(data) === 'formdata') {\n var _data = data;\n var _formData_1 = new FormData();\n _data.forEach(function (value, key) {\n _formData_1.append(key, value);\n });\n return _formData_1;\n }\n else if (Array.isArray(data)) {\n var newData = data.map(function (item) {\n if (typeof item === 'object') {\n return deepCopy(item);\n }\n else {\n return item;\n }\n });\n return newData;\n }\n else if (data && (0, Typeof_1.default)(data) === 'object') {\n var _data_1 = data;\n var newData_1 = {};\n Object.keys(_data_1).forEach(function (key) {\n var _item = _data_1[key];\n if (typeof _item === 'object') {\n newData_1[key] = deepCopy(_item);\n }\n else {\n newData_1[key] = _item;\n }\n });\n return newData_1;\n }\n return data;\n}\nexports[\"default\"] = deepCopy;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/DeepCopy/index.ts?");
|
69
69
|
|
70
70
|
/***/ }),
|
71
71
|
|
@@ -73,9 +73,9 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar
|
|
73
73
|
/*!******************************!*\
|
74
74
|
!*** ./tools/Equal/index.ts ***!
|
75
75
|
\******************************/
|
76
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
76
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
77
77
|
|
78
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ObjEqual = exports.ValEqual = exports.TypeEqual = void 0;\nvar
|
78
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ObjEqual = exports.ValEqual = exports.TypeEqual = void 0;\nvar Typeof_1 = __importDefault(__webpack_require__(/*! ../Typeof */ \"./tools/Typeof/index.ts\"));\nfunction TypeEqual(obj1, obj2) {\n var isEqual = false;\n if ((0, Typeof_1.default)(obj1) !== (0, Typeof_1.default)(obj2)) {\n isEqual = false;\n }\n else {\n isEqual = true;\n }\n return isEqual;\n}\nexports.TypeEqual = TypeEqual;\nfunction ValEqual(obj1, obj2) {\n var isEqual = false;\n if ((obj1 === null && obj2 === undefined) || (obj1 === undefined && obj2 === null)) {\n isEqual = true;\n }\n else {\n if (typeof obj1 === 'object' && typeof obj2 === 'object') {\n isEqual = ObjEqual(obj1, obj2);\n }\n else if (typeof obj1 === 'function' && typeof obj2 === 'function') {\n isEqual = JSON.stringify(obj1) === JSON.stringify(obj2);\n }\n else {\n isEqual = obj1 === obj2;\n }\n }\n return isEqual;\n}\nexports.ValEqual = ValEqual;\nfunction ObjEqual(obj1, obj2) {\n var isEqual = false;\n if (obj1 !== null && obj2 !== null) {\n if (Array.isArray(obj1) && Array.isArray(obj2)) {\n obj1.sort();\n obj2.sort();\n if (obj1.length !== obj2.length) {\n isEqual = false;\n }\n else {\n for (var i = 0; i < obj1.length; i++) {\n isEqual = ValEqual(obj1[i], obj2[i]);\n if (!isEqual)\n break;\n }\n }\n }\n else if (typeof obj1 === 'object' && typeof obj2 === 'object') {\n if (Object.keys(obj1).length !== Object.keys(obj2).length) {\n isEqual = false;\n }\n else {\n for (var key in obj1) {\n isEqual = ValEqual(obj1[key], obj2[key]);\n if (!isEqual)\n break;\n }\n }\n }\n }\n else if (obj1 === null && obj2 === null) {\n isEqual = true;\n }\n return isEqual;\n}\nexports.ObjEqual = ObjEqual;\nvar Equal = { ObjEqual: ObjEqual, ValEqual: ValEqual, TypeEqual: TypeEqual };\nexports[\"default\"] = Equal;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/Equal/index.ts?");
|
79
79
|
|
80
80
|
/***/ }),
|
81
81
|
|
package/dist/hsu-utils.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
/*! For license information please see hsu-utils.min.js.LICENSE.txt */
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["hsu-utils"]=t():e["hsu-utils"]=t()}(this,(()=>(()=>{"use strict";var e={442:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var r="+",
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["hsu-utils"]=t():e["hsu-utils"]=t()}(this,(()=>(()=>{"use strict";var e={442:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var r="+",n="-",o="|",u=" ",a="";function f(e){for(var t=0,r=0,n=e;r<n.length;r++){var o=n[r];t+=o.charCodeAt(0)<128&&o.charCodeAt(0)>=0?1:2}return t}function l(e,t){void 0===t&&(t=!1);var o=e.length,u="";return e.forEach((function(e,f){u+=r+function(e){for(var t="",r=0;r<=e;r++)t+=n;return t}(e+1),u+=f===o-1?r+(t?a:"\n"):a})),u}function i(e){for(var t="",r=0;r<=e;r++)t+=u;return t}t.default=function(e,t){var r=e.length,n=function(e){for(var t=Object.keys(e[0]).map((function(e){return+e})),r=0,n=e;r<n.length;r++)n[r].forEach((function(e,r){var n=f(e.toString());t[r]=Math.max(n,t[r])}));return t}(e),c="";e.forEach((function(e,t){t<=1&&(c+=l(n)),c+=function(e,t){var r=e.length,n="";return e.forEach((function(e,l){var c=t[l],s="";isNaN(+c)?s+=u+(null!=c?c:"")+i(e-f((null!=c?c:"").toString())):s+=i(e-f(c.toString()))+c+u,n+=o+s,n+=l===r-1?o+"\n":a})),n}(n,e),t===r-1&&(c+=l(n,!0))})),console.log(c),t&&t(c)}},819:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(332));t.default=function e(t){if("date"===(0,o.default)(t))return new Date(t.toISOString());if("formdata"===(0,o.default)(t)){var r=t,n=new FormData;return r.forEach((function(e,t){n.append(t,e)})),n}if(Array.isArray(t))return t.map((function(t){return"object"==typeof t?e(t):t}));if(t&&"object"===(0,o.default)(t)){var u=t,a={};return Object.keys(u).forEach((function(t){var r=u[t];a[t]="object"==typeof r?e(r):r})),a}return t}},962:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ObjEqual=t.ValEqual=t.TypeEqual=void 0;var o=n(r(332));function u(e,t){return(0,o.default)(e)===(0,o.default)(t)}function a(e,t){return null===e&&void 0===t||void 0===e&&null===t||("object"==typeof e&&"object"==typeof t?f(e,t):"function"==typeof e&&"function"==typeof t?JSON.stringify(e)===JSON.stringify(t):e===t)}function f(e,t){var r=!1;if(null!==e&&null!==t){if(Array.isArray(e)&&Array.isArray(t))if(e.sort(),t.sort(),e.length!==t.length)r=!1;else for(var n=0;n<e.length&&(r=a(e[n],t[n]));n++);else if("object"==typeof e&&"object"==typeof t)if(Object.keys(e).length!==Object.keys(t).length)r=!1;else for(var o in e)if(!(r=a(e[o],t[o])))break}else null===e&&null===t&&(r=!0);return r}t.TypeEqual=u,t.ValEqual=a,t.ObjEqual=f;var l={ObjEqual:f,ValEqual:a,TypeEqual:u};t.default=l},332:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=Object.prototype.toString.call(e),r=new RegExp(" (.+?)]");return t.match(r)[1].toLowerCase()}},243:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Typeof=t.Equal=t.deepCopy=t.console_table=void 0;var o=n(r(442));t.console_table=o.default;var u=n(r(819));t.deepCopy=u.default;var a=n(r(962));t.Equal=a.default;var f=n(r(332));t.Typeof=f.default}},t={};var r=function r(n){var o=t[n];if(void 0!==o)return o.exports;var u=t[n]={exports:{}};return e[n].call(u.exports,u,u.exports,r),u.exports}(243);return r})()));
|
package/es/DeepCopy/index.js
CHANGED
package/es/Equal/index.js
CHANGED
package/lib/DeepCopy/index.js
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
var
|
6
|
+
var Typeof_1 = __importDefault(require("../Typeof"));
|
4
7
|
function deepCopy(data) {
|
5
|
-
if ((0,
|
8
|
+
if ((0, Typeof_1.default)(data) === 'date') {
|
6
9
|
return new Date(data.toISOString());
|
7
10
|
}
|
8
|
-
else if ((0,
|
11
|
+
else if ((0, Typeof_1.default)(data) === 'formdata') {
|
9
12
|
var _data = data;
|
10
13
|
var _formData_1 = new FormData();
|
11
14
|
_data.forEach(function (value, key) {
|
@@ -24,7 +27,7 @@ function deepCopy(data) {
|
|
24
27
|
});
|
25
28
|
return newData;
|
26
29
|
}
|
27
|
-
else if (data && (0,
|
30
|
+
else if (data && (0, Typeof_1.default)(data) === 'object') {
|
28
31
|
var _data_1 = data;
|
29
32
|
var newData_1 = {};
|
30
33
|
Object.keys(_data_1).forEach(function (key) {
|
package/lib/Equal/index.js
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
exports.ObjEqual = exports.ValEqual = exports.TypeEqual = void 0;
|
4
|
-
var
|
7
|
+
var Typeof_1 = __importDefault(require("../Typeof"));
|
5
8
|
function TypeEqual(obj1, obj2) {
|
6
9
|
var isEqual = false;
|
7
|
-
if ((0,
|
10
|
+
if ((0, Typeof_1.default)(obj1) !== (0, Typeof_1.default)(obj2)) {
|
8
11
|
isEqual = false;
|
9
12
|
}
|
10
13
|
else {
|