hsu-utils 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/hsu-utils.js +6 -6
- package/dist/hsu-utils.min.js +1 -1
- package/dist/hsu-utils.min.js.LICENSE.txt +2 -2
- package/es/DeepCopy/index.js +1 -1
- package/es/Equal/index.d.ts +1 -1
- package/es/Equal/index.js +6 -2
- package/es/index.d.ts +3 -2
- package/lib/DeepCopy/index.js +4 -7
- package/lib/Equal/index.d.ts +1 -1
- package/lib/Equal/index.js +7 -6
- package/lib/index.d.ts +3 -2
- 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.3
|
4
4
|
*
|
5
|
-
* some front-end
|
5
|
+
* some front-end utils
|
6
6
|
*
|
7
7
|
* MIT License
|
8
8
|
*
|
@@ -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 }));\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?");
|
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 __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 = {\n ValEqual: ValEqual,\n TypeEqual: TypeEqual,\n ObjEqual: ObjEqual\n};\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="+",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={ValEqual:u,TypeEqual:n,ObjEqual:a};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})()));
|
package/es/DeepCopy/index.js
CHANGED
package/es/Equal/index.d.ts
CHANGED
@@ -2,8 +2,8 @@ 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
4
|
declare const Equal: {
|
5
|
-
ObjEqual: typeof ObjEqual;
|
6
5
|
ValEqual: typeof ValEqual;
|
7
6
|
TypeEqual: typeof TypeEqual;
|
7
|
+
ObjEqual: typeof ObjEqual;
|
8
8
|
};
|
9
9
|
export default Equal;
|
package/es/Equal/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import Typeof from '
|
1
|
+
import { Typeof } from '..';
|
2
2
|
export function TypeEqual(obj1, obj2) {
|
3
3
|
let isEqual = false;
|
4
4
|
if (Typeof(obj1) !== Typeof(obj2)) {
|
@@ -62,5 +62,9 @@ export function ObjEqual(obj1, obj2) {
|
|
62
62
|
}
|
63
63
|
return isEqual;
|
64
64
|
}
|
65
|
-
const Equal = {
|
65
|
+
const Equal = {
|
66
|
+
ValEqual,
|
67
|
+
TypeEqual,
|
68
|
+
ObjEqual
|
69
|
+
};
|
66
70
|
export default Equal;
|
package/es/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import console_table
|
1
|
+
import console_table from './ConsoleTable';
|
2
2
|
import deepCopy from './DeepCopy';
|
3
3
|
import Equal from './Equal';
|
4
4
|
import Typeof from './Typeof';
|
5
|
-
export type { ConsoleData };
|
6
5
|
export { console_table, deepCopy, Equal, Typeof };
|
6
|
+
import { ConsoleData } from './ConsoleTable';
|
7
|
+
export type { ConsoleData };
|
package/lib/DeepCopy/index.js
CHANGED
@@ -1,14 +1,11 @@
|
|
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
|
-
var
|
3
|
+
var __1 = require("..");
|
7
4
|
function deepCopy(data) {
|
8
|
-
if ((0,
|
5
|
+
if ((0, __1.Typeof)(data) === 'date') {
|
9
6
|
return new Date(data.toISOString());
|
10
7
|
}
|
11
|
-
else if ((0,
|
8
|
+
else if ((0, __1.Typeof)(data) === 'formdata') {
|
12
9
|
var _data = data;
|
13
10
|
var _formData_1 = new FormData();
|
14
11
|
_data.forEach(function (value, key) {
|
@@ -27,7 +24,7 @@ function deepCopy(data) {
|
|
27
24
|
});
|
28
25
|
return newData;
|
29
26
|
}
|
30
|
-
else if (data && (0,
|
27
|
+
else if (data && (0, __1.Typeof)(data) === 'object') {
|
31
28
|
var _data_1 = data;
|
32
29
|
var newData_1 = {};
|
33
30
|
Object.keys(_data_1).forEach(function (key) {
|
package/lib/Equal/index.d.ts
CHANGED
@@ -2,8 +2,8 @@ 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
4
|
declare const Equal: {
|
5
|
-
ObjEqual: typeof ObjEqual;
|
6
5
|
ValEqual: typeof ValEqual;
|
7
6
|
TypeEqual: typeof TypeEqual;
|
7
|
+
ObjEqual: typeof ObjEqual;
|
8
8
|
};
|
9
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
|
4
|
+
var __1 = require("..");
|
8
5
|
function TypeEqual(obj1, obj2) {
|
9
6
|
var isEqual = false;
|
10
|
-
if ((0,
|
7
|
+
if ((0, __1.Typeof)(obj1) !== (0, __1.Typeof)(obj2)) {
|
11
8
|
isEqual = false;
|
12
9
|
}
|
13
10
|
else {
|
@@ -71,5 +68,9 @@ function ObjEqual(obj1, obj2) {
|
|
71
68
|
return isEqual;
|
72
69
|
}
|
73
70
|
exports.ObjEqual = ObjEqual;
|
74
|
-
var Equal = {
|
71
|
+
var Equal = {
|
72
|
+
ValEqual: ValEqual,
|
73
|
+
TypeEqual: TypeEqual,
|
74
|
+
ObjEqual: ObjEqual
|
75
|
+
};
|
75
76
|
exports.default = Equal;
|
package/lib/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import console_table
|
1
|
+
import console_table from './ConsoleTable';
|
2
2
|
import deepCopy from './DeepCopy';
|
3
3
|
import Equal from './Equal';
|
4
4
|
import Typeof from './Typeof';
|
5
|
-
export type { ConsoleData };
|
6
5
|
export { console_table, deepCopy, Equal, Typeof };
|
6
|
+
import { ConsoleData } from './ConsoleTable';
|
7
|
+
export type { ConsoleData };
|
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.4",
|
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",
|