hsu-utils 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/hsu-utils.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  *
3
- * hsu-utils v0.0.0
3
+ * hsu-utils v0.0.2
4
4
  *
5
- * some front-end uilts
5
+ * some front-end utils
6
6
  *
7
7
  * MIT License
8
8
  *
@@ -55,7 +55,7 @@ return /******/ (() => { // webpackBootstrap
55
55
  \*************************************/
56
56
  /***/ ((__unused_webpack_module, exports) => {
57
57
 
58
- eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar NODE = '+';\nvar EDGE = '-';\nvar HIGH = '|';\nvar SPACE = ' ';\nvar EMPTY = '';\nfunction get_string_width(str) {\n var width = 0;\n for (var _i = 0, str_1 = str; _i < str_1.length; _i++) {\n var char = str_1[_i];\n width += char.charCodeAt(0) < 128 && char.charCodeAt(0) >= 0 ? 1 : 2;\n }\n return width;\n}\nfunction get_egde(width) {\n var edge = '';\n for (var i = 0; i <= width; i++) {\n edge += EDGE;\n }\n return edge;\n}\nfunction get_edge(widths, no_line_break) {\n if (no_line_break === void 0) { no_line_break = false; }\n var col_num = widths.length;\n var border = '';\n widths.forEach(function (width, col) {\n border += NODE + get_egde(width + 1);\n if (col === col_num - 1) {\n border += NODE + (no_line_break ? EMPTY : '\\n');\n }\n else {\n border += EMPTY;\n }\n });\n return border;\n}\nfunction get_space(width) {\n var space = '';\n for (var i = 0; i <= width; i++) {\n space += SPACE;\n }\n return space;\n}\nfunction wirte_data(widths, data) {\n var col_num = widths.length;\n var content = '';\n widths.forEach(function (width, col) {\n var col_data = data[col];\n var _content = '';\n if (!isNaN(+col_data)) {\n _content += get_space(width - get_string_width(col_data.toString())) + col_data + SPACE;\n }\n else {\n _content += SPACE + (col_data !== null && col_data !== void 0 ? col_data : '') + get_space(width - get_string_width((col_data !== null && col_data !== void 0 ? col_data : '').toString()));\n }\n content += HIGH + _content;\n if (col === col_num - 1) {\n content += HIGH + '\\n';\n }\n else {\n content += EMPTY;\n }\n });\n return content;\n}\nfunction get_max_widths(data) {\n var max_widths = Object.keys(data[0]).map(function (v) { return +v; });\n for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {\n var row_data = data_1[_i];\n row_data.forEach(function (col_data, idx) {\n var width = get_string_width(col_data.toString());\n max_widths[idx] = Math.max(width, max_widths[idx]);\n });\n }\n return max_widths;\n}\nfunction console_table(data, callBack) {\n var row_num = data.length;\n var max_widths = get_max_widths(data);\n var table = '';\n data.forEach(function (row_data, row) {\n if (row <= 1) {\n table += get_edge(max_widths);\n }\n table += wirte_data(max_widths, row_data);\n if (row === row_num - 1) {\n table += get_edge(max_widths, true);\n }\n });\n console.log(table);\n if (callBack) {\n callBack(table);\n }\n}\nexports[\"default\"] = console_table;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/ConsoleTable/index.ts?");
58
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.console_table = void 0;\nvar NODE = '+';\nvar EDGE = '-';\nvar HIGH = '|';\nvar SPACE = ' ';\nvar EMPTY = '';\nfunction get_string_width(str) {\n var width = 0;\n for (var _i = 0, str_1 = str; _i < str_1.length; _i++) {\n var char = str_1[_i];\n width += char.charCodeAt(0) < 128 && char.charCodeAt(0) >= 0 ? 1 : 2;\n }\n return width;\n}\nfunction get_egde(width) {\n var edge = '';\n for (var i = 0; i <= width; i++) {\n edge += EDGE;\n }\n return edge;\n}\nfunction get_edge(widths, no_line_break) {\n if (no_line_break === void 0) { no_line_break = false; }\n var col_num = widths.length;\n var border = '';\n widths.forEach(function (width, col) {\n border += NODE + get_egde(width + 1);\n if (col === col_num - 1) {\n border += NODE + (no_line_break ? EMPTY : '\\n');\n }\n else {\n border += EMPTY;\n }\n });\n return border;\n}\nfunction get_space(width) {\n var space = '';\n for (var i = 0; i <= width; i++) {\n space += SPACE;\n }\n return space;\n}\nfunction wirte_data(widths, data) {\n var col_num = widths.length;\n var content = '';\n widths.forEach(function (width, col) {\n var col_data = data[col];\n var _content = '';\n if (!isNaN(+col_data)) {\n _content += get_space(width - get_string_width(col_data.toString())) + col_data + SPACE;\n }\n else {\n _content += SPACE + (col_data !== null && col_data !== void 0 ? col_data : '') + get_space(width - get_string_width((col_data !== null && col_data !== void 0 ? col_data : '').toString()));\n }\n content += HIGH + _content;\n if (col === col_num - 1) {\n content += HIGH + '\\n';\n }\n else {\n content += EMPTY;\n }\n });\n return content;\n}\nfunction get_max_widths(data) {\n var max_widths = Object.keys(data[0]).map(function (v) { return +v; });\n for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {\n var row_data = data_1[_i];\n row_data.forEach(function (col_data, idx) {\n var width = get_string_width(col_data.toString());\n max_widths[idx] = Math.max(width, max_widths[idx]);\n });\n }\n return max_widths;\n}\nfunction console_table(data, callBack) {\n var row_num = data.length;\n var max_widths = get_max_widths(data);\n var table = '';\n data.forEach(function (row_data, row) {\n if (row <= 1) {\n table += get_edge(max_widths);\n }\n table += wirte_data(max_widths, row_data);\n if (row === row_num - 1) {\n table += get_edge(max_widths, true);\n }\n });\n console.log(table);\n if (callBack) {\n callBack(table);\n }\n}\nexports.console_table = console_table;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/ConsoleTable/index.ts?");
59
59
 
60
60
  /***/ }),
61
61
 
@@ -65,7 +65,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar
65
65
  \*********************************/
66
66
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
67
67
 
68
- eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar __1 = __webpack_require__(/*! .. */ \"./tools/index.ts\");\nfunction deepCopy(data) {\n if ((0, __1.Typeof)(data) === 'date') {\n return new Date(data.toISOString());\n }\n else if ((0, __1.Typeof)(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, __1.Typeof)(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?");
68
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.deepCopy = void 0;\nvar Typeof_1 = __webpack_require__(/*! ../Typeof */ \"./tools/Typeof/index.ts\");\nfunction deepCopy(data) {\n if ((0, Typeof_1.Typeof)(data) === 'date') {\n return new Date(data.toISOString());\n }\n else if ((0, Typeof_1.Typeof)(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.Typeof)(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.deepCopy = deepCopy;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/DeepCopy/index.ts?");
69
69
 
70
70
  /***/ }),
