hsu-utils 0.0.2 → 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 +12 -12
- package/dist/hsu-utils.min.js +1 -1
- package/dist/hsu-utils.min.js.LICENSE.txt +2 -2
- package/es/ConsoleTable/index.d.ts +1 -1
- package/es/ConsoleTable/index.js +1 -1
- package/es/DeepCopy/index.d.ts +1 -1
- package/es/DeepCopy/index.js +2 -2
- package/es/Equal/index.d.ts +0 -6
- package/es/Equal/index.js +1 -3
- package/es/Typeof/index.d.ts +1 -1
- package/es/Typeof/index.js +1 -1
- package/es/index.d.ts +6 -5
- package/es/index.js +5 -5
- package/lib/ConsoleTable/index.d.ts +1 -1
- package/lib/ConsoleTable/index.js +2 -1
- package/lib/DeepCopy/index.d.ts +1 -1
- package/lib/DeepCopy/index.js +6 -8
- package/lib/Equal/index.d.ts +0 -6
- package/lib/Equal/index.js +2 -7
- package/lib/Typeof/index.d.ts +1 -1
- package/lib/Typeof/index.js +2 -1
- package/lib/index.d.ts +6 -5
- package/lib/index.js +11 -12
- package/package.json +2 -2
package/dist/hsu-utils.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
/*!
|
2
2
|
*
|
3
|
-
* hsu-utils v0.0.
|
3
|
+
* hsu-utils v0.0.2
|
4
4
|
*
|
5
|
-
* some front-end
|
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
|
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
|
|
@@ -63,9 +63,9 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar
|
|
63
63
|
/*!*********************************!*\
|
64
64
|
!*** ./tools/DeepCopy/index.ts ***!
|
65
65
|
\*********************************/
|
66
|
-
/***/ (
|
66
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
67
67
|
|
68
|
-
eval("\
|
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
|
|
@@ -73,9 +73,9 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
73
73
|
/*!******************************!*\
|
74
74
|
!*** ./tools/Equal/index.ts ***!
|
75
75
|
\******************************/
|
76
|
-
/***/ (
|
76
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
77
77
|
|
78
|
-
eval("\
|
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("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
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
|
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
|
-
/***/ (
|
96
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
97
97
|
|
98
|
-
eval("\
|
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]
|
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
|
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__;
|
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="+",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.
|
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,2 +1,2 @@
|
|
1
1
|
export type ConsoleData = Array<Array<string | number>>;
|
2
|
-
export
|
2
|
+
export declare function console_table(data: ConsoleData, callBack?: (str: string) => void): void;
|
package/es/ConsoleTable/index.js
CHANGED
@@ -70,7 +70,7 @@ function get_max_widths(data) {
|
|
70
70
|
}
|
71
71
|
return max_widths;
|
72
72
|
}
|
73
|
-
export
|
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 = '';
|
package/es/DeepCopy/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export
|
1
|
+
export declare function deepCopy<T = unknown>(data: T): T;
|
package/es/DeepCopy/index.js
CHANGED
package/es/Equal/index.d.ts
CHANGED
@@ -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 '../Typeof';
|
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;
|
package/es/Typeof/index.d.ts
CHANGED
package/es/Typeof/index.js
CHANGED
package/es/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import
|
2
|
-
import deepCopy from './DeepCopy';
|
3
|
-
import
|
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
|
4
|
-
import Typeof from './Typeof';
|
5
|
-
export { console_table, deepCopy,
|
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
|
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.
|
97
|
+
exports.console_table = console_table;
|
package/lib/DeepCopy/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export
|
1
|
+
export declare function deepCopy<T = unknown>(data: T): T;
|
package/lib/DeepCopy/index.js
CHANGED
@@ -1,14 +1,12 @@
|
|
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
|
-
|
3
|
+
exports.deepCopy = void 0;
|
4
|
+
var Typeof_1 = require("../Typeof");
|
7
5
|
function deepCopy(data) {
|
8
|
-
if ((0, Typeof_1.
|
6
|
+
if ((0, Typeof_1.Typeof)(data) === 'date') {
|
9
7
|
return new Date(data.toISOString());
|
10
8
|
}
|
11
|
-
else if ((0, Typeof_1.
|
9
|
+
else if ((0, Typeof_1.Typeof)(data) === 'formdata') {
|
12
10
|
var _data = data;
|
13
11
|
var _formData_1 = new FormData();
|
14
12
|
_data.forEach(function (value, key) {
|
@@ -27,7 +25,7 @@ function deepCopy(data) {
|
|
27
25
|
});
|
28
26
|
return newData;
|
29
27
|
}
|
30
|
-
else if (data && (0, Typeof_1.
|
28
|
+
else if (data && (0, Typeof_1.Typeof)(data) === 'object') {
|
31
29
|
var _data_1 = data;
|
32
30
|
var newData_1 = {};
|
33
31
|
Object.keys(_data_1).forEach(function (key) {
|
@@ -43,4 +41,4 @@ function deepCopy(data) {
|
|
43
41
|
}
|
44
42
|
return data;
|
45
43
|
}
|
46
|
-
exports.
|
44
|
+
exports.deepCopy = deepCopy;
|
package/lib/Equal/index.d.ts
CHANGED
@@ -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/lib/Equal/index.js
CHANGED
@@ -1,13 +1,10 @@
|
|
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
3
|
exports.ObjEqual = exports.ValEqual = exports.TypeEqual = void 0;
|
7
|
-
var Typeof_1 =
|
4
|
+
var Typeof_1 = require("../Typeof");
|
8
5
|
function TypeEqual(obj1, obj2) {
|
9
6
|
var isEqual = false;
|
10
|
-
if ((0, Typeof_1.
|
7
|
+
if ((0, Typeof_1.Typeof)(obj1) !== (0, Typeof_1.Typeof)(obj2)) {
|
11
8
|
isEqual = false;
|
12
9
|
}
|
13
10
|
else {
|
@@ -71,5 +68,3 @@ function ObjEqual(obj1, obj2) {
|
|
71
68
|
return isEqual;
|
72
69
|
}
|
73
70
|
exports.ObjEqual = ObjEqual;
|
74
|
-
var Equal = { ObjEqual: ObjEqual, ValEqual: ValEqual, TypeEqual: TypeEqual };
|
75
|
-
exports.default = Equal;
|
package/lib/Typeof/index.d.ts
CHANGED
package/lib/Typeof/index.js
CHANGED
@@ -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.
|
10
|
+
exports.Typeof = Typeof;
|
package/lib/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import
|
2
|
-
import deepCopy from './DeepCopy';
|
3
|
-
import
|
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.
|
7
|
-
var ConsoleTable_1 =
|
8
|
-
exports
|
9
|
-
var DeepCopy_1 =
|
10
|
-
exports
|
11
|
-
var Equal_1 =
|
12
|
-
exports
|
13
|
-
|
14
|
-
exports
|
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.
|
4
|
-
"description": "some front-end
|
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",
|