@wavy/fn 0.0.20 → 0.0.22
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 +46 -1
- package/dist/main.d.cts +8 -2
- package/dist/main.d.ts +8 -2
- package/dist/main.js +41 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -27,6 +27,8 @@ __export(main_exports, {
|
|
|
27
27
|
blankSpaces: () => blankSpaces,
|
|
28
28
|
buildArray: () => buildArray,
|
|
29
29
|
camelCaseToLetter: () => camelCaseToLetter,
|
|
30
|
+
castArray: () => castArray,
|
|
31
|
+
castReturn: () => castReturn,
|
|
30
32
|
classNameExt: () => classNameExt,
|
|
31
33
|
classNameResolver: () => classNameResolver,
|
|
32
34
|
coerceIn: () => coerceIn,
|
|
@@ -63,8 +65,11 @@ __export(main_exports, {
|
|
|
63
65
|
maxOf: () => maxOf,
|
|
64
66
|
minOf: () => minOf,
|
|
65
67
|
negate: () => negate,
|
|
68
|
+
omit: () => omit,
|
|
69
|
+
omitNils: () => omitNils,
|
|
66
70
|
ordinalIndicator: () => ordinalIndicator,
|
|
67
71
|
overwrite: () => overwrite,
|
|
72
|
+
pick: () => pick,
|
|
68
73
|
pluralize: () => pluralize,
|
|
69
74
|
poll: () => poll,
|
|
70
75
|
random: () => random,
|
|
@@ -472,7 +477,7 @@ var TimeManager = class _TimeManager {
|
|
|
472
477
|
return takeLastWhile(fmtDate.split(""), (char) => char !== ",").join("").trim();
|
|
473
478
|
if (format2 === "MMM dd, yyyy | hh:mm A" || format2 === "MMM dd, yyyy at hh:mm A") {
|
|
474
479
|
const delimiter = format2 === "MMM dd, yyyy at hh:mm A" ? "at" : "|";
|
|
475
|
-
const time2 =
|
|
480
|
+
const time2 = new _TimeManager().format(convertedDate, "hh:mm A");
|
|
476
481
|
return [fmtDate, time2].join(` ${delimiter} `);
|
|
477
482
|
}
|
|
478
483
|
return fmtDate;
|
|
@@ -597,6 +602,41 @@ function isLocalFile(value) {
|
|
|
597
602
|
}
|
|
598
603
|
return false;
|
|
599
604
|
}
|
|
605
|
+
function castArray(value) {
|
|
606
|
+
return Array.isArray(value) ? value : [value];
|
|
607
|
+
}
|
|
608
|
+
function castReturn(value) {
|
|
609
|
+
if (typeof value === "function") return value();
|
|
610
|
+
else return value;
|
|
611
|
+
}
|
|
612
|
+
function pick(value, keys) {
|
|
613
|
+
const result = {};
|
|
614
|
+
if (!value || !keys || keys.length === 0) return value;
|
|
615
|
+
for (const key of keys) {
|
|
616
|
+
if (key in value) result[key] = value[key];
|
|
617
|
+
else result[key] = null;
|
|
618
|
+
}
|
|
619
|
+
return result;
|
|
620
|
+
}
|
|
621
|
+
function omit(value, keys) {
|
|
622
|
+
const result = {};
|
|
623
|
+
if (!value || !keys || keys.length === 0) return value;
|
|
624
|
+
for (const [k, v] of Object.entries(value)) {
|
|
625
|
+
if (!(keys || []).includes(k)) result[k] = v;
|
|
626
|
+
}
|
|
627
|
+
return result;
|
|
628
|
+
}
|
|
629
|
+
function omitNils(value) {
|
|
630
|
+
const result = {};
|
|
631
|
+
if (!value) return value;
|
|
632
|
+
for (const key of Object.keys(value)) {
|
|
633
|
+
const validKey = key;
|
|
634
|
+
const prop = value[validKey];
|
|
635
|
+
if (prop === null || prop === void 0) continue;
|
|
636
|
+
result[validKey] = prop;
|
|
637
|
+
}
|
|
638
|
+
return result;
|
|
639
|
+
}
|
|
600
640
|
function getMimeTypes(typeAliases) {
|
|
601
641
|
return distinct(strictArray(typeAliases)).map((alias) => import_types2.LOCAL_FILE_MIME_TYPES[alias]).flat();
|
|
602
642
|
}
|
|
@@ -1094,6 +1134,8 @@ var serverDataAdapter = new ServerDataAdapter().invoke;
|
|
|
1094
1134
|
blankSpaces,
|
|
1095
1135
|
buildArray,
|
|
1096
1136
|
camelCaseToLetter,
|
|
1137
|
+
castArray,
|
|
1138
|
+
castReturn,
|
|
1097
1139
|
classNameExt,
|
|
1098
1140
|
classNameResolver,
|
|
1099
1141
|
coerceIn,
|
|
@@ -1130,8 +1172,11 @@ var serverDataAdapter = new ServerDataAdapter().invoke;
|
|
|
1130
1172
|
maxOf,
|
|
1131
1173
|
minOf,
|
|
1132
1174
|
negate,
|
|
1175
|
+
omit,
|
|
1176
|
+
omitNils,
|
|
1133
1177
|
ordinalIndicator,
|
|
1134
1178
|
overwrite,
|
|
1179
|
+
pick,
|
|
1135
1180
|
pluralize,
|
|
1136
1181
|
poll,
|
|
1137
1182
|
random,
|
package/dist/main.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@wavy/types"
|
|
2
2
|
import * as _wavy_types from '@wavy/types';
|
|
3
|
-
import { LocalFile, SanitizeFile, KnownFileTypeAlias, TaskResult, FromServer, NormalizeFromServer } from '@wavy/types';
|
|
3
|
+
import { LocalFile, SanitizeFile, NonFunction, KnownFileTypeAlias, TaskResult, FromServer, NormalizeFromServer } from '@wavy/types';
|
|
4
4
|
|
|
5
5
|
type DateFormat = "MMM dd, yyyy" | "MMM dd, yyyy | hh:mm A" | "MMM dd, yyyy at hh:mm A" | "MMMM" | "yyyy" | "MMM yyyy" | "mm/dd/yyyy" | "mm/dd/yyyy hh:mm A" | "hh:mm A" | "hh:mm:ss A";
|
|
6
6
|
|
|
@@ -50,6 +50,7 @@ declare const dateFormat: (time: number | Date | "now", format?: DateFormat) =>
|
|
|
50
50
|
declare const timeDuration: (from: number | "now" | Date, to: number | "now" | Date, options?: {
|
|
51
51
|
disableRemainder?: boolean;
|
|
52
52
|
abvUnits?: boolean;
|
|
53
|
+
round?: boolean;
|
|
53
54
|
}) => string;
|
|
54
55
|
declare const upperFirst: typeof StringFormatter.upperFirst;
|
|
55
56
|
declare const camelCaseToLetter: (camelCase: string) => string;
|
|
@@ -66,6 +67,11 @@ declare function format<Event extends "date" | "money" | "name" | "address" | "f
|
|
|
66
67
|
declare function sanitizeLocalFile({ _metadata: _, ...file }: LocalFile): SanitizeFile<LocalFile>;
|
|
67
68
|
declare function isFile(value: unknown): value is File;
|
|
68
69
|
declare function isLocalFile(value: unknown): value is LocalFile;
|
|
70
|
+
declare function castArray<T>(value: T | T[]): T[];
|
|
71
|
+
declare function castReturn<T extends NonFunction<any>>(value: T | (() => T)): T;
|
|
72
|
+
declare function pick<O extends object, K extends keyof O>(value: O, keys: K[]): { [Key in K]: O[Key] | null; };
|
|
73
|
+
declare function omit<O extends object, K extends keyof O>(value: O, keys: K[]): { [Key in Exclude<keyof O, K>]: O[Key] | null; };
|
|
74
|
+
declare function omitNils<O extends object>(value: O): O;
|
|
69
75
|
declare function getMimeTypes(typeAliases: KnownFileTypeAlias[]): string[];
|
|
70
76
|
declare function classNameResolver(baseClassName: string): (className: string) => string;
|
|
71
77
|
declare function classNameExt(rootClassName: string): (className: string) => string;
|
|
@@ -184,4 +190,4 @@ declare const serverDataAdapter: {
|
|
|
184
190
|
}>(event: "unzip", data: DataType): NormalizeFromServer<DataType>;
|
|
185
191
|
};
|
|
186
192
|
|
|
187
|
-
export { addArticle, arrayWithConst, asyncRun, averageOf, blankSpaces, buildArray, camelCaseToLetter, 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, isLetter, isLocalFile, isNumber, lastIndex, map, mapToArray, maxOf, minOf, negate, ordinalIndicator, overwrite, pluralize, poll, random, range, readClipboardText, removeAll, repeat, run, sanitizeLocalFile, serverDataAdapter, someValuesEmpty, sort, strictArray, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, toObject, trimString, undefinedIfEmpty, upperFirst, windowed };
|
|
193
|
+
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, isLetter, isLocalFile, isNumber, lastIndex, map, mapToArray, maxOf, minOf, negate, omit, omitNils, ordinalIndicator, overwrite, pick, pluralize, poll, random, range, readClipboardText, removeAll, repeat, run, sanitizeLocalFile, serverDataAdapter, someValuesEmpty, sort, strictArray, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, toObject, trimString, undefinedIfEmpty, upperFirst, windowed };
|
package/dist/main.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@wavy/types"
|
|
2
2
|
import * as _wavy_types from '@wavy/types';
|
|
3
|
-
import { LocalFile, SanitizeFile, KnownFileTypeAlias, TaskResult, FromServer, NormalizeFromServer } from '@wavy/types';
|
|
3
|
+
import { LocalFile, SanitizeFile, NonFunction, KnownFileTypeAlias, TaskResult, FromServer, NormalizeFromServer } from '@wavy/types';
|
|
4
4
|
|
|
5
5
|
type DateFormat = "MMM dd, yyyy" | "MMM dd, yyyy | hh:mm A" | "MMM dd, yyyy at hh:mm A" | "MMMM" | "yyyy" | "MMM yyyy" | "mm/dd/yyyy" | "mm/dd/yyyy hh:mm A" | "hh:mm A" | "hh:mm:ss A";
|
|
6
6
|
|
|
@@ -50,6 +50,7 @@ declare const dateFormat: (time: number | Date | "now", format?: DateFormat) =>
|
|
|
50
50
|
declare const timeDuration: (from: number | "now" | Date, to: number | "now" | Date, options?: {
|
|
51
51
|
disableRemainder?: boolean;
|
|
52
52
|
abvUnits?: boolean;
|
|
53
|
+
round?: boolean;
|
|
53
54
|
}) => string;
|
|
54
55
|
declare const upperFirst: typeof StringFormatter.upperFirst;
|
|
55
56
|
declare const camelCaseToLetter: (camelCase: string) => string;
|
|
@@ -66,6 +67,11 @@ declare function format<Event extends "date" | "money" | "name" | "address" | "f
|
|
|
66
67
|
declare function sanitizeLocalFile({ _metadata: _, ...file }: LocalFile): SanitizeFile<LocalFile>;
|
|
67
68
|
declare function isFile(value: unknown): value is File;
|
|
68
69
|
declare function isLocalFile(value: unknown): value is LocalFile;
|
|
70
|
+
declare function castArray<T>(value: T | T[]): T[];
|
|
71
|
+
declare function castReturn<T extends NonFunction<any>>(value: T | (() => T)): T;
|
|
72
|
+
declare function pick<O extends object, K extends keyof O>(value: O, keys: K[]): { [Key in K]: O[Key] | null; };
|
|
73
|
+
declare function omit<O extends object, K extends keyof O>(value: O, keys: K[]): { [Key in Exclude<keyof O, K>]: O[Key] | null; };
|
|
74
|
+
declare function omitNils<O extends object>(value: O): O;
|
|
69
75
|
declare function getMimeTypes(typeAliases: KnownFileTypeAlias[]): string[];
|
|
70
76
|
declare function classNameResolver(baseClassName: string): (className: string) => string;
|
|
71
77
|
declare function classNameExt(rootClassName: string): (className: string) => string;
|
|
@@ -184,4 +190,4 @@ declare const serverDataAdapter: {
|
|
|
184
190
|
}>(event: "unzip", data: DataType): NormalizeFromServer<DataType>;
|
|
185
191
|
};
|
|
186
192
|
|
|
187
|
-
export { addArticle, arrayWithConst, asyncRun, averageOf, blankSpaces, buildArray, camelCaseToLetter, 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, isLetter, isLocalFile, isNumber, lastIndex, map, mapToArray, maxOf, minOf, negate, ordinalIndicator, overwrite, pluralize, poll, random, range, readClipboardText, removeAll, repeat, run, sanitizeLocalFile, serverDataAdapter, someValuesEmpty, sort, strictArray, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, toObject, trimString, undefinedIfEmpty, upperFirst, windowed };
|
|
193
|
+
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, isLetter, isLocalFile, isNumber, lastIndex, map, mapToArray, maxOf, minOf, negate, omit, omitNils, ordinalIndicator, overwrite, pick, pluralize, poll, random, range, readClipboardText, removeAll, repeat, run, sanitizeLocalFile, serverDataAdapter, someValuesEmpty, sort, strictArray, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, toObject, trimString, undefinedIfEmpty, upperFirst, windowed };
|
package/dist/main.js
CHANGED
|
@@ -377,7 +377,7 @@ var TimeManager = class _TimeManager {
|
|
|
377
377
|
return takeLastWhile(fmtDate.split(""), (char) => char !== ",").join("").trim();
|
|
378
378
|
if (format2 === "MMM dd, yyyy | hh:mm A" || format2 === "MMM dd, yyyy at hh:mm A") {
|
|
379
379
|
const delimiter = format2 === "MMM dd, yyyy at hh:mm A" ? "at" : "|";
|
|
380
|
-
const time2 =
|
|
380
|
+
const time2 = new _TimeManager().format(convertedDate, "hh:mm A");
|
|
381
381
|
return [fmtDate, time2].join(` ${delimiter} `);
|
|
382
382
|
}
|
|
383
383
|
return fmtDate;
|
|
@@ -502,6 +502,41 @@ function isLocalFile(value) {
|
|
|
502
502
|
}
|
|
503
503
|
return false;
|
|
504
504
|
}
|
|
505
|
+
function castArray(value) {
|
|
506
|
+
return Array.isArray(value) ? value : [value];
|
|
507
|
+
}
|
|
508
|
+
function castReturn(value) {
|
|
509
|
+
if (typeof value === "function") return value();
|
|
510
|
+
else return value;
|
|
511
|
+
}
|
|
512
|
+
function pick(value, keys) {
|
|
513
|
+
const result = {};
|
|
514
|
+
if (!value || !keys || keys.length === 0) return value;
|
|
515
|
+
for (const key of keys) {
|
|
516
|
+
if (key in value) result[key] = value[key];
|
|
517
|
+
else result[key] = null;
|
|
518
|
+
}
|
|
519
|
+
return result;
|
|
520
|
+
}
|
|
521
|
+
function omit(value, keys) {
|
|
522
|
+
const result = {};
|
|
523
|
+
if (!value || !keys || keys.length === 0) return value;
|
|
524
|
+
for (const [k, v] of Object.entries(value)) {
|
|
525
|
+
if (!(keys || []).includes(k)) result[k] = v;
|
|
526
|
+
}
|
|
527
|
+
return result;
|
|
528
|
+
}
|
|
529
|
+
function omitNils(value) {
|
|
530
|
+
const result = {};
|
|
531
|
+
if (!value) return value;
|
|
532
|
+
for (const key of Object.keys(value)) {
|
|
533
|
+
const validKey = key;
|
|
534
|
+
const prop = value[validKey];
|
|
535
|
+
if (prop === null || prop === void 0) continue;
|
|
536
|
+
result[validKey] = prop;
|
|
537
|
+
}
|
|
538
|
+
return result;
|
|
539
|
+
}
|
|
505
540
|
function getMimeTypes(typeAliases) {
|
|
506
541
|
return distinct(strictArray(typeAliases)).map((alias) => LOCAL_FILE_MIME_TYPES2[alias]).flat();
|
|
507
542
|
}
|
|
@@ -998,6 +1033,8 @@ export {
|
|
|
998
1033
|
blankSpaces,
|
|
999
1034
|
buildArray,
|
|
1000
1035
|
camelCaseToLetter,
|
|
1036
|
+
castArray,
|
|
1037
|
+
castReturn,
|
|
1001
1038
|
classNameExt,
|
|
1002
1039
|
classNameResolver,
|
|
1003
1040
|
coerceIn,
|
|
@@ -1034,8 +1071,11 @@ export {
|
|
|
1034
1071
|
maxOf,
|
|
1035
1072
|
minOf,
|
|
1036
1073
|
negate,
|
|
1074
|
+
omit,
|
|
1075
|
+
omitNils,
|
|
1037
1076
|
ordinalIndicator,
|
|
1038
1077
|
overwrite,
|
|
1078
|
+
pick,
|
|
1039
1079
|
pluralize,
|
|
1040
1080
|
poll,
|
|
1041
1081
|
random,
|