71
71
 
@@ -75,7 +75,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar
75
75
  \******************************/
76
76
  /***/ ((__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 __1 = __webpack_require__(/*! .. */ \"./tools/index.ts\");\nfunction TypeEqual(obj1, obj2) {\n var isEqual = false;\n if ((0, __1.Typeof)(obj1) !== (0, __1.Typeof)(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?");
78
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ObjEqual = exports.ValEqual = exports.TypeEqual = void 0;\nvar Typeof_1 = __webpack_require__(/*! ../Typeof */ \"./tools/Typeof/index.ts\");\nfunction TypeEqual(obj1, obj2) {\n var isEqual = false;\n if ((0, Typeof_1.Typeof)(obj1) !== (0, Typeof_1.Typeof)(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;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/Equal/index.ts?");
79
79
 
80
80
  /***/ }),
81
81
 
@@ -85,7 +85,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
85
85
  \*******************************/
86
86
  /***/ ((__unused_webpack_module, exports) => {
87
87
 
88
- eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nfunction Typeof(value) {\n var object_type = Object.prototype.toString.call(value);\n var reg = new RegExp(' (.+?)]');\n var type = object_type.match(reg)[1];\n return type.toLowerCase();\n}\nexports[\"default\"] = Typeof;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/Typeof/index.ts?");
88
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Typeof = void 0;\nfunction Typeof(value) {\n var object_type = Object.prototype.toString.call(value);\n var reg = new RegExp(' (.+?)]');\n var type = object_type.match(reg)[1];\n return type.toLowerCase();\n}\nexports.Typeof = Typeof;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/Typeof/index.ts?");
89
89
 
90
90
  /***/ }),
