@cashub/utils 0.5.0 → 0.6.1

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.
Files changed (44) hide show
  1. package/aria/constant.js +2 -3
  2. package/aria/index.js +1 -3
  3. package/array/generateRange.js +4 -9
  4. package/array/index.js +1 -3
  5. package/check/index.js +6 -13
  6. package/check/isContainSpace.js +3 -6
  7. package/check/isInteger.js +3 -6
  8. package/check/isValidEmail.js +3 -6
  9. package/check/isValidPassword.js +3 -6
  10. package/check/isValidTelephone.js +3 -6
  11. package/check/isValidUrl.js +3 -6
  12. package/copyToClipboard.js +4 -7
  13. package/date/firstDay.js +2 -5
  14. package/date/index.js +2 -5
  15. package/date/lastDay.js +2 -5
  16. package/element/appendElementTo.js +5 -11
  17. package/element/index.js +1 -3
  18. package/file/dataURLtoFile.js +7 -28
  19. package/file/getBase64DataUrlFromFile.js +3 -8
  20. package/file/index.js +3 -7
  21. package/file/readText.js +6 -12
  22. package/format/convertSecondsToTimeFormat.js +9 -12
  23. package/format/datetimeFormat.js +21 -52
  24. package/format/formatDate.js +10 -16
  25. package/format/formatSize.js +3 -8
  26. package/format/index.js +4 -9
  27. package/image/getBase64DataUrlFromUrl.js +7 -10
  28. package/image/index.js +2 -5
  29. package/image/resizeImage.js +10 -16
  30. package/index.js +24 -36
  31. package/object/index.js +27 -0
  32. package/object/mergeArrayObject.js +27 -0
  33. package/object/mergeArrayObjectWithOrder.js +36 -0
  34. package/object/mergeObject.js +20 -0
  35. package/package.json +4 -4
  36. package/react/index.js +2 -5
  37. package/react/isReactComponent.js +6 -9
  38. package/react/setRef.js +2 -5
  39. package/replace/index.js +1 -3
  40. package/replace/replaceNonLatinSymbol.js +26 -29
  41. package/sort/index.js +1 -3
  42. package/sort/sortObjectByProperty.js +7 -12
  43. package/url/index.js +1 -3
  44. 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
- var sortObjectByProperty = function sortObjectByProperty(property, sort) {
9
- var order = sort === 'asc' ? 1 : -1;
10
- return function (objectA, objectB) {
11
- var propertyA = typeof objectA[property] === 'string' ? objectA[property].toLowerCase() : objectA[property].toString().toLowerCase();
12
- var propertyB = typeof objectB[property] === 'string' ? objectB[property].toLowerCase() : objectB[property].toString().toLowerCase();
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 get() {
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 }; }
@@ -4,81 +4,36 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
-
10
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
-
12
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
13
-
14
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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
- var searchParams = new URLSearchParams(search);
29
- var newParams = new URLSearchParams(newParameters);
30
- var searchParamsObj = {};
31
- var searchParamsArr = [];
32
-
33
- var _iterator = _createForOfIteratorHelper(searchParams.entries()),
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
- var _iterator2 = _createForOfIteratorHelper(newParams.entries()),
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([].concat(searchParamsArr).join('&'));
30
+ url = "".concat(pathname, "?").concat([...searchParamsArr].join('&'));
73
31
  } else {
74
- url = "".concat(pathname, "?").concat([].concat(searchParamsArr).join(''));
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;