@wavy/fn 0.0.24 → 0.0.26
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 +7 -1
- package/dist/main.d.cts +4 -3
- package/dist/main.d.ts +4 -3
- package/dist/main.js +6 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -71,6 +71,7 @@ __export(main_exports, {
|
|
|
71
71
|
omitNils: () => omitNils,
|
|
72
72
|
ordinalIndicator: () => ordinalIndicator,
|
|
73
73
|
overwrite: () => overwrite,
|
|
74
|
+
parseName: () => parseName,
|
|
74
75
|
pick: () => pick,
|
|
75
76
|
pluralize: () => pluralize,
|
|
76
77
|
poll: () => poll,
|
|
@@ -218,7 +219,7 @@ var NumberFormatter = class _NumberFormatter {
|
|
|
218
219
|
};
|
|
219
220
|
let amount2 = parseInt(decimal) > 0 ? `${value}.${decimal}` : value;
|
|
220
221
|
if (amount2.includes("-")) {
|
|
221
|
-
amount2 = "-" + dollarSign + amount2;
|
|
222
|
+
amount2 = "-" + dollarSign + amount2.replaceAll("-", "");
|
|
222
223
|
} else {
|
|
223
224
|
amount2 = dollarSign + amount2;
|
|
224
225
|
}
|
|
@@ -617,6 +618,10 @@ function isPromise(value) {
|
|
|
617
618
|
if (value instanceof Promise) return true;
|
|
618
619
|
return !!value && (typeof value === "object" || typeof value === "function") && "then" in value && typeof value.then === "function";
|
|
619
620
|
}
|
|
621
|
+
function parseName(value) {
|
|
622
|
+
const [first = "", last = ""] = (value || "").split(" ");
|
|
623
|
+
return { first, last };
|
|
624
|
+
}
|
|
620
625
|
function castArray(value) {
|
|
621
626
|
return Array.isArray(value) ? value : [value];
|
|
622
627
|
}
|
|
@@ -1193,6 +1198,7 @@ var serverDataAdapter = new ServerDataAdapter().invoke;
|
|
|
1193
1198
|
omitNils,
|
|
1194
1199
|
ordinalIndicator,
|
|
1195
1200
|
overwrite,
|
|
1201
|
+
parseName,
|
|
1196
1202
|
pick,
|
|
1197
1203
|
pluralize,
|
|
1198
1204
|
poll,
|
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, NonFunction, KnownFileTypeAlias, TaskResult, FromServer, NormalizeFromServer } from '@wavy/types';
|
|
3
|
+
import { LocalFile, Name, 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
|
|
|
@@ -60,7 +60,7 @@ declare const getCaps: (value: string, count?: number) => string[];
|
|
|
60
60
|
declare const toNumber: typeof StringFormatter.toNumber;
|
|
61
61
|
declare const addArticle: typeof StringFormatter.addArticle;
|
|
62
62
|
declare const pluralize: typeof StringFormatter.pluralize;
|
|
63
|
-
declare const nameToString: (name:
|
|
63
|
+
declare const nameToString: (name: Name | undefined) => string;
|
|
64
64
|
declare const addressToString: (address: _wavy_types.Address | undefined, inline?: boolean) => string;
|
|
65
65
|
declare const toMoney: (value: string | number, options?: NumberFormatterTypes["options"]["money"]) => string;
|
|
66
66
|
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;
|
|
@@ -69,6 +69,7 @@ declare function isFile(value: unknown): value is File;
|
|
|
69
69
|
declare function isLocalFile(value: unknown): value is LocalFile;
|
|
70
70
|
declare function isIterable<T>(value: unknown): value is Iterable<T>;
|
|
71
71
|
declare function isPromise<T>(value: unknown): value is Promise<T>;
|
|
72
|
+
declare function parseName(value: string): Name;
|
|
72
73
|
declare function castArray<T>(value: T | T[]): T[];
|
|
73
74
|
declare function castReturn<T extends NonFunction<any>>(value: T | (() => T)): T;
|
|
74
75
|
declare function pick<O extends object, K extends keyof O>(value: O, keys: K[]): { [Key in K]: O[Key] | null; };
|
|
@@ -192,4 +193,4 @@ declare const serverDataAdapter: {
|
|
|
192
193
|
}>(event: "unzip", data: DataType): NormalizeFromServer<DataType>;
|
|
193
194
|
};
|
|
194
195
|
|
|
195
|
-
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, isIterable, isLetter, isLocalFile, isNumber, isPromise, 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 };
|
|
196
|
+
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, isIterable, isLetter, isLocalFile, isNumber, isPromise, lastIndex, map, mapToArray, maxOf, minOf, negate, omit, omitNils, ordinalIndicator, overwrite, parseName, 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, NonFunction, KnownFileTypeAlias, TaskResult, FromServer, NormalizeFromServer } from '@wavy/types';
|
|
3
|
+
import { LocalFile, Name, 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
|
|
|
@@ -60,7 +60,7 @@ declare const getCaps: (value: string, count?: number) => string[];
|
|
|
60
60
|
declare const toNumber: typeof StringFormatter.toNumber;
|
|
61
61
|
declare const addArticle: typeof StringFormatter.addArticle;
|
|
62
62
|
declare const pluralize: typeof StringFormatter.pluralize;
|
|
63
|
-
declare const nameToString: (name:
|
|
63
|
+
declare const nameToString: (name: Name | undefined) => string;
|
|
64
64
|
declare const addressToString: (address: _wavy_types.Address | undefined, inline?: boolean) => string;
|
|
65
65
|
declare const toMoney: (value: string | number, options?: NumberFormatterTypes["options"]["money"]) => string;
|
|
66
66
|
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;
|
|
@@ -69,6 +69,7 @@ declare function isFile(value: unknown): value is File;
|
|
|
69
69
|
declare function isLocalFile(value: unknown): value is LocalFile;
|
|
70
70
|
declare function isIterable<T>(value: unknown): value is Iterable<T>;
|
|
71
71
|
declare function isPromise<T>(value: unknown): value is Promise<T>;
|
|
72
|
+
declare function parseName(value: string): Name;
|
|
72
73
|
declare function castArray<T>(value: T | T[]): T[];
|
|
73
74
|
declare function castReturn<T extends NonFunction<any>>(value: T | (() => T)): T;
|
|
74
75
|
declare function pick<O extends object, K extends keyof O>(value: O, keys: K[]): { [Key in K]: O[Key] | null; };
|
|
@@ -192,4 +193,4 @@ declare const serverDataAdapter: {
|
|
|
192
193
|
}>(event: "unzip", data: DataType): NormalizeFromServer<DataType>;
|
|
193
194
|
};
|
|
194
195
|
|
|
195
|
-
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, isIterable, isLetter, isLocalFile, isNumber, isPromise, 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 };
|
|
196
|
+
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, isIterable, isLetter, isLocalFile, isNumber, isPromise, lastIndex, map, mapToArray, maxOf, minOf, negate, omit, omitNils, ordinalIndicator, overwrite, parseName, 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
|
@@ -116,7 +116,7 @@ var NumberFormatter = class _NumberFormatter {
|
|
|
116
116
|
};
|
|
117
117
|
let amount2 = parseInt(decimal) > 0 ? `${value}.${decimal}` : value;
|
|
118
118
|
if (amount2.includes("-")) {
|
|
119
|
-
amount2 = "-" + dollarSign + amount2;
|
|
119
|
+
amount2 = "-" + dollarSign + amount2.replaceAll("-", "");
|
|
120
120
|
} else {
|
|
121
121
|
amount2 = dollarSign + amount2;
|
|
122
122
|
}
|
|
@@ -515,6 +515,10 @@ function isPromise(value) {
|
|
|
515
515
|
if (value instanceof Promise) return true;
|
|
516
516
|
return !!value && (typeof value === "object" || typeof value === "function") && "then" in value && typeof value.then === "function";
|
|
517
517
|
}
|
|
518
|
+
function parseName(value) {
|
|
519
|
+
const [first = "", last = ""] = (value || "").split(" ");
|
|
520
|
+
return { first, last };
|
|
521
|
+
}
|
|
518
522
|
function castArray(value) {
|
|
519
523
|
return Array.isArray(value) ? value : [value];
|
|
520
524
|
}
|
|
@@ -1090,6 +1094,7 @@ export {
|
|
|
1090
1094
|
omitNils,
|
|
1091
1095
|
ordinalIndicator,
|
|
1092
1096
|
overwrite,
|
|
1097
|
+
parseName,
|
|
1093
1098
|
pick,
|
|
1094
1099
|
pluralize,
|
|
1095
1100
|
poll,
|