91
91
 
@@ -93,9 +93,9 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nfunc
93
93
  /*!************************!*\
94
94
  !*** ./tools/index.ts ***!
95
95
  \************************/
96
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
96
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
97
97
 
98
- eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Typeof = exports.Equal = exports.deepCopy = exports.console_table = void 0;\nvar ConsoleTable_1 = __importDefault(__webpack_require__(/*! ./ConsoleTable */ \"./tools/ConsoleTable/index.ts\"));\nexports.console_table = ConsoleTable_1.default;\nvar DeepCopy_1 = __importDefault(__webpack_require__(/*! ./DeepCopy */ \"./tools/DeepCopy/index.ts\"));\nexports.deepCopy = DeepCopy_1.default;\nvar Equal_1 = __importDefault(__webpack_require__(/*! ./Equal */ \"./tools/Equal/index.ts\"));\nexports.Equal = Equal_1.default;\nvar Typeof_1 = __importDefault(__webpack_require__(/*! ./Typeof */ \"./tools/Typeof/index.ts\"));\nexports.Typeof = Typeof_1.default;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/index.ts?");
98
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Typeof = exports.TypeEqual = exports.ValEqual = exports.ObjEqual = exports.deepCopy = exports.console_table = void 0;\nvar ConsoleTable_1 = __webpack_require__(/*! ./ConsoleTable */ \"./tools/ConsoleTable/index.ts\");\nObject.defineProperty(exports, \"console_table\", ({ enumerable: true, get: function () { return ConsoleTable_1.console_table; } }));\nvar DeepCopy_1 = __webpack_require__(/*! ./DeepCopy */ \"./tools/DeepCopy/index.ts\");\nObject.defineProperty(exports, \"deepCopy\", ({ enumerable: true, get: function () { return DeepCopy_1.deepCopy; } }));\nvar Equal_1 = __webpack_require__(/*! ./Equal */ \"./tools/Equal/index.ts\");\nObject.defineProperty(exports, \"ObjEqual\", ({ enumerable: true, get: function () { return Equal_1.ObjEqual; } }));\nObject.defineProperty(exports, \"ValEqual\", ({ enumerable: true, get: function () { return Equal_1.ValEqual; } }));\nObject.defineProperty(exports, \"TypeEqual\", ({ enumerable: true, get: function () { return Equal_1.TypeEqual; } }));\nvar Typeof_1 = __webpack_require__(/*! ./Typeof */ \"./tools/Typeof/index.ts\");\nObject.defineProperty(exports, \"Typeof\", ({ enumerable: true, get: function () { return Typeof_1.Typeof; } }));\n\n\n//# sourceURL=webpack://hsu-utils/./tools/index.ts?");
99
99
 
100
100
  /***/ })
101
101
 
@@ -119,7 +119,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
119
119
  /******/ };
120
120
  /******/
121
121
  /******/ // Execute the module function
122
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
122
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
123
123
  /******/
124
124
  /******/ // Return the exports of the module
125
125
  /******/ return module.exports;
@@ -129,7 +129,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
129
129
  /******/
130
130
  /******/ // startup
131
131
  /******/ // Load entry module and return exports
132
- /******/ // This entry module is referenced by other modules so it can't be inlined
132
+ /******/ // This entry module can't be inlined because the eval devtool is used.
133
133
  /******/ var __webpack_exports__ = __webpack_require__("./tools/index.ts");
134
134
  /******/
135
135
  /******/ return __webpack_exports__;
