@wikicasa-dev/utilities 1.2.9 → 1.2.10
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/dist/index.js +34 -34
- package/dist/utils/ObjectUtils.d.ts +32 -23
- package/dist/utils/ObjectUtils.js +12 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,53 +3,52 @@ import { rgba as a } from "./utils/ColorUtils.js";
|
|
|
3
3
|
import { decodeCookie as i, encodeCookie as l, getCookie as p, removeCookie as n } from "./utils/CookieUtils.js";
|
|
4
4
|
import { formatCurrency as E, formatCurrencyShort as f } from "./utils/CurrencyUtils.js";
|
|
5
5
|
import { formatDate as d, formatDateToddMMYYYY as u, getStartAndEndOfDayUTC as x, subtractDaysFromDate as g } from "./utils/DateUtils.js";
|
|
6
|
-
import { getCurrentDeviceSize as O, isMobile as C, isSafari as
|
|
7
|
-
import { emptyElem as
|
|
8
|
-
import { hash256 as
|
|
9
|
-
import { debounce as
|
|
6
|
+
import { getCurrentDeviceSize as O, isMobile as C, isSafari as S, isWindows as y, isiOSDevice as P } from "./utils/DeviceDetectionUtils.js";
|
|
7
|
+
import { emptyElem as D, getSingleElement as L, hideElem as R, showElem as T } from "./utils/DOMUtils.js";
|
|
8
|
+
import { hash256 as G, hashEmail as N } from "./utils/EmailUtils.js";
|
|
9
|
+
import { debounce as h, isPromise as M } from "./utils/FunctionUtils.js";
|
|
10
10
|
import { awaitableSetTimeout as I, createCustomEvent as w } from "./utils/GenericUtils.js";
|
|
11
11
|
import { formatFloat as k, formatInteger as F, formatLocaleNumber as U, formatLocaleNumberAuto as Y, formatNumber as H, formatterNumberObj as W, parseLocaleNumber as z, parseLocaleNumberAuto as Q } from "./utils/NumberUtils.js";
|
|
12
|
-
import {
|
|
12
|
+
import { areObjectsEqual as B, deepCopy as K, getOrDefault as V, getOrNull as J, invertFlatObject as Z, invertKeyToValue as $, isEmptyObject as ee, mergeDeep as oe, shallowCopyObjectTo as re } from "./utils/ObjectUtils.js";
|
|
13
13
|
import { observeOnce as ae } from "./utils/ObserverUtils.js";
|
|
14
14
|
import { addPermissionStateListener as ie, onNotificationsPermissionChange as le } from "./utils/PermissionUtils.js";
|
|
15
15
|
import { buildParams as ne, buildURL as se } from "./utils/RESB_UrlBuilder.js";
|
|
16
16
|
import { capitalizeFirstLetter as fe, cleanASCII as ce, decodeTextWithEntities as de, replaceAll as ue, replaceAllTokens as xe, stringToHyphened as ge, strip as be } from "./utils/StringUtils.js";
|
|
17
17
|
import { appendQueryString as Ce } from "./utils/URLBuilderUtils.js";
|
|
18
|
-
import { COMPETITOR_REGEX as
|
|
19
|
-
import { browserSupportGeolocation as
|
|
18
|
+
import { COMPETITOR_REGEX as ye, DATE_REGEX as Pe, EMAIL_REGEX as Ae, EMAIL_REGEX_INTO_TEXT as De, EXCLUDED_REGEX as Le, GLOBAL_PHONE_REGEX as Re, PASSWORD_REGEX as Te, PHONE_REGEX as _e, ROOMS_REGEX as Ge, SQM_REGEX as Ne } from "./utils/RegexUtils.js";
|
|
19
|
+
import { browserSupportGeolocation as he, getUserPosition as Me } from "./utils/GeolocationUtils.js";
|
|
20
20
|
import { formatAddress as Ie, formattedAddress as we } from "./utils/AdressUtils.js";
|
|
21
21
|
import { googlePlaceConverter as ke } from "./utils/GAutocompleteUtils.js";
|
|
22
22
|
import { downloadFile as Ue } from "./utils/DownloadUtils.js";
|
|
23
23
|
import { calcPolygonCenter as He, encodePolygon as We, getMinMaxLatLng as ze, getPolygonString as Qe, parsePoints as qe, removeDuplicatePoints as Be } from "./utils/MapUtils.js";
|
|
24
24
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
ye as COMPETITOR_REGEX,
|
|
26
|
+
Pe as DATE_REGEX,
|
|
27
27
|
Ae as EMAIL_REGEX,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
De as EMAIL_REGEX_INTO_TEXT,
|
|
29
|
+
Le as EXCLUDED_REGEX,
|
|
30
|
+
Re as GLOBAL_PHONE_REGEX,
|
|
31
|
+
Te as PASSWORD_REGEX,
|
|
32
32
|
_e as PHONE_REGEX,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
Ge as ROOMS_REGEX,
|
|
34
|
+
Ne as SQM_REGEX,
|
|
35
35
|
ie as addPermissionStateListener,
|
|
36
36
|
Ce as appendQueryString,
|
|
37
|
-
B as
|
|
38
|
-
K as areObjectsEqual,
|
|
37
|
+
B as areObjectsEqual,
|
|
39
38
|
I as awaitableSetTimeout,
|
|
40
|
-
|
|
39
|
+
he as browserSupportGeolocation,
|
|
41
40
|
ne as buildParams,
|
|
42
41
|
se as buildURL,
|
|
43
42
|
He as calcPolygonCenter,
|
|
44
43
|
fe as capitalizeFirstLetter,
|
|
45
44
|
ce as cleanASCII,
|
|
46
45
|
w as createCustomEvent,
|
|
47
|
-
|
|
46
|
+
h as debounce,
|
|
48
47
|
i as decodeCookie,
|
|
49
48
|
de as decodeTextWithEntities,
|
|
50
|
-
|
|
49
|
+
K as deepCopy,
|
|
51
50
|
Ue as downloadFile,
|
|
52
|
-
|
|
51
|
+
D as emptyElem,
|
|
53
52
|
l as encodeCookie,
|
|
54
53
|
We as encodePolygon,
|
|
55
54
|
Ie as formatAddress,
|
|
@@ -67,25 +66,26 @@ export {
|
|
|
67
66
|
p as getCookie,
|
|
68
67
|
O as getCurrentDeviceSize,
|
|
69
68
|
ze as getMinMaxLatLng,
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
V as getOrDefault,
|
|
70
|
+
J as getOrNull,
|
|
72
71
|
Qe as getPolygonString,
|
|
73
|
-
|
|
72
|
+
L as getSingleElement,
|
|
74
73
|
x as getStartAndEndOfDayUTC,
|
|
75
74
|
Me as getUserPosition,
|
|
76
75
|
ke as googlePlaceConverter,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
G as hash256,
|
|
77
|
+
N as hashEmail,
|
|
78
|
+
R as hideElem,
|
|
79
|
+
Z as invertFlatObject,
|
|
80
|
+
$ as invertKeyToValue,
|
|
82
81
|
r as isArrNullOrEmpty,
|
|
83
|
-
|
|
82
|
+
ee as isEmptyObject,
|
|
84
83
|
C as isMobile,
|
|
85
84
|
M as isPromise,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
S as isSafari,
|
|
86
|
+
y as isWindows,
|
|
87
|
+
P as isiOSDevice,
|
|
88
|
+
oe as mergeDeep,
|
|
89
89
|
ae as observeOnce,
|
|
90
90
|
le as onNotificationsPermissionChange,
|
|
91
91
|
z as parseLocaleNumber,
|
|
@@ -97,7 +97,7 @@ export {
|
|
|
97
97
|
xe as replaceAllTokens,
|
|
98
98
|
a as rgba,
|
|
99
99
|
re as shallowCopyObjectTo,
|
|
100
|
-
|
|
100
|
+
T as showElem,
|
|
101
101
|
ge as stringToHyphened,
|
|
102
102
|
be as strip,
|
|
103
103
|
g as subtractDaysFromDate
|
|
@@ -65,42 +65,51 @@ export declare const getOrDefault: <T>(value: T, defaultValue: NonNullable<T>) =
|
|
|
65
65
|
*/
|
|
66
66
|
export declare const areObjectsEqual: (obj1?: object, obj2?: object) => boolean;
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* Deeply merges a patch object into a source object.
|
|
69
69
|
*
|
|
70
|
-
* This
|
|
71
|
-
*
|
|
70
|
+
* This utility is designed for application state updates rather than API
|
|
71
|
+
* payload patching.
|
|
72
72
|
*
|
|
73
|
+
* Merge rules:
|
|
74
|
+
*
|
|
75
|
+
* - `undefined` values remove the corresponding property.
|
|
76
|
+
* - `null` values are preserved and explicitly set the property to `null`.
|
|
73
77
|
* - Objects are merged recursively.
|
|
74
|
-
* - Arrays are replaced
|
|
75
|
-
* - Primitive values
|
|
76
|
-
*
|
|
78
|
+
* - Arrays are replaced entirely.
|
|
79
|
+
* - Primitive values replace the existing value.
|
|
80
|
+
*
|
|
81
|
+
* The function does not mutate the source object or the patch object.
|
|
77
82
|
*
|
|
78
|
-
*
|
|
83
|
+
* @example
|
|
79
84
|
* ```ts
|
|
80
85
|
* const source = {
|
|
81
|
-
*
|
|
82
|
-
*
|
|
86
|
+
* name: "John",
|
|
87
|
+
* address: {
|
|
88
|
+
* city: "Rome",
|
|
89
|
+
* zip: "00100",
|
|
90
|
+
* },
|
|
83
91
|
* };
|
|
84
92
|
*
|
|
85
93
|
* const patch = {
|
|
86
|
-
*
|
|
87
|
-
*
|
|
94
|
+
* name: undefined,
|
|
95
|
+
* address: {
|
|
96
|
+
* city: null,
|
|
97
|
+
* },
|
|
88
98
|
* };
|
|
89
99
|
*
|
|
90
|
-
* const result =
|
|
100
|
+
* const result = mergeDeep(source, patch);
|
|
101
|
+
*
|
|
91
102
|
* // {
|
|
92
|
-
* //
|
|
103
|
+
* // address: {
|
|
104
|
+
* // city: null,
|
|
105
|
+
* // zip: "00100",
|
|
106
|
+
* // },
|
|
93
107
|
* // }
|
|
94
108
|
* ```
|
|
95
109
|
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* @template T - Source object type
|
|
102
|
-
* @param source - The original JSON object to apply the patch to.
|
|
103
|
-
* @param patch - The JSON Merge Patch object describing changes.
|
|
104
|
-
* @returns A new object resulting from applying the patch.
|
|
110
|
+
* @template T The source object type.
|
|
111
|
+
* @param source The original object to merge into.
|
|
112
|
+
* @param patch The partial update object.
|
|
113
|
+
* @returns A new object containing the merged result.
|
|
105
114
|
*/
|
|
106
|
-
export declare const
|
|
115
|
+
export declare const mergeDeep: <T extends object>(source: T, patch: MergePatch<T>) => T;
|
|
@@ -4,7 +4,7 @@ function u(e, t) {
|
|
|
4
4
|
t[r] = e[r];
|
|
5
5
|
}
|
|
6
6
|
const y = (e) => !e || !Object.keys(e).length;
|
|
7
|
-
function
|
|
7
|
+
function O(e) {
|
|
8
8
|
if (!e) return null;
|
|
9
9
|
for (const t in e) {
|
|
10
10
|
const r = e[t];
|
|
@@ -13,13 +13,13 @@ function a(e) {
|
|
|
13
13
|
}
|
|
14
14
|
return { ...e };
|
|
15
15
|
}
|
|
16
|
-
const
|
|
16
|
+
const a = (e) => Object.entries(e).reduce(
|
|
17
17
|
(t, [r, n]) => (t[n] = r, t),
|
|
18
18
|
{}
|
|
19
19
|
), g = (e) => Object.keys(e).reduce(
|
|
20
20
|
(t, r) => (t[r] = r, t),
|
|
21
21
|
{}
|
|
22
|
-
),
|
|
22
|
+
), d = (e) => e ?? null, o = (e, t) => e ?? t, c = (e = {}, t = {}) => {
|
|
23
23
|
if (e === null || t === null || e === void 0 || t === void 0 || typeof e != "object" && typeof t != "object")
|
|
24
24
|
return e === t;
|
|
25
25
|
if (e instanceof Date && t instanceof Date)
|
|
@@ -34,28 +34,26 @@ const O = (e) => Object.entries(e).reduce(
|
|
|
34
34
|
t[s]
|
|
35
35
|
)
|
|
36
36
|
);
|
|
37
|
-
}, l = (e) => e !== null && typeof e == "object" && !Array.isArray(e)
|
|
38
|
-
|
|
39
|
-
if (t === null)
|
|
37
|
+
}, l = (e) => e !== null && typeof e == "object" && !Array.isArray(e), f = (e, t) => {
|
|
38
|
+
if (t === void 0)
|
|
40
39
|
return;
|
|
41
40
|
if (!l(e) || !l(t))
|
|
42
41
|
return t;
|
|
43
42
|
const r = { ...e };
|
|
44
43
|
for (const n of Object.keys(t)) {
|
|
45
|
-
const s = t[n], i = f(
|
|
44
|
+
const s = t[n], i = f(r[n], s);
|
|
46
45
|
i === void 0 ? delete r[n] : r[n] = i;
|
|
47
46
|
}
|
|
48
47
|
return r;
|
|
49
|
-
}
|
|
50
|
-
const k = (e, t) => f(e, t);
|
|
48
|
+
}, p = (e, t) => f(e, t);
|
|
51
49
|
export {
|
|
52
|
-
k as applyMergePatch,
|
|
53
50
|
c as areObjectsEqual,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
O as deepCopy,
|
|
52
|
+
o as getOrDefault,
|
|
53
|
+
d as getOrNull,
|
|
54
|
+
a as invertFlatObject,
|
|
58
55
|
g as invertKeyToValue,
|
|
59
56
|
y as isEmptyObject,
|
|
57
|
+
p as mergeDeep,
|
|
60
58
|
u as shallowCopyObjectTo
|
|
61
59
|
};
|