@wavy/fn 0.0.35 → 0.0.37
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 +19 -8
- package/dist/main.d.cts +4 -3
- package/dist/main.d.ts +4 -3
- package/dist/main.js +17 -7
- package/package.json +2 -2
package/dist/main.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/main.ts
|
|
21
21
|
var main_exports = {};
|
|
22
22
|
__export(main_exports, {
|
|
23
|
+
TODO: () => TODO,
|
|
23
24
|
addArticle: () => addArticle,
|
|
24
25
|
arrayEquals: () => arrayEquals,
|
|
25
26
|
arrayWithConst: () => arrayWithConst,
|
|
@@ -48,7 +49,6 @@ __export(main_exports, {
|
|
|
48
49
|
getFileExt: () => getFileExt,
|
|
49
50
|
getFilename: () => getFilename,
|
|
50
51
|
getMimeTypes: () => getMimeTypes,
|
|
51
|
-
getObjectValue: () => getObjectValue,
|
|
52
52
|
group: () => group,
|
|
53
53
|
hasIndex: () => hasIndex,
|
|
54
54
|
ifDefined: () => ifDefined,
|
|
@@ -104,6 +104,7 @@ __export(main_exports, {
|
|
|
104
104
|
timeDuration: () => timeDuration,
|
|
105
105
|
toNumber: () => toNumber,
|
|
106
106
|
toObject: () => ObjectConverter_default,
|
|
107
|
+
traverse: () => traverse,
|
|
107
108
|
trimString: () => trimString,
|
|
108
109
|
undefinedIfEmpty: () => undefinedIfEmpty,
|
|
109
110
|
upperFirst: () => upperFirst,
|
|
@@ -595,6 +596,9 @@ function format(event, ...args) {
|
|
|
595
596
|
return event;
|
|
596
597
|
}
|
|
597
598
|
}
|
|
599
|
+
function TODO(message) {
|
|
600
|
+
throw new Error(`Todo: ${message}`);
|
|
601
|
+
}
|
|
598
602
|
function isFile(value) {
|
|
599
603
|
const requiredKeys = [
|
|
600
604
|
"name",
|
|
@@ -616,25 +620,30 @@ function isFileDetails(value) {
|
|
|
616
620
|
return false;
|
|
617
621
|
}
|
|
618
622
|
}
|
|
619
|
-
function
|
|
623
|
+
function traverse(obj, path) {
|
|
620
624
|
const pathArr = path.split(".");
|
|
621
625
|
return pathArr.reduce((currentObj, key) => {
|
|
622
626
|
return currentObj?.[key];
|
|
623
627
|
}, obj);
|
|
624
628
|
}
|
|
625
629
|
function findObjectChanges(source, compareTo, options) {
|
|
626
|
-
const changes = [];
|
|
627
630
|
let entries = Object.entries(source);
|
|
631
|
+
const changes = Object.keys(compareTo).filter(
|
|
632
|
+
(key) => !entries.some(([sourceKey]) => sourceKey === key)
|
|
633
|
+
);
|
|
628
634
|
for (let idx = 0; idx < entries.length; idx++) {
|
|
629
635
|
const [key, value] = entries[idx];
|
|
630
|
-
const comparedValue =
|
|
636
|
+
const comparedValue = traverse(compareTo, key);
|
|
631
637
|
const checkArrayEquality = options?.strict ? strictArrayEquals : arrayEquals;
|
|
632
638
|
if (Array.isArray(value) && Array.isArray(comparedValue) && !checkArrayEquality(value, comparedValue)) {
|
|
633
639
|
changes.push(key);
|
|
634
640
|
} else if (!!value && !!comparedValue && typeof value === "object" && typeof comparedValue === "object") {
|
|
635
|
-
const newEntries = Object.entries(value).map(
|
|
636
|
-
|
|
637
|
-
|
|
641
|
+
const newEntries = Object.entries(value).map(
|
|
642
|
+
([nestedKey, nestedValue]) => {
|
|
643
|
+
const path = [key, nestedKey].join(".");
|
|
644
|
+
return [path, nestedValue];
|
|
645
|
+
}
|
|
646
|
+
);
|
|
638
647
|
entries.push(...newEntries);
|
|
639
648
|
} else if (JSON.stringify(value) !== JSON.stringify(comparedValue)) {
|
|
640
649
|
changes.push(key);
|
|
@@ -770,6 +779,7 @@ function omit(value, keys) {
|
|
|
770
779
|
function omitNils(value) {
|
|
771
780
|
const result = {};
|
|
772
781
|
if (!value) return value;
|
|
782
|
+
if (Array.isArray(value)) return value.filter((d) => !!d);
|
|
773
783
|
for (const key of Object.keys(value)) {
|
|
774
784
|
const validKey = key;
|
|
775
785
|
const prop = value[validKey];
|
|
@@ -1095,6 +1105,7 @@ function arrayWithConst(array) {
|
|
|
1095
1105
|
}
|
|
1096
1106
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1097
1107
|
0 && (module.exports = {
|
|
1108
|
+
TODO,
|
|
1098
1109
|
addArticle,
|
|
1099
1110
|
arrayEquals,
|
|
1100
1111
|
arrayWithConst,
|
|
@@ -1123,7 +1134,6 @@ function arrayWithConst(array) {
|
|
|
1123
1134
|
getFileExt,
|
|
1124
1135
|
getFilename,
|
|
1125
1136
|
getMimeTypes,
|
|
1126
|
-
getObjectValue,
|
|
1127
1137
|
group,
|
|
1128
1138
|
hasIndex,
|
|
1129
1139
|
ifDefined,
|
|
@@ -1179,6 +1189,7 @@ function arrayWithConst(array) {
|
|
|
1179
1189
|
timeDuration,
|
|
1180
1190
|
toNumber,
|
|
1181
1191
|
toObject,
|
|
1192
|
+
traverse,
|
|
1182
1193
|
trimString,
|
|
1183
1194
|
undefinedIfEmpty,
|
|
1184
1195
|
upperFirst,
|
package/dist/main.d.cts
CHANGED
|
@@ -82,9 +82,10 @@ declare const toMoney: (value: string | number, options?: NumberFormatterTypes["
|
|
|
82
82
|
* @example parseDate, parseMoney, parseName, parseAddress, parseFileSize
|
|
83
83
|
*/
|
|
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
|
+
declare function TODO(message: string): void;
|
|
85
86
|
declare function isFile(value: unknown): value is File;
|
|
86
87
|
declare function isFileDetails(value: unknown): value is FileDetails;
|
|
87
|
-
declare function
|
|
88
|
+
declare function traverse(obj: object, path: string): object;
|
|
88
89
|
declare function findObjectChanges<T extends object>(source: T, compareTo: T, options?: Partial<{
|
|
89
90
|
strict: boolean;
|
|
90
91
|
}>): string[];
|
|
@@ -117,7 +118,7 @@ declare function castArray<T>(value: T | T[]): T[];
|
|
|
117
118
|
declare function castReturn<T extends NonFunction<any>>(value: T | (() => T)): T;
|
|
118
119
|
declare function pick<O extends object, K extends keyof O = keyof O>(value: O, keys: K[]): { [Key in K]: O[Key] | null; };
|
|
119
120
|
declare function omit<O extends object, K extends keyof O = keyof O>(value: O, keys: K[]): { [Key in Exclude<keyof O, K>]: O[Key] | null; };
|
|
120
|
-
declare function omitNils<
|
|
121
|
+
declare function omitNils<T extends object | any[]>(value: T): any[] | T;
|
|
121
122
|
declare function map<T>(arr: T[], callback: (value: T, index: number, array: T[], end: () => void) => T): T[];
|
|
122
123
|
declare function getMimeTypes(typeAliases: KnownFileAlias[]): string[];
|
|
123
124
|
declare function classNameResolver(baseClassName: string): (className: string) => string;
|
|
@@ -227,4 +228,4 @@ declare function arrayWithConst<T>(array: T[]): {
|
|
|
227
228
|
asConst: readonly T[];
|
|
228
229
|
};
|
|
229
230
|
|
|
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,
|
|
231
|
+
export { TODO, 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, 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, traverse, trimString, undefinedIfEmpty, upperFirst, windowed };
|
package/dist/main.d.ts
CHANGED
|
@@ -82,9 +82,10 @@ declare const toMoney: (value: string | number, options?: NumberFormatterTypes["
|
|
|
82
82
|
* @example parseDate, parseMoney, parseName, parseAddress, parseFileSize
|
|
83
83
|
*/
|
|
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
|
+
declare function TODO(message: string): void;
|
|
85
86
|
declare function isFile(value: unknown): value is File;
|
|
86
87
|
declare function isFileDetails(value: unknown): value is FileDetails;
|
|
87
|
-
declare function
|
|
88
|
+
declare function traverse(obj: object, path: string): object;
|
|
88
89
|
declare function findObjectChanges<T extends object>(source: T, compareTo: T, options?: Partial<{
|
|
89
90
|
strict: boolean;
|
|
90
91
|
}>): string[];
|
|
@@ -117,7 +118,7 @@ declare function castArray<T>(value: T | T[]): T[];
|
|
|
117
118
|
declare function castReturn<T extends NonFunction<any>>(value: T | (() => T)): T;
|
|
118
119
|
declare function pick<O extends object, K extends keyof O = keyof O>(value: O, keys: K[]): { [Key in K]: O[Key] | null; };
|
|
119
120
|
declare function omit<O extends object, K extends keyof O = keyof O>(value: O, keys: K[]): { [Key in Exclude<keyof O, K>]: O[Key] | null; };
|
|
120
|
-
declare function omitNils<
|
|
121
|
+
declare function omitNils<T extends object | any[]>(value: T): any[] | T;
|
|
121
122
|
declare function map<T>(arr: T[], callback: (value: T, index: number, array: T[], end: () => void) => T): T[];
|
|
122
123
|
declare function getMimeTypes(typeAliases: KnownFileAlias[]): string[];
|
|
123
124
|
declare function classNameResolver(baseClassName: string): (className: string) => string;
|
|
@@ -227,4 +228,4 @@ declare function arrayWithConst<T>(array: T[]): {
|
|
|
227
228
|
asConst: readonly T[];
|
|
228
229
|
};
|
|
229
230
|
|
|
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,
|
|
231
|
+
export { TODO, 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, 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, traverse, trimString, undefinedIfEmpty, upperFirst, windowed };
|
package/dist/main.js
CHANGED
|
@@ -485,6 +485,9 @@ function format(event, ...args) {
|
|
|
485
485
|
return event;
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
+
function TODO(message) {
|
|
489
|
+
throw new Error(`Todo: ${message}`);
|
|
490
|
+
}
|
|
488
491
|
function isFile(value) {
|
|
489
492
|
const requiredKeys = [
|
|
490
493
|
"name",
|
|
@@ -506,25 +509,30 @@ function isFileDetails(value) {
|
|
|
506
509
|
return false;
|
|
507
510
|
}
|
|
508
511
|
}
|
|
509
|
-
function
|
|
512
|
+
function traverse(obj, path) {
|
|
510
513
|
const pathArr = path.split(".");
|
|
511
514
|
return pathArr.reduce((currentObj, key) => {
|
|
512
515
|
return currentObj?.[key];
|
|
513
516
|
}, obj);
|
|
514
517
|
}
|
|
515
518
|
function findObjectChanges(source, compareTo, options) {
|
|
516
|
-
const changes = [];
|
|
517
519
|
let entries = Object.entries(source);
|
|
520
|
+
const changes = Object.keys(compareTo).filter(
|
|
521
|
+
(key) => !entries.some(([sourceKey]) => sourceKey === key)
|
|
522
|
+
);
|
|
518
523
|
for (let idx = 0; idx < entries.length; idx++) {
|
|
519
524
|
const [key, value] = entries[idx];
|
|
520
|
-
const comparedValue =
|
|
525
|
+
const comparedValue = traverse(compareTo, key);
|
|
521
526
|
const checkArrayEquality = options?.strict ? strictArrayEquals : arrayEquals;
|
|
522
527
|
if (Array.isArray(value) && Array.isArray(comparedValue) && !checkArrayEquality(value, comparedValue)) {
|
|
523
528
|
changes.push(key);
|
|
524
529
|
} else if (!!value && !!comparedValue && typeof value === "object" && typeof comparedValue === "object") {
|
|
525
|
-
const newEntries = Object.entries(value).map(
|
|
526
|
-
|
|
527
|
-
|
|
530
|
+
const newEntries = Object.entries(value).map(
|
|
531
|
+
([nestedKey, nestedValue]) => {
|
|
532
|
+
const path = [key, nestedKey].join(".");
|
|
533
|
+
return [path, nestedValue];
|
|
534
|
+
}
|
|
535
|
+
);
|
|
528
536
|
entries.push(...newEntries);
|
|
529
537
|
} else if (JSON.stringify(value) !== JSON.stringify(comparedValue)) {
|
|
530
538
|
changes.push(key);
|
|
@@ -660,6 +668,7 @@ function omit(value, keys) {
|
|
|
660
668
|
function omitNils(value) {
|
|
661
669
|
const result = {};
|
|
662
670
|
if (!value) return value;
|
|
671
|
+
if (Array.isArray(value)) return value.filter((d) => !!d);
|
|
663
672
|
for (const key of Object.keys(value)) {
|
|
664
673
|
const validKey = key;
|
|
665
674
|
const prop = value[validKey];
|
|
@@ -984,6 +993,7 @@ function arrayWithConst(array) {
|
|
|
984
993
|
return { value: array, asConst: [...array] };
|
|
985
994
|
}
|
|
986
995
|
export {
|
|
996
|
+
TODO,
|
|
987
997
|
addArticle,
|
|
988
998
|
arrayEquals,
|
|
989
999
|
arrayWithConst,
|
|
@@ -1012,7 +1022,6 @@ export {
|
|
|
1012
1022
|
getFileExt,
|
|
1013
1023
|
getFilename,
|
|
1014
1024
|
getMimeTypes,
|
|
1015
|
-
getObjectValue,
|
|
1016
1025
|
group,
|
|
1017
1026
|
hasIndex,
|
|
1018
1027
|
ifDefined,
|
|
@@ -1068,6 +1077,7 @@ export {
|
|
|
1068
1077
|
timeDuration,
|
|
1069
1078
|
toNumber,
|
|
1070
1079
|
ObjectConverter_default as toObject,
|
|
1080
|
+
traverse,
|
|
1071
1081
|
trimString,
|
|
1072
1082
|
undefinedIfEmpty,
|
|
1073
1083
|
upperFirst,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wavy/fn",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"main": "./dist/main.js",
|
|
5
5
|
"module": "./dist/main.cjs",
|
|
6
6
|
"types": "./dist/main.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"zod": "^4.2.1"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@wavy/util": "^0.0.
|
|
36
|
+
"@wavy/util": "^0.0.9",
|
|
37
37
|
"uuid": "^13.0.0"
|
|
38
38
|
}
|
|
39
39
|
}
|