@@ -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="+",o="-",n="|",u=" ",a="";function f(e){for(var t=0,r=0,o=e;r<o.length;r++){var n=o[r];t+=n.charCodeAt(0)<128&&n.charCodeAt(0)>=0?1:2}return t}function l(e,t){void 0===t&&(t=!1);var n=e.length,u="";return e.forEach((function(e,f){u+=r+function(e){for(var t="",r=0;r<=e;r++)t+=o;return t}(e+1),u+=f===n-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,o=function(e){for(var t=Object.keys(e[0]).map((function(e){return+e})),r=0,o=e;r<o.length;r++)o[r].forEach((function(e,r){var o=f(e.toString());t[r]=Math.max(o,t[r])}));return t}(e),c="";e.forEach((function(e,t){t<=1&&(c+=l(o)),c+=function(e,t){var r=e.length,o="";return e.forEach((function(e,l){var c=t[l],p="";isNaN(+c)?p+=u+(null!=c?c:"")+i(e-f((null!=c?c:"").toString())):p+=i(e-f(c.toString()))+c+u,o+=n+p,o+=l===r-1?n+"\n":a})),o}(o,e),t===r-1&&(c+=l(o,!0))})),console.log(c),t&&t(c)}},819:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var o=r(243);t.default=function e(t){if("date"===(0,o.Typeof)(t))return new Date(t.toISOString());if("formdata"===(0,o.Typeof)(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.Typeof)(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:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ObjEqual=t.ValEqual=t.TypeEqual=void 0;var o=r(243);function n(e,t){return(0,o.Typeof)(e)===(0,o.Typeof)(t)}function u(e,t){return null===e&&void 0===t||void 0===e&&null===t||("object"==typeof e&&"object"==typeof t?a(e,t):"function"==typeof e&&"function"==typeof t?JSON.stringify(e)===JSON.stringify(t):e===t)}function a(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 o=0;o<e.length&&(r=u(e[o],t[o]));o++);else if("object"==typeof e&&"object"==typeof t)if(Object.keys(e).length!==Object.keys(t).length)r=!1;else for(var n in e)if(!(r=u(e[n],t[n])))break}else null===e&&null===t&&(r=!0);return r}t.TypeEqual=n,t.ValEqual=u,t.ObjEqual=a;var f={ObjEqual:a,ValEqual:u,TypeEqual:n};t.default=f},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 o=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 n=o(r(442));t.console_table=n.default;var u=o(r(819));t.deepCopy=u.default;var a=o(r(962));t.Equal=a.default;var f=o(r(332));t.Typeof=f.default}},t={};var r=function r(o){var n=t[o];if(void 0!==n)return n.exports;var u=t[o]={exports:{}};return e[o].call(u.exports,u,u.exports,r),u.exports}(243);return 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}),t.console_table=void 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.console_table=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],p="";isNaN(+c)?p+=u+(null!=c?c:"")+i(e-f((null!=c?c:"").toString())):p+=i(e-f(c.toString()))+c+u,n+=o+p,n+=l===r-1?o+"\n":a})),n}(n,e),t===r-1&&(c+=l(n,!0))})),console.log(c),t&&t(c)}},819:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepCopy=void 0;var n=r(332);t.deepCopy=function e(t){if("date"===(0,n.Typeof)(t))return new Date(t.toISOString());if("formdata"===(0,n.Typeof)(t)){var r=t,o=new FormData;return r.forEach((function(e,t){o.append(t,e)})),o}if(Array.isArray(t))return t.map((function(t){return"object"==typeof t?e(t):t}));if(t&&"object"===(0,n.Typeof)(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:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ObjEqual=t.ValEqual=t.TypeEqual=void 0;var n=r(332);function o(e,t){return null===e&&void 0===t||void 0===e&&null===t||("object"==typeof e&&"object"==typeof t?u(e,t):"function"==typeof e&&"function"==typeof t?JSON.stringify(e)===JSON.stringify(t):e===t)}function u(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=o(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 u in e)if(!(r=o(e[u],t[u])))break}else null===e&&null===t&&(r=!0);return r}t.TypeEqual=function(e,t){return(0,n.Typeof)(e)===(0,n.Typeof)(t)},t.ValEqual=o,t.ObjEqual=u},332:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Typeof=void 0,t.Typeof=function(e){var t=Object.prototype.toString.call(e),r=new RegExp(" (.+?)]");return t.match(r)[1].toLowerCase()}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var u=t[n]={exports:{}};return e[n](u,u.exports,r),u.exports}var n={};return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.Typeof=e.TypeEqual=e.ValEqual=e.ObjEqual=e.deepCopy=e.console_table=void 0;var t=r(442);Object.defineProperty(e,"console_table",{enumerable:!0,get:function(){return t.console_table}});var o=r(819);Object.defineProperty(e,"deepCopy",{enumerable:!0,get:function(){return o.deepCopy}});var u=r(962);Object.defineProperty(e,"ObjEqual",{enumerable:!0,get:function(){return u.ObjEqual}}),Object.defineProperty(e,"ValEqual",{enumerable:!0,get:function(){return u.ValEqual}}),Object.defineProperty(e,"TypeEqual",{enumerable:!0,get:function(){return u.TypeEqual}});var a=r(332);Object.defineProperty(e,"Typeof",{enumerable:!0,get:function(){return a.Typeof}})})(),n})()));
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  *
3
- * hsu-utils v0.0.0
3
+ * hsu-utils v0.0.2
4
4
  *
