@cashub/utils 0.5.0 → 0.6.0
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/aria/constant.js +2 -3
- package/aria/index.js +1 -3
- package/array/generateRange.js +4 -9
- package/array/index.js +1 -3
- package/check/index.js +6 -13
- package/check/isContainSpace.js +3 -6
- package/check/isInteger.js +3 -6
- package/check/isValidEmail.js +3 -6
- package/check/isValidPassword.js +3 -6
- package/check/isValidTelephone.js +3 -6
- package/check/isValidUrl.js +3 -6
- package/copyToClipboard.js +4 -7
- package/date/firstDay.js +2 -5
- package/date/index.js +2 -5
- package/date/lastDay.js +2 -5
- package/element/appendElementTo.js +5 -11
- package/element/index.js +1 -3
- package/file/dataURLtoFile.js +7 -28
- package/file/getBase64DataUrlFromFile.js +3 -8
- package/file/index.js +3 -7
- package/file/readText.js +6 -12
- package/format/convertSecondsToTimeFormat.js +9 -12
- package/format/datetimeFormat.js +21 -52
- package/format/formatDate.js +10 -16
- package/format/formatSize.js +3 -8
- package/format/index.js +4 -9
- package/image/getBase64DataUrlFromUrl.js +7 -10
- package/image/index.js +2 -5
- package/image/resizeImage.js +10 -16
- package/index.js +24 -36
- package/object/index.js +27 -0
- package/object/mergeArrayObject.js +27 -0
- package/object/mergeArrayObjectWithOrder.js +36 -0
- package/object/mergeObject.js +20 -0
- package/package.json +1 -1
- package/react/index.js +2 -5
- package/react/isReactComponent.js +6 -9
- package/react/setRef.js +2 -5
- package/replace/index.js +1 -3
- package/replace/replaceNonLatinSymbol.js +26 -29
- package/sort/index.js +1 -3
- package/sort/sortObjectByProperty.js +7 -12
- package/url/index.js +1 -3
- package/url/urlParameters.js +20 -65
|
@@ -4,23 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var result = 0;
|
|
14
|
-
|
|
7
|
+
const sortObjectByProperty = (property, sort) => {
|
|
8
|
+
const order = sort === 'asc' ? 1 : -1;
|
|
9
|
+
return (objectA, objectB) => {
|
|
10
|
+
const propertyA = typeof objectA[property] === 'string' ? objectA[property].toLowerCase() : objectA[property].toString().toLowerCase();
|
|
11
|
+
const propertyB = typeof objectB[property] === 'string' ? objectB[property].toLowerCase() : objectB[property].toString().toLowerCase();
|
|
12
|
+
let result = 0;
|
|
15
13
|
if (propertyA < propertyB) {
|
|
16
14
|
result = -1;
|
|
17
15
|
} else if (propertyA > propertyB) {
|
|
18
16
|
result = 1;
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
return result * order;
|
|
22
19
|
};
|
|
23
20
|
};
|
|
24
|
-
|
|
25
|
-
var _default = sortObjectByProperty;
|
|
26
|
-
exports.default = _default;
|
|
21
|
+
var _default = exports.default = sortObjectByProperty;
|
package/url/index.js
CHANGED
|
@@ -5,11 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "urlParameters", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _urlParameters.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
13
12
|
var _urlParameters = _interopRequireDefault(require("./urlParameters"));
|
|
14
|
-
|
|
15
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/url/urlParameters.js
CHANGED
|
@@ -4,81 +4,36 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
17
|
-
|
|
18
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
19
|
-
|
|
20
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
21
|
-
|
|
22
|
-
var urlParameters = function urlParameters(location, newParameters) {
|
|
23
|
-
var pathname = location.pathname,
|
|
24
|
-
search = location.search;
|
|
25
|
-
var url = ''; // 如果原本的網址有帶參數
|
|
26
|
-
|
|
7
|
+
const urlParameters = (location, newParameters) => {
|
|
8
|
+
const {
|
|
9
|
+
pathname,
|
|
10
|
+
search
|
|
11
|
+
} = location;
|
|
12
|
+
let url = '';
|
|
13
|
+
|
|
14
|
+
// 如果原本的網址有帶參數
|
|
27
15
|
if (search) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
_step;
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
38
|
-
var _step$value = _slicedToArray(_step.value, 2),
|
|
39
|
-
key = _step$value[0],
|
|
40
|
-
value = _step$value[1];
|
|
41
|
-
|
|
42
|
-
searchParamsObj[key] = value;
|
|
43
|
-
}
|
|
44
|
-
} catch (err) {
|
|
45
|
-
_iterator.e(err);
|
|
46
|
-
} finally {
|
|
47
|
-
_iterator.f();
|
|
16
|
+
const searchParams = new URLSearchParams(search);
|
|
17
|
+
const newParams = new URLSearchParams(newParameters);
|
|
18
|
+
const searchParamsObj = {};
|
|
19
|
+
const searchParamsArr = [];
|
|
20
|
+
for (const [key, value] of searchParams.entries()) {
|
|
21
|
+
searchParamsObj[key] = value;
|
|
48
22
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
_step2;
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
55
|
-
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
56
|
-
newParamsKey = _step2$value[0],
|
|
57
|
-
newParamsValue = _step2$value[1];
|
|
58
|
-
|
|
59
|
-
searchParamsObj[newParamsKey] = newParamsValue;
|
|
60
|
-
}
|
|
61
|
-
} catch (err) {
|
|
62
|
-
_iterator2.e(err);
|
|
63
|
-
} finally {
|
|
64
|
-
_iterator2.f();
|
|
23
|
+
for (const [newParamsKey, newParamsValue] of newParams.entries()) {
|
|
24
|
+
searchParamsObj[newParamsKey] = newParamsValue;
|
|
65
25
|
}
|
|
66
|
-
|
|
67
|
-
for (var paramsKey in searchParamsObj) {
|
|
26
|
+
for (const paramsKey in searchParamsObj) {
|
|
68
27
|
searchParamsArr.push("".concat(paramsKey, "=").concat(searchParamsObj[paramsKey]));
|
|
69
28
|
}
|
|
70
|
-
|
|
71
29
|
if (searchParamsArr.length >= 2) {
|
|
72
|
-
url = "".concat(pathname, "?").concat([].
|
|
30
|
+
url = "".concat(pathname, "?").concat([...searchParamsArr].join('&'));
|
|
73
31
|
} else {
|
|
74
|
-
url = "".concat(pathname, "?").concat([].
|
|
32
|
+
url = "".concat(pathname, "?").concat([...searchParamsArr].join(''));
|
|
75
33
|
}
|
|
76
34
|
} else {
|
|
77
35
|
url = "".concat(pathname, "?").concat(newParameters);
|
|
78
36
|
}
|
|
79
|
-
|
|
80
37
|
return url;
|
|
81
38
|
};
|
|
82
|
-
|
|
83
|
-
var _default = urlParameters;
|
|
84
|
-
exports.default = _default;
|
|
39
|
+
var _default = exports.default = urlParameters;
|