@wavy/fn 0.0.15 → 0.0.16
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 +10 -8
- package/dist/main.d.cts +6 -3
- package/dist/main.d.ts +6 -3
- package/dist/main.js +13 -9
- package/package.json +2 -2
package/dist/main.cjs
CHANGED
|
@@ -454,8 +454,8 @@ var import_uuid = require("uuid");
|
|
|
454
454
|
var import_types = require("@wavy/types");
|
|
455
455
|
var import_console = require("console");
|
|
456
456
|
function fileToLocalFile(file, options) {
|
|
457
|
+
const fileExt = getFileExt(file.name);
|
|
457
458
|
const fileName = (() => {
|
|
458
|
-
const fileExt = getFileExt(file.name);
|
|
459
459
|
if (options?.filename && options.filename.includes(fileExt))
|
|
460
460
|
return options.filename;
|
|
461
461
|
else if (options?.filename) return options.filename.trim() + fileExt;
|
|
@@ -465,6 +465,7 @@ function fileToLocalFile(file, options) {
|
|
|
465
465
|
return {
|
|
466
466
|
uid: options?.uid || (0, import_uuid.v4)(),
|
|
467
467
|
description: options?.description,
|
|
468
|
+
ext: fileExt,
|
|
468
469
|
path: options?.filepath || file?.webkitRelativePath,
|
|
469
470
|
typeAlias: options?.typeAlias || run(
|
|
470
471
|
Object.keys(import_types.LOCAL_FILE_MIME_TYPES).find(
|
|
@@ -563,6 +564,7 @@ function isLocalFile(value) {
|
|
|
563
564
|
description: "",
|
|
564
565
|
path: "",
|
|
565
566
|
sizeInBytes: 0,
|
|
567
|
+
ext: "",
|
|
566
568
|
typeAlias: "unknown",
|
|
567
569
|
uid: "",
|
|
568
570
|
uploadDate: 0,
|
|
@@ -684,17 +686,17 @@ function group(arr, isGroup) {
|
|
|
684
686
|
return groups;
|
|
685
687
|
}
|
|
686
688
|
function strictArray(arr) {
|
|
687
|
-
return arr
|
|
689
|
+
return (arr || []).filter(
|
|
688
690
|
(val) => typeof val === "string" ? val.trim().length > 0 : val !== void 0 && val !== null
|
|
689
691
|
);
|
|
690
692
|
}
|
|
691
693
|
function maxOf(arr) {
|
|
692
|
-
const fmtArr = strictArray(arr
|
|
693
|
-
return isEmpty(
|
|
694
|
+
const fmtArr = strictArray(arr);
|
|
695
|
+
return isEmpty(fmtArr) ? 0 : fmtArr.reduce((prev, current) => current > prev ? current : prev);
|
|
694
696
|
}
|
|
695
697
|
function minOf(arr) {
|
|
696
698
|
const fmtArr = strictArray(arr || []);
|
|
697
|
-
return isEmpty(
|
|
699
|
+
return isEmpty(fmtArr) ? 0 : fmtArr.reduce((prev, current) => current < prev ? current : prev);
|
|
698
700
|
}
|
|
699
701
|
function averageOf(arr) {
|
|
700
702
|
const fmtArr = strictArray(arr || []);
|
|
@@ -726,7 +728,7 @@ function sort(arr, sortBy, order = "asc") {
|
|
|
726
728
|
}
|
|
727
729
|
return order === "asc" ? queryA < queryB : queryA > queryB;
|
|
728
730
|
};
|
|
729
|
-
return arr.toSorted(
|
|
731
|
+
return (arr || []).toSorted(
|
|
730
732
|
(a, b) => sortOrder(a, b) ? -1 : queryObj(a) === queryObj(b) ? 0 : 1
|
|
731
733
|
);
|
|
732
734
|
}
|
|
@@ -737,7 +739,7 @@ function insertAt(arr, index, value) {
|
|
|
737
739
|
return arr.toSpliced(index, 0, value);
|
|
738
740
|
}
|
|
739
741
|
function overwrite(arr, index, newValue) {
|
|
740
|
-
return arr.with(index, newValue);
|
|
742
|
+
return (arr || []).with(index, newValue);
|
|
741
743
|
}
|
|
742
744
|
function take(value, amount) {
|
|
743
745
|
return [...value].splice(0, amount);
|
|
@@ -800,7 +802,7 @@ function mapToArray(map2) {
|
|
|
800
802
|
}
|
|
801
803
|
function distinct(arr) {
|
|
802
804
|
const newArr = [];
|
|
803
|
-
arr.forEach((value) => {
|
|
805
|
+
(arr || []).forEach((value) => {
|
|
804
806
|
if (!newArr.includes(value)) newArr.push(value);
|
|
805
807
|
});
|
|
806
808
|
return newArr;
|
package/dist/main.d.cts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import "@wavy/types"
|
|
2
|
+
import * as _wavy_types from '@wavy/types';
|
|
3
|
+
import { LocalFile, SanitizeFile, KnownFileTypeAlias, TaskResult, FromServer, NormalizeFromServer } from '@wavy/types';
|
|
4
|
+
|
|
2
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";
|
|
3
6
|
|
|
4
7
|
type NumberFormatterTypes = {
|
|
@@ -56,9 +59,9 @@ declare const getCaps: (value: string, count?: number) => string[];
|
|
|
56
59
|
declare const toNumber: typeof StringFormatter.toNumber;
|
|
57
60
|
declare const addArticle: typeof StringFormatter.addArticle;
|
|
58
61
|
declare const pluralize: typeof StringFormatter.pluralize;
|
|
59
|
-
declare const nameToString: (name: Name | undefined) => string;
|
|
60
|
-
declare const phoneNoToString: (phoneNumber: PhoneNumber | undefined) => string;
|
|
61
|
-
declare const addressToString: (address: Address | undefined, inline?: boolean) => string;
|
|
62
|
+
declare const nameToString: (name: _wavy_types.Name | undefined) => string;
|
|
63
|
+
declare const phoneNoToString: (phoneNumber: _wavy_types.PhoneNumber | undefined) => string;
|
|
64
|
+
declare const addressToString: (address: _wavy_types.Address | undefined, inline?: boolean) => string;
|
|
62
65
|
declare const toMoney: (value: string | number, options?: NumberFormatterTypes["options"]["money"]) => string;
|
|
63
66
|
declare function format<Event extends "date" | "money" | "name" | "phone-number" | "address">(event: Event, ...args: Event extends "date" ? Parameters<typeof dateFormat> : Event extends "money" ? Parameters<typeof toMoney> : Event extends "name" ? Parameters<typeof nameToString> : Event extends "phone-number" ? Parameters<typeof phoneNoToString> : Event extends "address" ? Parameters<typeof addressToString> : never): Event extends "date" ? ReturnType<typeof dateFormat> : Event extends "money" ? ReturnType<typeof toMoney> : Event extends "name" ? ReturnType<typeof nameToString> : Event extends "phone-number" ? ReturnType<typeof phoneNoToString> : Event extends "address" ? ReturnType<typeof addressToString> : never;
|
|
64
67
|
declare function sanitizeLocalFile({ _metadata: _, ...file }: LocalFile): SanitizeFile<LocalFile>;
|
package/dist/main.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import "@wavy/types"
|
|
2
|
+
import * as _wavy_types from '@wavy/types';
|
|
3
|
+
import { LocalFile, SanitizeFile, KnownFileTypeAlias, TaskResult, FromServer, NormalizeFromServer } from '@wavy/types';
|
|
4
|
+
|
|
2
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";
|
|
3
6
|
|
|
4
7
|
type NumberFormatterTypes = {
|
|
@@ -56,9 +59,9 @@ declare const getCaps: (value: string, count?: number) => string[];
|
|
|
56
59
|
declare const toNumber: typeof StringFormatter.toNumber;
|
|
57
60
|
declare const addArticle: typeof StringFormatter.addArticle;
|
|
58
61
|
declare const pluralize: typeof StringFormatter.pluralize;
|
|
59
|
-
declare const nameToString: (name: Name | undefined) => string;
|
|
60
|
-
declare const phoneNoToString: (phoneNumber: PhoneNumber | undefined) => string;
|
|
61
|
-
declare const addressToString: (address: Address | undefined, inline?: boolean) => string;
|
|
62
|
+
declare const nameToString: (name: _wavy_types.Name | undefined) => string;
|
|
63
|
+
declare const phoneNoToString: (phoneNumber: _wavy_types.PhoneNumber | undefined) => string;
|
|
64
|
+
declare const addressToString: (address: _wavy_types.Address | undefined, inline?: boolean) => string;
|
|
62
65
|
declare const toMoney: (value: string | number, options?: NumberFormatterTypes["options"]["money"]) => string;
|
|
63
66
|
declare function format<Event extends "date" | "money" | "name" | "phone-number" | "address">(event: Event, ...args: Event extends "date" ? Parameters<typeof dateFormat> : Event extends "money" ? Parameters<typeof toMoney> : Event extends "name" ? Parameters<typeof nameToString> : Event extends "phone-number" ? Parameters<typeof phoneNoToString> : Event extends "address" ? Parameters<typeof addressToString> : never): Event extends "date" ? ReturnType<typeof dateFormat> : Event extends "money" ? ReturnType<typeof toMoney> : Event extends "name" ? ReturnType<typeof nameToString> : Event extends "phone-number" ? ReturnType<typeof phoneNoToString> : Event extends "address" ? ReturnType<typeof addressToString> : never;
|
|
64
67
|
declare function sanitizeLocalFile({ _metadata: _, ...file }: LocalFile): SanitizeFile<LocalFile>;
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// src/helper-functions/HelperFunctions.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
LOCAL_FILE_MIME_TYPES as LOCAL_FILE_MIME_TYPES2
|
|
4
|
+
} from "@wavy/types";
|
|
3
5
|
|
|
4
6
|
// src/helper-functions/components/formatter/number/NumberFormatter.ts
|
|
5
7
|
var NumberFormatter = class _NumberFormatter {
|
|
@@ -357,8 +359,8 @@ import { v4 } from "uuid";
|
|
|
357
359
|
import { LOCAL_FILE_MIME_TYPES } from "@wavy/types";
|
|
358
360
|
import { log } from "console";
|
|
359
361
|
function fileToLocalFile(file, options) {
|
|
362
|
+
const fileExt = getFileExt(file.name);
|
|
360
363
|
const fileName = (() => {
|
|
361
|
-
const fileExt = getFileExt(file.name);
|
|
362
364
|
if (options?.filename && options.filename.includes(fileExt))
|
|
363
365
|
return options.filename;
|
|
364
366
|
else if (options?.filename) return options.filename.trim() + fileExt;
|
|
@@ -368,6 +370,7 @@ function fileToLocalFile(file, options) {
|
|
|
368
370
|
return {
|
|
369
371
|
uid: options?.uid || v4(),
|
|
370
372
|
description: options?.description,
|
|
373
|
+
ext: fileExt,
|
|
371
374
|
path: options?.filepath || file?.webkitRelativePath,
|
|
372
375
|
typeAlias: options?.typeAlias || run(
|
|
373
376
|
Object.keys(LOCAL_FILE_MIME_TYPES).find(
|
|
@@ -466,6 +469,7 @@ function isLocalFile(value) {
|
|
|
466
469
|
description: "",
|
|
467
470
|
path: "",
|
|
468
471
|
sizeInBytes: 0,
|
|
472
|
+
ext: "",
|
|
469
473
|
typeAlias: "unknown",
|
|
470
474
|
uid: "",
|
|
471
475
|
uploadDate: 0,
|
|
@@ -587,17 +591,17 @@ function group(arr, isGroup) {
|
|
|
587
591
|
return groups;
|
|
588
592
|
}
|
|
589
593
|
function strictArray(arr) {
|
|
590
|
-
return arr
|
|
594
|
+
return (arr || []).filter(
|
|
591
595
|
(val) => typeof val === "string" ? val.trim().length > 0 : val !== void 0 && val !== null
|
|
592
596
|
);
|
|
593
597
|
}
|
|
594
598
|
function maxOf(arr) {
|
|
595
|
-
const fmtArr = strictArray(arr
|
|
596
|
-
return isEmpty(
|
|
599
|
+
const fmtArr = strictArray(arr);
|
|
600
|
+
return isEmpty(fmtArr) ? 0 : fmtArr.reduce((prev, current) => current > prev ? current : prev);
|
|
597
601
|
}
|
|
598
602
|
function minOf(arr) {
|
|
599
603
|
const fmtArr = strictArray(arr || []);
|
|
600
|
-
return isEmpty(
|
|
604
|
+
return isEmpty(fmtArr) ? 0 : fmtArr.reduce((prev, current) => current < prev ? current : prev);
|
|
601
605
|
}
|
|
602
606
|
function averageOf(arr) {
|
|
603
607
|
const fmtArr = strictArray(arr || []);
|
|
@@ -629,7 +633,7 @@ function sort(arr, sortBy, order = "asc") {
|
|
|
629
633
|
}
|
|
630
634
|
return order === "asc" ? queryA < queryB : queryA > queryB;
|
|
631
635
|
};
|
|
632
|
-
return arr.toSorted(
|
|
636
|
+
return (arr || []).toSorted(
|
|
633
637
|
(a, b) => sortOrder(a, b) ? -1 : queryObj(a) === queryObj(b) ? 0 : 1
|
|
634
638
|
);
|
|
635
639
|
}
|
|
@@ -640,7 +644,7 @@ function insertAt(arr, index, value) {
|
|
|
640
644
|
return arr.toSpliced(index, 0, value);
|
|
641
645
|
}
|
|
642
646
|
function overwrite(arr, index, newValue) {
|
|
643
|
-
return arr.with(index, newValue);
|
|
647
|
+
return (arr || []).with(index, newValue);
|
|
644
648
|
}
|
|
645
649
|
function take(value, amount) {
|
|
646
650
|
return [...value].splice(0, amount);
|
|
@@ -703,7 +707,7 @@ function mapToArray(map2) {
|
|
|
703
707
|
}
|
|
704
708
|
function distinct(arr) {
|
|
705
709
|
const newArr = [];
|
|
706
|
-
arr.forEach((value) => {
|
|
710
|
+
(arr || []).forEach((value) => {
|
|
707
711
|
if (!newArr.includes(value)) newArr.push(value);
|
|
708
712
|
});
|
|
709
713
|
return newArr;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wavy/fn",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"main": "./dist/main.js",
|
|
5
5
|
"module": "./dist/main.cjs",
|
|
6
6
|
"types": "./dist/main.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"description": "",
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^24.5.2",
|
|
25
|
-
"@wavy/types": "^0.0.
|
|
25
|
+
"@wavy/types": "^0.0.43",
|
|
26
26
|
"tsup": "^8.5.0",
|
|
27
27
|
"typescript": "^5.9.2"
|
|
28
28
|
},
|