5
- * some front-end uilts
5
+ * some front-end utils
6
6
  *
7
7
  * MIT License
8
8
  *
@@ -1,2 +1,2 @@
1
1
  export type ConsoleData = Array<Array<string | number>>;
2
- export default function console_table(data: ConsoleData, callBack?: (str: string) => void): void;
2
+ export declare function console_table(data: ConsoleData, callBack?: (str: string) => void): void;
@@ -70,7 +70,7 @@ function get_max_widths(data) {
70
70
  }
71
71
  return max_widths;
72
72
  }
73
- export default function console_table(data, callBack) {
73
+ export function console_table(data, callBack) {
74
74
  const row_num = data.length;
75
75
  const max_widths = get_max_widths(data);
76
76
  let table = '';
@@ -1 +1 @@
1
- export default function deepCopy<T = unknown>(data: T): T;
1
+ export declare function deepCopy<T = unknown>(data: T): T;
@@ -1,5 +1,5 @@
1
- import { Typeof } from '..';
2
- export default function deepCopy(data) {
1
+ import { Typeof } from '../Typeof';
2
+ export function deepCopy(data) {
3
3
  if (Typeof(data) === 'date') {
4
4
  return new Date(data.toISOString());
5
5
  }
@@ -1,9 +1,3 @@
1
1
  export declare function TypeEqual<T = unknown>(obj1: T, obj2: T): boolean;
2
2
  export declare function ValEqual<T = unknown>(obj1: T, obj2: T): boolean;
3
3
  export declare function ObjEqual<T = object>(obj1: T, obj2: T): boolean;
4
- declare const Equal: {
5
- ObjEqual: typeof ObjEqual;
6
- ValEqual: typeof ValEqual;
7
- TypeEqual: typeof TypeEqual;
8
- };
9
- export default Equal;
package/es/Equal/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Typeof } from '..';
1
+ import { Typeof } from '../Typeof';
2
2
  export function TypeEqual(obj1, obj2) {
3
3
  let isEqual = false;
4
4
  if (Typeof(obj1) !== Typeof(obj2)) {
@@ -62,5 +62,3 @@ export function ObjEqual(obj1, obj2) {
62
62
  }
63
63
  return isEqual;
64
64
  }
65
- const Equal = { ObjEqual, ValEqual, TypeEqual };
66
- export default Equal;
@@ -1,3 +1,3 @@
1
1
  type Type = 'number' | 'string' | 'boolean' | 'object' | 'array' | 'null' | 'undefined' | 'unknown' | 'function' | 'symbol' | 'date' | 'formdata' | string;
2
- export default function Typeof(value: any): Type;
2
+ export declare function Typeof(value: any): Type;
3
3
  export {};
@@ -1,4 +1,4 @@
1
- export default function Typeof(value) {
1
+ export function Typeof(value) {
2
2
  const object_type = Object.prototype.toString.call(value);
3
3
  const reg = new RegExp(' (.+?)]');
4
4
  const type = object_type.match(reg)[1];
package/es/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import console_table, { ConsoleData } from './ConsoleTable';
2
- import deepCopy from './DeepCopy';
3
- import Equal from './Equal';
4
- import Typeof from './Typeof';
1
+ import { console_table } from './ConsoleTable';
2
+ import { deepCopy } from './DeepCopy';
3
+ import { ObjEqual, ValEqual, TypeEqual } from './Equal';
4
+ import { Typeof } from './Typeof';
5
+ export { console_table, deepCopy, ObjEqual, ValEqual, TypeEqual, Typeof };
6
+ import { ConsoleData } from './ConsoleTable';
5
7
  export type { ConsoleData };
6
- export { console_table, deepCopy, Equal, Typeof };
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import console_table from './ConsoleTable';
2
- import deepCopy from './DeepCopy';
3
- import Equal from './Equal';
4
- import Typeof from './Typeof';
5
- export { console_table, deepCopy, Equal, Typeof };
1
+ import { console_table } from './ConsoleTable';
2
+ import { deepCopy } from './DeepCopy';
3
+ import { ObjEqual, ValEqual, TypeEqual } from './Equal';
4
+ import { Typeof } from './Typeof';
5
+ export { console_table, deepCopy, ObjEqual, ValEqual, TypeEqual, Typeof };
@@ -1,2 +1,2 @@
1
1
  export type ConsoleData = Array<Array<string | number>>;
2
- export default function console_table(data: ConsoleData, callBack?: (str: string) => void): void;
2
+ export declare function console_table(data: ConsoleData, callBack?: (str: string) => void): void;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.console_table = void 0;
3
4
  var NODE = '+';
4
5
  var EDGE = '-';
5
6
  var HIGH = '|';
@@ -93,4 +94,4 @@ function console_table(data, callBack) {
93
94
  callBack(table);
94
95
  }
95
96
  }
96
- exports.default = console_table;
97
+ exports.console_table = console_table;
@@ -1 +1 @@
1
- export default function deepCopy<T = unknown>(data: T): T;
1
+ export declare function deepCopy<T = unknown>(data: T): T;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var __1 = require("..");
3
+ exports.deepCopy = void 0;
4
+ var Typeof_1 = require("../Typeof");
4
5
  function deepCopy(data) {
5
- if ((0, __1.Typeof)(data) === 'date') {
6
+ if ((0, Typeof_1.Typeof)(data) === 'date') {
6
7
  return new Date(data.toISOString());
7
8
  }
8
- else if ((0, __1.Typeof)(data) === 'formdata') {
9
+ else if ((0, Typeof_1.Typeof)(data) === 'formdata') {
9
10
  var _data = data;
10
11
  var _formData_1 = new FormData();
11
12
  _data.forEach(function (value, key) {
@@ -24,7 +25,7 @@ function deepCopy(data) {
24
25
  });
25
26
  return newData;
26
27
  }
27
- else if (data && (0, __1.Typeof)(data) === 'object') {
28
+ else if (data && (0, Typeof_1.Typeof)(data) === 'object') {
28
29
  var _data_1 = data;
29
30
  var newData_1 = {};
30
31
  Object.keys(_data_1).forEach(function (key) {
@@ -40,4 +41,4 @@ function deepCopy(data) {
40
41
  }
41
42
  return data;
42
43
  }
43
- exports.default = deepCopy;
44
+ exports.deepCopy = deepCopy;
@@ -1,9 +1,3 @@
1
1
  export declare function TypeEqual<T = unknown>(obj1: T, obj2: T): boolean;
2
2
  export declare function ValEqual<T = unknown>(obj1: T, obj2: T): boolean;
3
3
  export declare function ObjEqual<T = object>(obj1: T, obj2: T): boolean;
4
- declare const Equal: {
5
- ObjEqual: typeof ObjEqual;
6
- ValEqual: typeof ValEqual;
7
- TypeEqual: typeof TypeEqual;
8
- };
9
- export default Equal;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObjEqual = exports.ValEqual = exports.TypeEqual = void 0;
4
- var __1 = require("..");
4
+ var Typeof_1 = require("../Typeof");
5
5
  function TypeEqual(obj1, obj2) {
6
6
  var isEqual = false;
7
- if ((0, __1.Typeof)(obj1) !== (0, __1.Typeof)(obj2)) {
7
+ if ((0, Typeof_1.Typeof)(obj1) !== (0, Typeof_1.Typeof)(obj2)) {
8
8
  isEqual = false;
9
9
  }
10
10
  else {
@@ -68,5 +68,3 @@ function ObjEqual(obj1, obj2) {
68
68
  return isEqual;
69
69
  }
70
70
  exports.ObjEqual = ObjEqual;
71
- var Equal = { ObjEqual: ObjEqual, ValEqual: ValEqual, TypeEqual: TypeEqual };
72
- exports.default = Equal;
@@ -1,3 +1,3 @@
1
1
  type Type = 'number' | 'string' | 'boolean' | 'object' | 'array' | 'null' | 'undefined' | 'unknown' | 'function' | 'symbol' | 'date' | 'formdata' | string;
2
- export default function Typeof(value: any): Type;
2
+ export declare function Typeof(value: any): Type;
3
3
  export {};
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Typeof = void 0;
3
4
  function Typeof(value) {
4
5
  var object_type = Object.prototype.toString.call(value);
5
6
  var reg = new RegExp(' (.+?)]');
6
7
  var type = object_type.match(reg)[1];
7
8
  return type.toLowerCase();
8
9
  }
9
- exports.default = Typeof;
10
+ exports.Typeof = Typeof;
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import console_table, { ConsoleData } from './ConsoleTable';
2
- import deepCopy from './DeepCopy';
3
- import Equal from './Equal';
4
- import Typeof from './Typeof';
1
+ import { console_table } from './ConsoleTable';
2
+ import { deepCopy } from './DeepCopy';
3
+ import { ObjEqual, ValEqual, TypeEqual } from './Equal';
4
+ import { Typeof } from './Typeof';
5
+ export { console_table, deepCopy, ObjEqual, ValEqual, TypeEqual, Typeof };
6
+ import { ConsoleData } from './ConsoleTable';
5
7
  export type { ConsoleData };
6
- export { console_table, deepCopy, Equal, Typeof };
package/lib/index.js CHANGED
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Typeof = exports.Equal = exports.deepCopy = exports.console_table = void 0;
7
- var ConsoleTable_1 = __importDefault(require("./ConsoleTable"));
8
- exports.console_table = ConsoleTable_1.default;
9
- var DeepCopy_1 = __importDefault(require("./DeepCopy"));
10
- exports.deepCopy = DeepCopy_1.default;
11
- var Equal_1 = __importDefault(require("./Equal"));
12
- exports.Equal = Equal_1.default;
13
- var Typeof_1 = __importDefault(require("./Typeof"));
14
- exports.Typeof = Typeof_1.default;
3
+ exports.Typeof = exports.TypeEqual = exports.ValEqual = exports.ObjEqual = exports.deepCopy = exports.console_table = void 0;
4
+ var ConsoleTable_1 = require("./ConsoleTable");
5
+ Object.defineProperty(exports, "console_table", { enumerable: true, get: function () { return ConsoleTable_1.console_table; } });
6
+ var DeepCopy_1 = require("./DeepCopy");
7
+ Object.defineProperty(exports, "deepCopy", { enumerable: true, get: function () { return DeepCopy_1.deepCopy; } });
8
+ var Equal_1 = require("./Equal");
9
+ Object.defineProperty(exports, "ObjEqual", { enumerable: true, get: function () { return Equal_1.ObjEqual; } });
10
+ Object.defineProperty(exports, "ValEqual", { enumerable: true, get: function () { return Equal_1.ValEqual; } });
11
+ Object.defineProperty(exports, "TypeEqual", { enumerable: true, get: function () { return Equal_1.TypeEqual; } });
12
+ var Typeof_1 = require("./Typeof");
13
+ Object.defineProperty(exports, "Typeof", { enumerable: true, get: function () { return Typeof_1.Typeof; } });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hsu-utils",
3
- "version": "0.0.1",
4
- "description": "some front-end uilts",
3
+ "version": "0.0.3",
4
+ "description": "some front-end utils",
5
5
  "repository": "git@github.com:VitaTsui/hsu-utils.git",
6
6
  "author": "VitaHsu <vitahsu7@gmail.com>",
7
7
  "license": "MIT",