@wavy/fn 0.0.30 → 0.0.32
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/main.cjs +73 -0
- package/dist/main.d.cts +11 -1
- package/dist/main.d.ts +11 -1
- package/dist/main.js +68 -0
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var main_exports = {};
|
|
22
22
|
__export(main_exports, {
|
|
23
23
|
addArticle: () => addArticle,
|
|
24
|
+
arrayEquals: () => arrayEquals,
|
|
24
25
|
arrayWithConst: () => arrayWithConst,
|
|
25
26
|
asyncRun: () => asyncRun,
|
|
26
27
|
averageOf: () => averageOf,
|
|
@@ -40,11 +41,14 @@ __export(main_exports, {
|
|
|
40
41
|
dropLast: () => dropLast,
|
|
41
42
|
dropLastWhile: () => dropLastWhile,
|
|
42
43
|
dropWhile: () => dropWhile,
|
|
44
|
+
findChanges: () => findChanges,
|
|
45
|
+
findObjectChanges: () => findObjectChanges,
|
|
43
46
|
format: () => format,
|
|
44
47
|
getCaps: () => getCaps,
|
|
45
48
|
getFileExt: () => getFileExt,
|
|
46
49
|
getFilename: () => getFilename,
|
|
47
50
|
getMimeTypes: () => getMimeTypes,
|
|
51
|
+
getObjectValue: () => getObjectValue,
|
|
48
52
|
group: () => group,
|
|
49
53
|
hasIndex: () => hasIndex,
|
|
50
54
|
ifDefined: () => ifDefined,
|
|
@@ -89,6 +93,7 @@ __export(main_exports, {
|
|
|
89
93
|
someValuesEmpty: () => someValuesEmpty,
|
|
90
94
|
sort: () => sort,
|
|
91
95
|
strictArray: () => strictArray,
|
|
96
|
+
strictArrayEquals: () => strictArrayEquals,
|
|
92
97
|
stringToSearch: () => stringToSearch,
|
|
93
98
|
subObjectList: () => subObjectList,
|
|
94
99
|
sumOf: () => sumOf,
|
|
@@ -611,6 +616,47 @@ function isFileDetails(value) {
|
|
|
611
616
|
return false;
|
|
612
617
|
}
|
|
613
618
|
}
|
|
619
|
+
function getObjectValue(obj, path) {
|
|
620
|
+
const pathArr = path.split(".");
|
|
621
|
+
return pathArr.reduce((currentObj, key) => {
|
|
622
|
+
return currentObj?.[key];
|
|
623
|
+
}, obj);
|
|
624
|
+
}
|
|
625
|
+
function findObjectChanges(source, compareTo, options) {
|
|
626
|
+
const changes = [];
|
|
627
|
+
let entries = Object.entries(source);
|
|
628
|
+
for (let idx = 0; idx < entries.length; idx++) {
|
|
629
|
+
const [key, value] = entries[idx];
|
|
630
|
+
const comparedValue = getObjectValue(compareTo, key);
|
|
631
|
+
const checkArrayEquality = options?.strict ? strictArrayEquals : arrayEquals;
|
|
632
|
+
if (Array.isArray(value) && Array.isArray(comparedValue) && !checkArrayEquality(value, comparedValue)) {
|
|
633
|
+
changes.push(key);
|
|
634
|
+
} else if (typeof value === "object" && typeof comparedValue === "object") {
|
|
635
|
+
const newEntries = Object.entries(value).map(([newKey, newValue]) => {
|
|
636
|
+
return [key + "." + newKey, newValue];
|
|
637
|
+
});
|
|
638
|
+
entries.push(...newEntries);
|
|
639
|
+
} else if (JSON.stringify(value) !== JSON.stringify(comparedValue)) {
|
|
640
|
+
changes.push(key);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return changes;
|
|
644
|
+
}
|
|
645
|
+
function findChanges(source, compareTo) {
|
|
646
|
+
if (Array.isArray(source) && Array.isArray(compareTo)) {
|
|
647
|
+
const changes = [];
|
|
648
|
+
for (let idx = 0; idx < source.length; idx++) {
|
|
649
|
+
const _changes = findObjectChanges(source[idx], compareTo[idx]);
|
|
650
|
+
if (_changes.length > 0) {
|
|
651
|
+
changes.push({ keys: _changes, index: idx });
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
return changes;
|
|
655
|
+
} else if (typeof source === "object" && typeof compareTo === "object") {
|
|
656
|
+
return findObjectChanges(source, compareTo);
|
|
657
|
+
}
|
|
658
|
+
return [];
|
|
659
|
+
}
|
|
614
660
|
function isIterable(value) {
|
|
615
661
|
return !!value && typeof value === "object" && Symbol.iterator in value && typeof value[Symbol.iterator] === "function";
|
|
616
662
|
}
|
|
@@ -618,6 +664,28 @@ function isPromise(value) {
|
|
|
618
664
|
if (value instanceof Promise) return true;
|
|
619
665
|
return !!value && (typeof value === "object" || typeof value === "function") && "then" in value && typeof value.then === "function";
|
|
620
666
|
}
|
|
667
|
+
function arrayEquals(...args) {
|
|
668
|
+
if (!args) return false;
|
|
669
|
+
if (args.length === 0) return false;
|
|
670
|
+
if (args.length === 1) return true;
|
|
671
|
+
return args.every((array, i) => {
|
|
672
|
+
const compareTo = args[i - 1] ?? args[i + 1];
|
|
673
|
+
const fmtCompareTo = compareTo.map(
|
|
674
|
+
(item) => JSON.stringify(item).toLowerCase()
|
|
675
|
+
);
|
|
676
|
+
return array.length === compareTo.length && array.every((item) => {
|
|
677
|
+
return fmtCompareTo.includes(JSON.stringify(item).toLowerCase());
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
function strictArrayEquals(...args) {
|
|
682
|
+
if (!args) return false;
|
|
683
|
+
if (args.length === 0) return false;
|
|
684
|
+
if (args.length === 1) return true;
|
|
685
|
+
return args.every(
|
|
686
|
+
(array, i) => JSON.stringify(args[i - 1] ?? args[i + 1]) === JSON.stringify(array)
|
|
687
|
+
);
|
|
688
|
+
}
|
|
621
689
|
var parseDate = dateFormat;
|
|
622
690
|
function parseName(value) {
|
|
623
691
|
if (typeof value === "string") {
|
|
@@ -1028,6 +1096,7 @@ function arrayWithConst(array) {
|
|
|
1028
1096
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1029
1097
|
0 && (module.exports = {
|
|
1030
1098
|
addArticle,
|
|
1099
|
+
arrayEquals,
|
|
1031
1100
|
arrayWithConst,
|
|
1032
1101
|
asyncRun,
|
|
1033
1102
|
averageOf,
|
|
@@ -1047,11 +1116,14 @@ function arrayWithConst(array) {
|
|
|
1047
1116
|
dropLast,
|
|
1048
1117
|
dropLastWhile,
|
|
1049
1118
|
dropWhile,
|
|
1119
|
+
findChanges,
|
|
1120
|
+
findObjectChanges,
|
|
1050
1121
|
format,
|
|
1051
1122
|
getCaps,
|
|
1052
1123
|
getFileExt,
|
|
1053
1124
|
getFilename,
|
|
1054
1125
|
getMimeTypes,
|
|
1126
|
+
getObjectValue,
|
|
1055
1127
|
group,
|
|
1056
1128
|
hasIndex,
|
|
1057
1129
|
ifDefined,
|
|
@@ -1096,6 +1168,7 @@ function arrayWithConst(array) {
|
|
|
1096
1168
|
someValuesEmpty,
|
|
1097
1169
|
sort,
|
|
1098
1170
|
strictArray,
|
|
1171
|
+
strictArrayEquals,
|
|
1099
1172
|
stringToSearch,
|
|
1100
1173
|
subObjectList,
|
|
1101
1174
|
sumOf,
|
package/dist/main.d.cts
CHANGED
|
@@ -84,8 +84,18 @@ declare const toMoney: (value: string | number, options?: NumberFormatterTypes["
|
|
|
84
84
|
declare function format<Event extends "date" | "money" | "name" | "address" | "file-size">(event: Event, ...args: Event extends "date" ? Parameters<typeof dateFormat> : Event extends "money" ? Parameters<typeof toMoney> : Event extends "name" ? Parameters<typeof nameToString> : Event extends "address" ? Parameters<typeof addressToString> : Event extends "file-size" ? [bytes: number] : never): Event extends "date" | "money" | "name" | "address" | "file-size" ? string : never;
|
|
85
85
|
declare function isFile(value: unknown): value is File;
|
|
86
86
|
declare function isFileDetails(value: unknown): value is FileDetails;
|
|
87
|
+
declare function getObjectValue(obj: object, path: string): object;
|
|
88
|
+
declare function findObjectChanges<T extends object>(source: T, compareTo: T, options?: Partial<{
|
|
89
|
+
strict: boolean;
|
|
90
|
+
}>): string[];
|
|
91
|
+
declare function findChanges<T extends object | object[]>(source: T, compareTo: T): T extends object[] ? {
|
|
92
|
+
keys: string[];
|
|
93
|
+
index: number;
|
|
94
|
+
}[] : T extends object ? string[] : never;
|
|
87
95
|
declare function isIterable<T>(value: unknown): value is Iterable<T>;
|
|
88
96
|
declare function isPromise<T>(value: unknown): value is Promise<T>;
|
|
97
|
+
declare function arrayEquals(...args: any[][]): boolean;
|
|
98
|
+
declare function strictArrayEquals(...args: any[][]): boolean;
|
|
89
99
|
declare const parseDate: (time: number | Date | "now", format?: DateFormat) => string;
|
|
90
100
|
declare function parseName<Value extends string | Name>(value: Value): Value extends string ? Name : Value extends Name ? string : never;
|
|
91
101
|
declare function parseMoney(value: string | number, options?: Parameters<typeof NumberFormatter.toMoney>[1]): string;
|
|
@@ -217,4 +227,4 @@ declare function arrayWithConst<T>(array: T[]): {
|
|
|
217
227
|
asConst: readonly T[];
|
|
218
228
|
};
|
|
219
229
|
|
|
220
|
-
export { addArticle, arrayWithConst, asyncRun, averageOf, blankSpaces, buildArray, camelCaseToLetter, castArray, castReturn, classNameExt, classNameResolver, coerceIn, copyToClipboard, count, dataSearcher, distinct, drop, dropLast, dropLastWhile, dropWhile, format, getCaps, getFileExt, getFilename, getMimeTypes, group, hasIndex, ifDefined, ifEmpty, inRange, indexOf, indices, inferFilename, insertAt, isEmpty, isFile, isFileDetails, isIterable, isLetter, isNumber, isPromise, lastIndex, limit, map, mapToArray, maxOf, minOf, negate, omit, omitNils, ordinalIndicator, overwrite, parseAddress, parseDate, parseFileSize, parseMoney, parseName, pick, pluralize, poll, random, range, readClipboardText, removeAll, repeat, run, someValuesEmpty, sort, strictArray, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, toObject, trimString, undefinedIfEmpty, upperFirst, windowed };
|
|
230
|
+
export { addArticle, arrayEquals, arrayWithConst, asyncRun, averageOf, blankSpaces, buildArray, camelCaseToLetter, castArray, castReturn, classNameExt, classNameResolver, coerceIn, copyToClipboard, count, dataSearcher, distinct, drop, dropLast, dropLastWhile, dropWhile, findChanges, findObjectChanges, format, getCaps, getFileExt, getFilename, getMimeTypes, getObjectValue, group, hasIndex, ifDefined, ifEmpty, inRange, indexOf, indices, inferFilename, insertAt, isEmpty, isFile, isFileDetails, isIterable, isLetter, isNumber, isPromise, lastIndex, limit, map, mapToArray, maxOf, minOf, negate, omit, omitNils, ordinalIndicator, overwrite, parseAddress, parseDate, parseFileSize, parseMoney, parseName, pick, pluralize, poll, random, range, readClipboardText, removeAll, repeat, run, someValuesEmpty, sort, strictArray, strictArrayEquals, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, toObject, trimString, undefinedIfEmpty, upperFirst, windowed };
|
package/dist/main.d.ts
CHANGED
|
@@ -84,8 +84,18 @@ declare const toMoney: (value: string | number, options?: NumberFormatterTypes["
|
|
|
84
84
|
declare function format<Event extends "date" | "money" | "name" | "address" | "file-size">(event: Event, ...args: Event extends "date" ? Parameters<typeof dateFormat> : Event extends "money" ? Parameters<typeof toMoney> : Event extends "name" ? Parameters<typeof nameToString> : Event extends "address" ? Parameters<typeof addressToString> : Event extends "file-size" ? [bytes: number] : never): Event extends "date" | "money" | "name" | "address" | "file-size" ? string : never;
|
|
85
85
|
declare function isFile(value: unknown): value is File;
|
|
86
86
|
declare function isFileDetails(value: unknown): value is FileDetails;
|
|
87
|
+
declare function getObjectValue(obj: object, path: string): object;
|
|
88
|
+
declare function findObjectChanges<T extends object>(source: T, compareTo: T, options?: Partial<{
|
|
89
|
+
strict: boolean;
|
|
90
|
+
}>): string[];
|
|
91
|
+
declare function findChanges<T extends object | object[]>(source: T, compareTo: T): T extends object[] ? {
|
|
92
|
+
keys: string[];
|
|
93
|
+
index: number;
|
|
94
|
+
}[] : T extends object ? string[] : never;
|
|
87
95
|
declare function isIterable<T>(value: unknown): value is Iterable<T>;
|
|
88
96
|
declare function isPromise<T>(value: unknown): value is Promise<T>;
|
|
97
|
+
declare function arrayEquals(...args: any[][]): boolean;
|
|
98
|
+
declare function strictArrayEquals(...args: any[][]): boolean;
|
|
89
99
|
declare const parseDate: (time: number | Date | "now", format?: DateFormat) => string;
|
|
90
100
|
declare function parseName<Value extends string | Name>(value: Value): Value extends string ? Name : Value extends Name ? string : never;
|
|
91
101
|
declare function parseMoney(value: string | number, options?: Parameters<typeof NumberFormatter.toMoney>[1]): string;
|
|
@@ -217,4 +227,4 @@ declare function arrayWithConst<T>(array: T[]): {
|
|
|
217
227
|
asConst: readonly T[];
|
|
218
228
|
};
|
|
219
229
|
|
|
220
|
-
export { addArticle, arrayWithConst, asyncRun, averageOf, blankSpaces, buildArray, camelCaseToLetter, castArray, castReturn, classNameExt, classNameResolver, coerceIn, copyToClipboard, count, dataSearcher, distinct, drop, dropLast, dropLastWhile, dropWhile, format, getCaps, getFileExt, getFilename, getMimeTypes, group, hasIndex, ifDefined, ifEmpty, inRange, indexOf, indices, inferFilename, insertAt, isEmpty, isFile, isFileDetails, isIterable, isLetter, isNumber, isPromise, lastIndex, limit, map, mapToArray, maxOf, minOf, negate, omit, omitNils, ordinalIndicator, overwrite, parseAddress, parseDate, parseFileSize, parseMoney, parseName, pick, pluralize, poll, random, range, readClipboardText, removeAll, repeat, run, someValuesEmpty, sort, strictArray, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, toObject, trimString, undefinedIfEmpty, upperFirst, windowed };
|
|
230
|
+
export { addArticle, arrayEquals, arrayWithConst, asyncRun, averageOf, blankSpaces, buildArray, camelCaseToLetter, castArray, castReturn, classNameExt, classNameResolver, coerceIn, copyToClipboard, count, dataSearcher, distinct, drop, dropLast, dropLastWhile, dropWhile, findChanges, findObjectChanges, format, getCaps, getFileExt, getFilename, getMimeTypes, getObjectValue, group, hasIndex, ifDefined, ifEmpty, inRange, indexOf, indices, inferFilename, insertAt, isEmpty, isFile, isFileDetails, isIterable, isLetter, isNumber, isPromise, lastIndex, limit, map, mapToArray, maxOf, minOf, negate, omit, omitNils, ordinalIndicator, overwrite, parseAddress, parseDate, parseFileSize, parseMoney, parseName, pick, pluralize, poll, random, range, readClipboardText, removeAll, repeat, run, someValuesEmpty, sort, strictArray, strictArrayEquals, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, toObject, trimString, undefinedIfEmpty, upperFirst, windowed };
|
package/dist/main.js
CHANGED
|
@@ -506,6 +506,47 @@ function isFileDetails(value) {
|
|
|
506
506
|
return false;
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
|
+
function getObjectValue(obj, path) {
|
|
510
|
+
const pathArr = path.split(".");
|
|
511
|
+
return pathArr.reduce((currentObj, key) => {
|
|
512
|
+
return currentObj?.[key];
|
|
513
|
+
}, obj);
|
|
514
|
+
}
|
|
515
|
+
function findObjectChanges(source, compareTo, options) {
|
|
516
|
+
const changes = [];
|
|
517
|
+
let entries = Object.entries(source);
|
|
518
|
+
for (let idx = 0; idx < entries.length; idx++) {
|
|
519
|
+
const [key, value] = entries[idx];
|
|
520
|
+
const comparedValue = getObjectValue(compareTo, key);
|
|
521
|
+
const checkArrayEquality = options?.strict ? strictArrayEquals : arrayEquals;
|
|
522
|
+
if (Array.isArray(value) && Array.isArray(comparedValue) && !checkArrayEquality(value, comparedValue)) {
|
|
523
|
+
changes.push(key);
|
|
524
|
+
} else if (typeof value === "object" && typeof comparedValue === "object") {
|
|
525
|
+
const newEntries = Object.entries(value).map(([newKey, newValue]) => {
|
|
526
|
+
return [key + "." + newKey, newValue];
|
|
527
|
+
});
|
|
528
|
+
entries.push(...newEntries);
|
|
529
|
+
} else if (JSON.stringify(value) !== JSON.stringify(comparedValue)) {
|
|
530
|
+
changes.push(key);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return changes;
|
|
534
|
+
}
|
|
535
|
+
function findChanges(source, compareTo) {
|
|
536
|
+
if (Array.isArray(source) && Array.isArray(compareTo)) {
|
|
537
|
+
const changes = [];
|
|
538
|
+
for (let idx = 0; idx < source.length; idx++) {
|
|
539
|
+
const _changes = findObjectChanges(source[idx], compareTo[idx]);
|
|
540
|
+
if (_changes.length > 0) {
|
|
541
|
+
changes.push({ keys: _changes, index: idx });
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return changes;
|
|
545
|
+
} else if (typeof source === "object" && typeof compareTo === "object") {
|
|
546
|
+
return findObjectChanges(source, compareTo);
|
|
547
|
+
}
|
|
548
|
+
return [];
|
|
549
|
+
}
|
|
509
550
|
function isIterable(value) {
|
|
510
551
|
return !!value && typeof value === "object" && Symbol.iterator in value && typeof value[Symbol.iterator] === "function";
|
|
511
552
|
}
|
|
@@ -513,6 +554,28 @@ function isPromise(value) {
|
|
|
513
554
|
if (value instanceof Promise) return true;
|
|
514
555
|
return !!value && (typeof value === "object" || typeof value === "function") && "then" in value && typeof value.then === "function";
|
|
515
556
|
}
|
|
557
|
+
function arrayEquals(...args) {
|
|
558
|
+
if (!args) return false;
|
|
559
|
+
if (args.length === 0) return false;
|
|
560
|
+
if (args.length === 1) return true;
|
|
561
|
+
return args.every((array, i) => {
|
|
562
|
+
const compareTo = args[i - 1] ?? args[i + 1];
|
|
563
|
+
const fmtCompareTo = compareTo.map(
|
|
564
|
+
(item) => JSON.stringify(item).toLowerCase()
|
|
565
|
+
);
|
|
566
|
+
return array.length === compareTo.length && array.every((item) => {
|
|
567
|
+
return fmtCompareTo.includes(JSON.stringify(item).toLowerCase());
|
|
568
|
+
});
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
function strictArrayEquals(...args) {
|
|
572
|
+
if (!args) return false;
|
|
573
|
+
if (args.length === 0) return false;
|
|
574
|
+
if (args.length === 1) return true;
|
|
575
|
+
return args.every(
|
|
576
|
+
(array, i) => JSON.stringify(args[i - 1] ?? args[i + 1]) === JSON.stringify(array)
|
|
577
|
+
);
|
|
578
|
+
}
|
|
516
579
|
var parseDate = dateFormat;
|
|
517
580
|
function parseName(value) {
|
|
518
581
|
if (typeof value === "string") {
|
|
@@ -922,6 +985,7 @@ function arrayWithConst(array) {
|
|
|
922
985
|
}
|
|
923
986
|
export {
|
|
924
987
|
addArticle,
|
|
988
|
+
arrayEquals,
|
|
925
989
|
arrayWithConst,
|
|
926
990
|
asyncRun,
|
|
927
991
|
averageOf,
|
|
@@ -941,11 +1005,14 @@ export {
|
|
|
941
1005
|
dropLast,
|
|
942
1006
|
dropLastWhile,
|
|
943
1007
|
dropWhile,
|
|
1008
|
+
findChanges,
|
|
1009
|
+
findObjectChanges,
|
|
944
1010
|
format,
|
|
945
1011
|
getCaps,
|
|
946
1012
|
getFileExt,
|
|
947
1013
|
getFilename,
|
|
948
1014
|
getMimeTypes,
|
|
1015
|
+
getObjectValue,
|
|
949
1016
|
group,
|
|
950
1017
|
hasIndex,
|
|
951
1018
|
ifDefined,
|
|
@@ -990,6 +1057,7 @@ export {
|
|
|
990
1057
|
someValuesEmpty,
|
|
991
1058
|
sort,
|
|
992
1059
|
strictArray,
|
|
1060
|
+
strictArrayEquals,
|
|
993
1061
|
stringToSearch,
|
|
994
1062
|
subObjectList,
|
|
995
1063
|
sumOf,
|