@wikicasa-dev/utilities 1.1.12 → 1.1.13
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/ObjectUtils.cjs +1 -1
- package/dist/ObjectUtils.js +18 -17
- package/dist/index.cjs +1 -1
- package/dist/index.js +59 -58
- package/dist/utils/ObjectUtils.d.ts +8 -0
- package/package.json +1 -1
package/dist/ObjectUtils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(e,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(e,t){if(e)for(const n in e)t[n]=e[n]}const l=e=>!e||!Object.keys(e).length;function c(e){if(!e)return null;for(const t in e){const n=e[t];if(n&&(Array.isArray(n)||Object.keys(n).length>0))return JSON.parse(JSON.stringify(e))}return{...e}}const s=e=>Object.entries(e).reduce((t,[n,r])=>(t[r]=n,t),{}),u=e=>Object.keys(e).reduce((t,n)=>(t[n]=n,t),{}),O=e=>e??null,o=(e,t)=>e??t;exports.deepCopy=c;exports.getOrDefault=o;exports.getOrNull=O;exports.invertFlatObject=s;exports.invertKeyToValue=u;exports.isEmptyObject=l;exports.shallowCopyObjectTo=i;
|
package/dist/ObjectUtils.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
function i(
|
|
2
|
-
if (
|
|
3
|
-
for (const
|
|
4
|
-
n
|
|
1
|
+
function i(t, e) {
|
|
2
|
+
if (t)
|
|
3
|
+
for (const n in t)
|
|
4
|
+
e[n] = t[n];
|
|
5
5
|
}
|
|
6
|
-
const s = (
|
|
7
|
-
function c(
|
|
8
|
-
if (!
|
|
9
|
-
for (const
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
12
|
-
return JSON.parse(JSON.stringify(
|
|
6
|
+
const s = (t) => !t || !Object.keys(t).length;
|
|
7
|
+
function c(t) {
|
|
8
|
+
if (!t) return null;
|
|
9
|
+
for (const e in t) {
|
|
10
|
+
const n = t[e];
|
|
11
|
+
if (n && (Array.isArray(n) || Object.keys(n).length > 0))
|
|
12
|
+
return JSON.parse(JSON.stringify(t));
|
|
13
13
|
}
|
|
14
|
-
return { ...
|
|
14
|
+
return { ...t };
|
|
15
15
|
}
|
|
16
|
-
const u = (
|
|
17
|
-
(
|
|
16
|
+
const u = (t) => Object.entries(t).reduce(
|
|
17
|
+
(e, [n, r]) => (e[r] = n, e),
|
|
18
18
|
{}
|
|
19
|
-
), l = (
|
|
20
|
-
(
|
|
19
|
+
), l = (t) => Object.keys(t).reduce(
|
|
20
|
+
(e, n) => (e[n] = n, e),
|
|
21
21
|
{}
|
|
22
|
-
), O = (
|
|
22
|
+
), O = (t) => t ?? null, f = (t, e) => t ?? e;
|
|
23
23
|
export {
|
|
24
24
|
c as deepCopy,
|
|
25
|
+
f as getOrDefault,
|
|
25
26
|
O as getOrNull,
|
|
26
27
|
u as invertFlatObject,
|
|
27
28
|
l as invertKeyToValue,
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./ArrayUtils.cjs"),C=require("./ColorUtils.cjs"),a=require("./CookieUtils.cjs"),c=require("./CurrencyUtils.cjs"),n=require("./DateUtils.cjs"),s=require("./DeviceDetectionUtils.cjs"),l=require("./DOMUtils.cjs"),u=require("./EmailUtils.cjs"),E=require("./FunctionUtils.cjs"),m=require("./GenericUtils.cjs"),t=require("./NumberUtils.cjs"),r=require("./ObjectUtils.cjs"),S=require("./ObserverUtils.cjs"),d=require("./PermissionUtils.cjs"),g=require("./RESB_UrlBuilder.cjs"),o=require("./StringUtils.cjs"),y=require("./URLBuilderUtils.cjs"),e=require("./RegexUtils.cjs"),b=require("./GeolocationUtils.cjs"),O=require("./AdressUtils.cjs"),f=require("./GAutocompleteUtils.cjs"),P=require("./DownloadUtils.cjs"),i=require("./MapUtils.cjs");exports.isArrNullOrEmpty=p.isArrNullOrEmpty;exports.rgba=C.rgba;exports.decodeCookie=a.decodeCookie;exports.encodeCookie=a.encodeCookie;exports.getCookie=a.getCookie;exports.removeCookie=a.removeCookie;exports.formatCurrency=c.formatCurrency;exports.formatCurrencyShort=c.formatCurrencyShort;exports.formatDate=n.formatDate;exports.formatDateToddMMYYYY=n.formatDateToddMMYYYY;exports.getStartAndEndOfDayUTC=n.getStartAndEndOfDayUTC;exports.subtractDaysFromDate=n.subtractDaysFromDate;exports.getCurrentDeviceSize=s.getCurrentDeviceSize;exports.isMobile=s.isMobile;exports.isSafari=s.isSafari;exports.isWindows=s.isWindows;exports.isiOSDevice=s.isiOSDevice;exports.emptyElem=l.emptyElem;exports.getSingleElement=l.getSingleElement;exports.hideElem=l.hideElem;exports.showElem=l.showElem;exports.hash256=u.hash256;exports.hashEmail=u.hashEmail;exports.debounce=E.debounce;exports.isPromise=E.isPromise;exports.awaitableSetTimeout=m.awaitableSetTimeout;exports.createCustomEvent=m.createCustomEvent;exports.formatFloat=t.formatFloat;exports.formatInteger=t.formatInteger;exports.formatLocaleNumber=t.formatLocaleNumber;exports.formatLocaleNumberAuto=t.formatLocaleNumberAuto;exports.formatNumber=t.formatNumber;exports.formatterNumberObj=t.formatterNumberObj;exports.parseLocaleNumber=t.parseLocaleNumber;exports.parseLocaleNumberAuto=t.parseLocaleNumberAuto;exports.deepCopy=r.deepCopy;exports.getOrDefault=r.getOrDefault;exports.getOrNull=r.getOrNull;exports.invertFlatObject=r.invertFlatObject;exports.invertKeyToValue=r.invertKeyToValue;exports.isEmptyObject=r.isEmptyObject;exports.shallowCopyObjectTo=r.shallowCopyObjectTo;exports.observeOnce=S.observeOnce;exports.addPermissionStateListener=d.addPermissionStateListener;exports.onNotificationsPermissionChange=d.onNotificationsPermissionChange;exports.buildParams=g.buildParams;exports.buildURL=g.buildURL;exports.capitalizeFirstLetter=o.capitalizeFirstLetter;exports.cleanASCII=o.cleanASCII;exports.decodeTextWithEntities=o.decodeTextWithEntities;exports.replaceAll=o.replaceAll;exports.replaceAllTokens=o.replaceAllTokens;exports.stringToHyphened=o.stringToHyphened;exports.strip=o.strip;exports.appendQueryString=y.appendQueryString;exports.COMPETITOR_REGEX=e.COMPETITOR_REGEX;exports.DATE_REGEX=e.DATE_REGEX;exports.EMAIL_REGEX=e.EMAIL_REGEX;exports.EMAIL_REGEX_INTO_TEXT=e.EMAIL_REGEX_INTO_TEXT;exports.EXCLUDED_REGEX=e.EXCLUDED_REGEX;exports.GLOBAL_PHONE_REGEX=e.GLOBAL_PHONE_REGEX;exports.PASSWORD_REGEX=e.PASSWORD_REGEX;exports.PHONE_REGEX=e.PHONE_REGEX;exports.ROOMS_REGEX=e.ROOMS_REGEX;exports.SQM_REGEX=e.SQM_REGEX;exports.browserSupportGeolocation=b.browserSupportGeolocation;exports.getUserPosition=b.getUserPosition;exports.formatAddress=O.formatAddress;exports.formattedAddress=O.formattedAddress;exports.googlePlaceConverter=f.googlePlaceConverter;exports.downloadFile=P.downloadFile;exports.calcPolygonCenter=i.calcPolygonCenter;exports.encodePolygon=i.encodePolygon;exports.getMinMaxLatLng=i.getMinMaxLatLng;exports.getPolygonString=i.getPolygonString;exports.parsePoints=i.parsePoints;exports.removeDuplicatePoints=i.removeDuplicatePoints;
|
package/dist/index.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
import { isArrNullOrEmpty as r } from "./ArrayUtils.js";
|
|
2
2
|
import { rgba as a } from "./ColorUtils.js";
|
|
3
|
-
import { decodeCookie as i, encodeCookie as
|
|
4
|
-
import { formatCurrency as
|
|
3
|
+
import { decodeCookie as i, encodeCookie as l, getCookie as n, removeCookie as p } from "./CookieUtils.js";
|
|
4
|
+
import { formatCurrency as f, formatCurrencyShort as E } from "./CurrencyUtils.js";
|
|
5
5
|
import { formatDate as d, formatDateToddMMYYYY as x, getStartAndEndOfDayUTC as u, subtractDaysFromDate as g } from "./DateUtils.js";
|
|
6
6
|
import { getCurrentDeviceSize as O, isMobile as C, isSafari as S, isWindows as y, isiOSDevice as P } from "./DeviceDetectionUtils.js";
|
|
7
|
-
import { emptyElem as L, getSingleElement as R, hideElem as T, showElem as
|
|
7
|
+
import { emptyElem as L, getSingleElement as R, hideElem as T, showElem as D } from "./DOMUtils.js";
|
|
8
8
|
import { hash256 as G, hashEmail as N } from "./EmailUtils.js";
|
|
9
9
|
import { debounce as h, isPromise as M } from "./FunctionUtils.js";
|
|
10
10
|
import { awaitableSetTimeout as I, createCustomEvent as w } from "./GenericUtils.js";
|
|
11
11
|
import { formatFloat as F, formatInteger as j, formatLocaleNumber as U, formatLocaleNumberAuto as Y, formatNumber as H, formatterNumberObj as W, parseLocaleNumber as z, parseLocaleNumberAuto as Q } from "./NumberUtils.js";
|
|
12
|
-
import { deepCopy as K,
|
|
13
|
-
import { observeOnce as
|
|
14
|
-
import { addPermissionStateListener as
|
|
15
|
-
import { buildParams as
|
|
16
|
-
import { capitalizeFirstLetter as
|
|
17
|
-
import { appendQueryString as
|
|
18
|
-
import { COMPETITOR_REGEX as
|
|
19
|
-
import { browserSupportGeolocation as
|
|
20
|
-
import { formatAddress as
|
|
21
|
-
import { googlePlaceConverter as
|
|
22
|
-
import { downloadFile as
|
|
23
|
-
import { calcPolygonCenter as
|
|
12
|
+
import { deepCopy as K, getOrDefault as V, getOrNull as q, invertFlatObject as J, invertKeyToValue as Z, isEmptyObject as $, shallowCopyObjectTo as ee } from "./ObjectUtils.js";
|
|
13
|
+
import { observeOnce as re } from "./ObserverUtils.js";
|
|
14
|
+
import { addPermissionStateListener as ae, onNotificationsPermissionChange as me } from "./PermissionUtils.js";
|
|
15
|
+
import { buildParams as le, buildURL as ne } from "./RESB_UrlBuilder.js";
|
|
16
|
+
import { capitalizeFirstLetter as se, cleanASCII as fe, decodeTextWithEntities as Ee, replaceAll as ce, replaceAllTokens as de, stringToHyphened as xe, strip as ue } from "./StringUtils.js";
|
|
17
|
+
import { appendQueryString as be } from "./URLBuilderUtils.js";
|
|
18
|
+
import { COMPETITOR_REGEX as Ce, DATE_REGEX as Se, EMAIL_REGEX as ye, EMAIL_REGEX_INTO_TEXT as Pe, EXCLUDED_REGEX as Ae, GLOBAL_PHONE_REGEX as Le, PASSWORD_REGEX as Re, PHONE_REGEX as Te, ROOMS_REGEX as De, SQM_REGEX as _e } from "./RegexUtils.js";
|
|
19
|
+
import { browserSupportGeolocation as Ne, getUserPosition as Xe } from "./GeolocationUtils.js";
|
|
20
|
+
import { formatAddress as Me, formattedAddress as ve } from "./AdressUtils.js";
|
|
21
|
+
import { googlePlaceConverter as we } from "./GAutocompleteUtils.js";
|
|
22
|
+
import { downloadFile as Fe } from "./DownloadUtils.js";
|
|
23
|
+
import { calcPolygonCenter as Ue, encodePolygon as Ye, getMinMaxLatLng as He, getPolygonString as We, parsePoints as ze, removeDuplicatePoints as Qe } from "./MapUtils.js";
|
|
24
24
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
Ce as COMPETITOR_REGEX,
|
|
26
|
+
Se as DATE_REGEX,
|
|
27
|
+
ye as EMAIL_REGEX,
|
|
28
|
+
Pe as EMAIL_REGEX_INTO_TEXT,
|
|
29
|
+
Ae as EXCLUDED_REGEX,
|
|
30
|
+
Le as GLOBAL_PHONE_REGEX,
|
|
31
|
+
Re as PASSWORD_REGEX,
|
|
32
|
+
Te as PHONE_REGEX,
|
|
33
|
+
De as ROOMS_REGEX,
|
|
34
34
|
_e as SQM_REGEX,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
ae as addPermissionStateListener,
|
|
36
|
+
be as appendQueryString,
|
|
37
37
|
I as awaitableSetTimeout,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
Ne as browserSupportGeolocation,
|
|
39
|
+
le as buildParams,
|
|
40
40
|
ne as buildURL,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
Ue as calcPolygonCenter,
|
|
42
|
+
se as capitalizeFirstLetter,
|
|
43
|
+
fe as cleanASCII,
|
|
44
44
|
w as createCustomEvent,
|
|
45
45
|
h as debounce,
|
|
46
46
|
i as decodeCookie,
|
|
47
47
|
Ee as decodeTextWithEntities,
|
|
48
48
|
K as deepCopy,
|
|
49
|
-
|
|
49
|
+
Fe as downloadFile,
|
|
50
50
|
L as emptyElem,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
l as encodeCookie,
|
|
52
|
+
Ye as encodePolygon,
|
|
53
|
+
Me as formatAddress,
|
|
54
|
+
f as formatCurrency,
|
|
55
|
+
E as formatCurrencyShort,
|
|
56
56
|
d as formatDate,
|
|
57
57
|
x as formatDateToddMMYYYY,
|
|
58
58
|
F as formatFloat,
|
|
@@ -60,42 +60,43 @@ export {
|
|
|
60
60
|
U as formatLocaleNumber,
|
|
61
61
|
Y as formatLocaleNumberAuto,
|
|
62
62
|
H as formatNumber,
|
|
63
|
-
|
|
63
|
+
ve as formattedAddress,
|
|
64
64
|
W as formatterNumberObj,
|
|
65
|
-
|
|
65
|
+
n as getCookie,
|
|
66
66
|
O as getCurrentDeviceSize,
|
|
67
|
-
|
|
68
|
-
V as
|
|
69
|
-
|
|
67
|
+
He as getMinMaxLatLng,
|
|
68
|
+
V as getOrDefault,
|
|
69
|
+
q as getOrNull,
|
|
70
|
+
We as getPolygonString,
|
|
70
71
|
R as getSingleElement,
|
|
71
72
|
u as getStartAndEndOfDayUTC,
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
Xe as getUserPosition,
|
|
74
|
+
we as googlePlaceConverter,
|
|
74
75
|
G as hash256,
|
|
75
76
|
N as hashEmail,
|
|
76
77
|
T as hideElem,
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
J as invertFlatObject,
|
|
79
|
+
Z as invertKeyToValue,
|
|
79
80
|
r as isArrNullOrEmpty,
|
|
80
|
-
|
|
81
|
+
$ as isEmptyObject,
|
|
81
82
|
C as isMobile,
|
|
82
83
|
M as isPromise,
|
|
83
84
|
S as isSafari,
|
|
84
85
|
y as isWindows,
|
|
85
86
|
P as isiOSDevice,
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
re as observeOnce,
|
|
88
|
+
me as onNotificationsPermissionChange,
|
|
88
89
|
z as parseLocaleNumber,
|
|
89
90
|
Q as parseLocaleNumberAuto,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
ze as parsePoints,
|
|
92
|
+
p as removeCookie,
|
|
93
|
+
Qe as removeDuplicatePoints,
|
|
94
|
+
ce as replaceAll,
|
|
95
|
+
de as replaceAllTokens,
|
|
95
96
|
a as rgba,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
ee as shallowCopyObjectTo,
|
|
98
|
+
D as showElem,
|
|
99
|
+
xe as stringToHyphened,
|
|
100
|
+
ue as strip,
|
|
100
101
|
g as subtractDaysFromDate
|
|
101
102
|
};
|
|
@@ -40,3 +40,11 @@ export declare const invertKeyToValue: <T extends Record<PropertyKey, unknown>>(
|
|
|
40
40
|
* @returns The value if it is not null or undefined, otherwise returns null.
|
|
41
41
|
*/
|
|
42
42
|
export declare const getOrNull: <T>(v: T) => NonNullable<T> | null;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the value if it is not null or undefined, otherwise returns the default value.
|
|
45
|
+
* @typeParam T - The type of the value.
|
|
46
|
+
* @param value - The value to check.
|
|
47
|
+
* @param defaultValue - The default value to return if value is null or undefined.
|
|
48
|
+
* @returns The value if it is not null or undefined, otherwise returns the default value.
|
|
49
|
+
*/
|
|
50
|
+
export declare const getOrDefault: <T>(value: T, defaultValue: NonNullable<T>) => NonNullable<T>;
|