@h3ravel/support 0.14.3 → 0.14.4
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.cjs +32 -29
- package/dist/index.d.cts +20 -3
- package/dist/index.d.ts +20 -3
- package/dist/index.js +31 -18
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -461,23 +461,6 @@ const toHumanTime = (seconds = 0, worded = false) => {
|
|
|
461
461
|
|
|
462
462
|
//#endregion
|
|
463
463
|
//#region src/Helpers/Obj.ts
|
|
464
|
-
var Obj_exports = /* @__PURE__ */ __export({
|
|
465
|
-
Obj: () => Obj,
|
|
466
|
-
data_fill: () => data_fill,
|
|
467
|
-
data_forget: () => data_forget,
|
|
468
|
-
data_get: () => data_get,
|
|
469
|
-
data_set: () => data_set,
|
|
470
|
-
dot: () => dot,
|
|
471
|
-
extractProperties: () => extractProperties,
|
|
472
|
-
getValue: () => getValue,
|
|
473
|
-
modObj: () => modObj,
|
|
474
|
-
safeDot: () => safeDot,
|
|
475
|
-
setNested: () => setNested,
|
|
476
|
-
slugifyKeys: () => slugifyKeys,
|
|
477
|
-
toCssClasses: () => toCssClasses,
|
|
478
|
-
toCssStyles: () => toCssStyles,
|
|
479
|
-
undot: () => undot
|
|
480
|
-
});
|
|
481
464
|
/**
|
|
482
465
|
* Flattens a nested object into a single-level object
|
|
483
466
|
* with dot-separated keys.
|
|
@@ -737,6 +720,15 @@ function data_forget(obj, path) {
|
|
|
737
720
|
}
|
|
738
721
|
}
|
|
739
722
|
}
|
|
723
|
+
/**
|
|
724
|
+
* Checks if a value is a plain object (not array, function, etc.)
|
|
725
|
+
*
|
|
726
|
+
* @param value
|
|
727
|
+
* @returns
|
|
728
|
+
*/
|
|
729
|
+
function isPlainObject(value) {
|
|
730
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.prototype.toString.call(value) === "[object Object]";
|
|
731
|
+
}
|
|
740
732
|
var Obj = class Obj {
|
|
741
733
|
/**
|
|
742
734
|
* Check if the value is a non-null object (associative/accessible).
|
|
@@ -757,6 +749,27 @@ var Obj = class Obj {
|
|
|
757
749
|
return obj;
|
|
758
750
|
}
|
|
759
751
|
/**
|
|
752
|
+
* Deeply merges two or more objects.
|
|
753
|
+
* - Arrays are replaced (not concatenated)
|
|
754
|
+
* - Objects are merged recursively
|
|
755
|
+
* - Non-object values overwrite previous ones
|
|
756
|
+
*
|
|
757
|
+
* @param objects
|
|
758
|
+
* @returns
|
|
759
|
+
*/
|
|
760
|
+
static deepMerge(...objects) {
|
|
761
|
+
const result = {};
|
|
762
|
+
for (const obj of objects) {
|
|
763
|
+
if (!obj || typeof obj !== "object") continue;
|
|
764
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
765
|
+
const existing = result[key];
|
|
766
|
+
if (isPlainObject(existing) && isPlainObject(value)) result[key] = Obj.deepMerge(existing, value);
|
|
767
|
+
else result[key] = value;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return result;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
760
773
|
* Split object into [keys, values]
|
|
761
774
|
*/
|
|
762
775
|
static divide(obj) {
|
|
@@ -6202,12 +6215,6 @@ Object.defineProperty(exports, 'Crypto', {
|
|
|
6202
6215
|
}
|
|
6203
6216
|
});
|
|
6204
6217
|
exports.DateTime = DateTime;
|
|
6205
|
-
Object.defineProperty(exports, 'DumpDie', {
|
|
6206
|
-
enumerable: true,
|
|
6207
|
-
get: function () {
|
|
6208
|
-
return DumpDie_exports;
|
|
6209
|
-
}
|
|
6210
|
-
});
|
|
6211
6218
|
exports.HtmlString = HtmlString;
|
|
6212
6219
|
exports.InvalidArgumentException = InvalidArgumentException;
|
|
6213
6220
|
exports.Mode = Mode;
|
|
@@ -6217,12 +6224,7 @@ Object.defineProperty(exports, 'Number', {
|
|
|
6217
6224
|
return Number_exports;
|
|
6218
6225
|
}
|
|
6219
6226
|
});
|
|
6220
|
-
|
|
6221
|
-
enumerable: true,
|
|
6222
|
-
get: function () {
|
|
6223
|
-
return Obj_exports;
|
|
6224
|
-
}
|
|
6225
|
-
});
|
|
6227
|
+
exports.Obj = Obj;
|
|
6226
6228
|
exports.RuntimeException = RuntimeException;
|
|
6227
6229
|
exports.Str = Str;
|
|
6228
6230
|
exports.Stringable = Stringable;
|
|
@@ -6245,6 +6247,7 @@ exports.getValue = getValue;
|
|
|
6245
6247
|
exports.hash = hash;
|
|
6246
6248
|
exports.hmac = hmac;
|
|
6247
6249
|
exports.humanize = humanize;
|
|
6250
|
+
exports.isPlainObject = isPlainObject;
|
|
6248
6251
|
exports.loadHelpers = loadHelpers;
|
|
6249
6252
|
exports.modObj = modObj;
|
|
6250
6253
|
exports.random = random;
|
package/dist/index.d.cts
CHANGED
|
@@ -240,7 +240,7 @@ declare const toBytes: (bytes?: number, decimals?: number, bits?: boolean) => st
|
|
|
240
240
|
*/
|
|
241
241
|
declare const toHumanTime: (seconds?: number, worded?: boolean) => string;
|
|
242
242
|
declare namespace Obj_d_exports {
|
|
243
|
-
export { Obj, data_fill, data_forget, data_get, data_set, dot, extractProperties, getValue, modObj, safeDot, setNested, slugifyKeys, toCssClasses, toCssStyles, undot };
|
|
243
|
+
export { Obj, data_fill, data_forget, data_get, data_set, dot, extractProperties, getValue, isPlainObject, modObj, safeDot, setNested, slugifyKeys, toCssClasses, toCssStyles, undot };
|
|
244
244
|
}
|
|
245
245
|
/**
|
|
246
246
|
* Flattens a nested object into a single-level object
|
|
@@ -369,6 +369,13 @@ declare function data_fill(obj: Record<string, any>, path: string | string[], va
|
|
|
369
369
|
* Remove a key from an object using dot notation.
|
|
370
370
|
*/
|
|
371
371
|
declare function data_forget(obj: Record<string, any>, path: string | string[]): void;
|
|
372
|
+
/**
|
|
373
|
+
* Checks if a value is a plain object (not array, function, etc.)
|
|
374
|
+
*
|
|
375
|
+
* @param value
|
|
376
|
+
* @returns
|
|
377
|
+
*/
|
|
378
|
+
declare function isPlainObject(value: any): value is Record<string, any>;
|
|
372
379
|
declare class Obj {
|
|
373
380
|
/**
|
|
374
381
|
* Check if the value is a non-null object (associative/accessible).
|
|
@@ -380,6 +387,16 @@ declare class Obj {
|
|
|
380
387
|
* Returns a new object (does not mutate original).
|
|
381
388
|
*/
|
|
382
389
|
static add<T extends Record<string, any>, K extends string, V>(obj: T, key: K, value: V): T & Record<K, V>;
|
|
390
|
+
/**
|
|
391
|
+
* Deeply merges two or more objects.
|
|
392
|
+
* - Arrays are replaced (not concatenated)
|
|
393
|
+
* - Objects are merged recursively
|
|
394
|
+
* - Non-object values overwrite previous ones
|
|
395
|
+
*
|
|
396
|
+
* @param objects
|
|
397
|
+
* @returns
|
|
398
|
+
*/
|
|
399
|
+
static deepMerge<T extends Record<string, any>>(...objects: (Partial<T> | undefined | null)[]): T;
|
|
383
400
|
/**
|
|
384
401
|
* Split object into [keys, values]
|
|
385
402
|
*/
|
|
@@ -467,7 +484,7 @@ declare class Arr {
|
|
|
467
484
|
* Arr.divide(['a','b']) -> [[0,1], ['a','b']]
|
|
468
485
|
* Arr.divide({x:1,y:2}) -> [['x','y'], [1,2]]
|
|
469
486
|
*/
|
|
470
|
-
static divide<A>(input: A[] | Record<string, A>): (
|
|
487
|
+
static divide<A>(input: A[] | Record<string, A>): (number[] | A[])[] | (string[] | A[])[];
|
|
471
488
|
/**
|
|
472
489
|
* Flatten a nested array/object structure into a single-level object
|
|
473
490
|
* with dot-notated keys.
|
|
@@ -3195,4 +3212,4 @@ declare function loadHelpers(target?: any): void;
|
|
|
3195
3212
|
*/
|
|
3196
3213
|
declare function cleanHelpers(target?: any): void;
|
|
3197
3214
|
//#endregion
|
|
3198
|
-
export { Arr, Arrayable, Callback, CamelToSnakeCase, Crypto_d_exports as Crypto, DateTime, DotPath,
|
|
3215
|
+
export { Arr, Arrayable, Callback, CamelToSnakeCase, Crypto_d_exports as Crypto, DateTime, DotPath, ExcerptOptions, Fallback, Function, GlobalHelpers, HtmlString, HtmlStringType, InvalidArgumentException, JsonSerializable, Jsonable, KeysToSnakeCase, Mode, Number_d_exports as Number, Obj, RuntimeException, SnakeToCamelCase, SnakeToTitleCase, Str, Stringable, TGeneric, Value, XGeneric, abbreviate, base64Decode, base64Encode, caesarCipher, checksum, cleanHelpers, data_fill, data_forget, data_get, data_set, dd, dot, dump, extractProperties, format, getValue, hash, hmac, humanize, isPlainObject, loadHelpers, modObj, random, randomColor, randomPassword, randomSecure, safeDot, secureToken, setNested, slugifyKeys, str, toBytes, toCssClasses, toCssStyles, toHumanTime, undot, uuid, verifyChecksum, xor };
|
package/dist/index.d.ts
CHANGED
|
@@ -238,7 +238,7 @@ declare const toBytes: (bytes?: number, decimals?: number, bits?: boolean) => st
|
|
|
238
238
|
*/
|
|
239
239
|
declare const toHumanTime: (seconds?: number, worded?: boolean) => string;
|
|
240
240
|
declare namespace Obj_d_exports {
|
|
241
|
-
export { Obj, data_fill, data_forget, data_get, data_set, dot, extractProperties, getValue, modObj, safeDot, setNested, slugifyKeys, toCssClasses, toCssStyles, undot };
|
|
241
|
+
export { Obj, data_fill, data_forget, data_get, data_set, dot, extractProperties, getValue, isPlainObject, modObj, safeDot, setNested, slugifyKeys, toCssClasses, toCssStyles, undot };
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
244
|
* Flattens a nested object into a single-level object
|
|
@@ -367,6 +367,13 @@ declare function data_fill(obj: Record<string, any>, path: string | string[], va
|
|
|
367
367
|
* Remove a key from an object using dot notation.
|
|
368
368
|
*/
|
|
369
369
|
declare function data_forget(obj: Record<string, any>, path: string | string[]): void;
|
|
370
|
+
/**
|
|
371
|
+
* Checks if a value is a plain object (not array, function, etc.)
|
|
372
|
+
*
|
|
373
|
+
* @param value
|
|
374
|
+
* @returns
|
|
375
|
+
*/
|
|
376
|
+
declare function isPlainObject(value: any): value is Record<string, any>;
|
|
370
377
|
declare class Obj {
|
|
371
378
|
/**
|
|
372
379
|
* Check if the value is a non-null object (associative/accessible).
|
|
@@ -378,6 +385,16 @@ declare class Obj {
|
|
|
378
385
|
* Returns a new object (does not mutate original).
|
|
379
386
|
*/
|
|
380
387
|
static add<T extends Record<string, any>, K extends string, V>(obj: T, key: K, value: V): T & Record<K, V>;
|
|
388
|
+
/**
|
|
389
|
+
* Deeply merges two or more objects.
|
|
390
|
+
* - Arrays are replaced (not concatenated)
|
|
391
|
+
* - Objects are merged recursively
|
|
392
|
+
* - Non-object values overwrite previous ones
|
|
393
|
+
*
|
|
394
|
+
* @param objects
|
|
395
|
+
* @returns
|
|
396
|
+
*/
|
|
397
|
+
static deepMerge<T extends Record<string, any>>(...objects: (Partial<T> | undefined | null)[]): T;
|
|
381
398
|
/**
|
|
382
399
|
* Split object into [keys, values]
|
|
383
400
|
*/
|
|
@@ -465,7 +482,7 @@ declare class Arr {
|
|
|
465
482
|
* Arr.divide(['a','b']) -> [[0,1], ['a','b']]
|
|
466
483
|
* Arr.divide({x:1,y:2}) -> [['x','y'], [1,2]]
|
|
467
484
|
*/
|
|
468
|
-
static divide<A>(input: A[] | Record<string, A>): (
|
|
485
|
+
static divide<A>(input: A[] | Record<string, A>): (number[] | A[])[] | (string[] | A[])[];
|
|
469
486
|
/**
|
|
470
487
|
* Flatten a nested array/object structure into a single-level object
|
|
471
488
|
* with dot-notated keys.
|
|
@@ -3193,4 +3210,4 @@ declare function loadHelpers(target?: any): void;
|
|
|
3193
3210
|
*/
|
|
3194
3211
|
declare function cleanHelpers(target?: any): void;
|
|
3195
3212
|
//#endregion
|
|
3196
|
-
export { Arr, Arrayable, Callback, CamelToSnakeCase, Crypto_d_exports as Crypto, DateTime, DotPath,
|
|
3213
|
+
export { Arr, Arrayable, Callback, CamelToSnakeCase, Crypto_d_exports as Crypto, DateTime, DotPath, ExcerptOptions, Fallback, Function, GlobalHelpers, HtmlString, HtmlStringType, InvalidArgumentException, JsonSerializable, Jsonable, KeysToSnakeCase, Mode, Number_d_exports as Number, Obj, RuntimeException, SnakeToCamelCase, SnakeToTitleCase, Str, Stringable, TGeneric, Value, XGeneric, abbreviate, base64Decode, base64Encode, caesarCipher, checksum, cleanHelpers, data_fill, data_forget, data_get, data_set, dd, dot, dump, extractProperties, format, getValue, hash, hmac, humanize, isPlainObject, loadHelpers, modObj, random, randomColor, randomPassword, randomSecure, safeDot, secureToken, setNested, slugifyKeys, str, toBytes, toCssClasses, toCssStyles, toHumanTime, undot, uuid, verifyChecksum, xor };
|
package/dist/index.js
CHANGED
|
@@ -419,23 +419,6 @@ const toHumanTime = (seconds = 0, worded = false) => {
|
|
|
419
419
|
|
|
420
420
|
//#endregion
|
|
421
421
|
//#region src/Helpers/Obj.ts
|
|
422
|
-
var Obj_exports = /* @__PURE__ */ __export({
|
|
423
|
-
Obj: () => Obj,
|
|
424
|
-
data_fill: () => data_fill,
|
|
425
|
-
data_forget: () => data_forget,
|
|
426
|
-
data_get: () => data_get,
|
|
427
|
-
data_set: () => data_set,
|
|
428
|
-
dot: () => dot,
|
|
429
|
-
extractProperties: () => extractProperties,
|
|
430
|
-
getValue: () => getValue,
|
|
431
|
-
modObj: () => modObj,
|
|
432
|
-
safeDot: () => safeDot,
|
|
433
|
-
setNested: () => setNested,
|
|
434
|
-
slugifyKeys: () => slugifyKeys,
|
|
435
|
-
toCssClasses: () => toCssClasses,
|
|
436
|
-
toCssStyles: () => toCssStyles,
|
|
437
|
-
undot: () => undot
|
|
438
|
-
});
|
|
439
422
|
/**
|
|
440
423
|
* Flattens a nested object into a single-level object
|
|
441
424
|
* with dot-separated keys.
|
|
@@ -695,6 +678,15 @@ function data_forget(obj, path) {
|
|
|
695
678
|
}
|
|
696
679
|
}
|
|
697
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* Checks if a value is a plain object (not array, function, etc.)
|
|
683
|
+
*
|
|
684
|
+
* @param value
|
|
685
|
+
* @returns
|
|
686
|
+
*/
|
|
687
|
+
function isPlainObject(value) {
|
|
688
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.prototype.toString.call(value) === "[object Object]";
|
|
689
|
+
}
|
|
698
690
|
var Obj = class Obj {
|
|
699
691
|
/**
|
|
700
692
|
* Check if the value is a non-null object (associative/accessible).
|
|
@@ -715,6 +707,27 @@ var Obj = class Obj {
|
|
|
715
707
|
return obj;
|
|
716
708
|
}
|
|
717
709
|
/**
|
|
710
|
+
* Deeply merges two or more objects.
|
|
711
|
+
* - Arrays are replaced (not concatenated)
|
|
712
|
+
* - Objects are merged recursively
|
|
713
|
+
* - Non-object values overwrite previous ones
|
|
714
|
+
*
|
|
715
|
+
* @param objects
|
|
716
|
+
* @returns
|
|
717
|
+
*/
|
|
718
|
+
static deepMerge(...objects) {
|
|
719
|
+
const result = {};
|
|
720
|
+
for (const obj of objects) {
|
|
721
|
+
if (!obj || typeof obj !== "object") continue;
|
|
722
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
723
|
+
const existing = result[key];
|
|
724
|
+
if (isPlainObject(existing) && isPlainObject(value)) result[key] = Obj.deepMerge(existing, value);
|
|
725
|
+
else result[key] = value;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return result;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
718
731
|
* Split object into [keys, values]
|
|
719
732
|
*/
|
|
720
733
|
static divide(obj) {
|
|
@@ -6152,4 +6165,4 @@ function cleanHelpers(target = globalThis) {
|
|
|
6152
6165
|
}
|
|
6153
6166
|
|
|
6154
6167
|
//#endregion
|
|
6155
|
-
export { Arr, Crypto_exports as Crypto, DateTime,
|
|
6168
|
+
export { Arr, Crypto_exports as Crypto, DateTime, HtmlString, InvalidArgumentException, Mode, Number_exports as Number, Obj, RuntimeException, Str, Stringable, abbreviate, base64Decode, base64Encode, caesarCipher, checksum, cleanHelpers, data_fill, data_forget, data_get, data_set, dd, dot, dump, extractProperties, format, getValue, hash, hmac, humanize, isPlainObject, loadHelpers, modObj, random, randomColor, randomPassword, randomSecure, safeDot, secureToken, setNested, slugifyKeys, str, toBytes, toCssClasses, toCssStyles, toHumanTime, undot, uuid, verifyChecksum, xor };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/support",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"description": "Shared helpers, facades and utilities for H3ravel.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/luxon": "^3.7.1",
|
|
40
40
|
"typescript": "^5.4.0",
|
|
41
|
-
"@h3ravel/shared": "^0.
|
|
41
|
+
"@h3ravel/shared": "^0.25.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"dayjs": "^1.11.18",
|