@wavy/fn 0.0.15 → 0.0.17

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 CHANGED
@@ -153,14 +153,6 @@ var NumberFormatter_default = NumberFormatter;
153
153
  var ObjectFormatter = class {
154
154
  static toString = {
155
155
  name: (name) => name ? `${name.first} ${name.last}`.trim() : "no_name",
156
- phoneNumber: (phoneNumber) => {
157
- if (!phoneNumber) return "no_phone_number";
158
- return `${phoneNumber.countryCode} (${phoneNumber.areaCode}) ${insertAt(
159
- phoneNumber.localNumber.split(""),
160
- 3,
161
- "-"
162
- ).join("")}`;
163
- },
164
156
  address: (address, inline) => {
165
157
  if (address === void 0) return "no_address";
166
158
  const addressKeys = Object.keys(address).map((k) => k);
@@ -454,8 +446,8 @@ var import_uuid = require("uuid");
454
446
  var import_types = require("@wavy/types");
455
447
  var import_console = require("console");
456
448
  function fileToLocalFile(file, options) {
449
+ const fileExt = getFileExt(file.name);
457
450
  const fileName = (() => {
458
- const fileExt = getFileExt(file.name);
459
451
  if (options?.filename && options.filename.includes(fileExt))
460
452
  return options.filename;
461
453
  else if (options?.filename) return options.filename.trim() + fileExt;
@@ -465,6 +457,7 @@ function fileToLocalFile(file, options) {
465
457
  return {
466
458
  uid: options?.uid || (0, import_uuid.v4)(),
467
459
  description: options?.description,
460
+ ext: fileExt,
468
461
  path: options?.filepath || file?.webkitRelativePath,
469
462
  typeAlias: options?.typeAlias || run(
470
463
  Object.keys(import_types.LOCAL_FILE_MIME_TYPES).find(
@@ -517,7 +510,6 @@ var addArticle = StringFormatter_default.addArticle;
517
510
  var pluralize = StringFormatter_default.pluralize;
518
511
  var objToString = ObjectFormatter_default.toString;
519
512
  var nameToString = objToString.name;
520
- var phoneNoToString = objToString.phoneNumber;
521
513
  var addressToString = objToString.address;
522
514
  var toMoney = (value, options) => typeof value === "string" ? StringFormatter_default.toMoney(value, options) : NumberFormatter_default.toMoney(value, options);
523
515
  function format(event, ...args) {
@@ -533,8 +525,6 @@ function format(event, ...args) {
533
525
  return getCaller(toMoney);
534
526
  case "name":
535
527
  return getCaller(nameToString);
536
- case "phone-number":
537
- return getCaller(phoneNoToString);
538
528
  default:
539
529
  return event;
540
530
  }
@@ -563,6 +553,7 @@ function isLocalFile(value) {
563
553
  description: "",
564
554
  path: "",
565
555
  sizeInBytes: 0,
556
+ ext: "",
566
557
  typeAlias: "unknown",
567
558
  uid: "",
568
559
  uploadDate: 0,
@@ -684,17 +675,17 @@ function group(arr, isGroup) {
684
675
  return groups;
685
676
  }
686
677
  function strictArray(arr) {
687
- return arr?.filter?.(
678
+ return (arr || []).filter(
688
679
  (val) => typeof val === "string" ? val.trim().length > 0 : val !== void 0 && val !== null
689
680
  );
690
681
  }
691
682
  function maxOf(arr) {
692
- const fmtArr = strictArray(arr || []);
693
- return isEmpty(arr) ? 0 : fmtArr.reduce((prev, current) => current > prev ? current : prev);
683
+ const fmtArr = strictArray(arr);
684
+ return isEmpty(fmtArr) ? 0 : fmtArr.reduce((prev, current) => current > prev ? current : prev);
694
685
  }
695
686
  function minOf(arr) {
696
687
  const fmtArr = strictArray(arr || []);
697
- return isEmpty(arr) ? 0 : fmtArr.reduce((prev, current) => current < prev ? current : prev);
688
+ return isEmpty(fmtArr) ? 0 : fmtArr.reduce((prev, current) => current < prev ? current : prev);
698
689
  }
699
690
  function averageOf(arr) {
700
691
  const fmtArr = strictArray(arr || []);
@@ -726,7 +717,7 @@ function sort(arr, sortBy, order = "asc") {
726
717
  }
727
718
  return order === "asc" ? queryA < queryB : queryA > queryB;
728
719
  };
729
- return arr.toSorted(
720
+ return (arr || []).toSorted(
730
721
  (a, b) => sortOrder(a, b) ? -1 : queryObj(a) === queryObj(b) ? 0 : 1
731
722
  );
732
723
  }
@@ -737,7 +728,7 @@ function insertAt(arr, index, value) {
737
728
  return arr.toSpliced(index, 0, value);
738
729
  }
739
730
  function overwrite(arr, index, newValue) {
740
- return arr.with(index, newValue);
731
+ return (arr || []).with(index, newValue);
741
732
  }
742
733
  function take(value, amount) {
743
734
  return [...value].splice(0, amount);
@@ -800,7 +791,7 @@ function mapToArray(map2) {
800
791
  }
801
792
  function distinct(arr) {
802
793
  const newArr = [];
803
- arr.forEach((value) => {
794
+ (arr || []).forEach((value) => {
804
795
  if (!newArr.includes(value)) newArr.push(value);
805
796
  });
806
797
  return newArr;
@@ -896,8 +887,7 @@ function arrayWithConst(array) {
896
887
  var import_types3 = require("@wavy/types");
897
888
  var iiKeys = Object.keys({
898
889
  name: null,
899
- address: null,
900
- phoneNumber: null
890
+ address: null
901
891
  });
902
892
  var stringArrayIdPrefix = "listOf";
903
893
  var multiDimArrayIdPrefix = "2DListOf";
@@ -915,11 +905,6 @@ var INDEX_MAPPER = {
915
905
  city: 1,
916
906
  parish: 2,
917
907
  country: 3
918
- },
919
- phoneNumber: {
920
- countryCode: 0,
921
- areaCode: 1,
922
- localNumber: 2
923
908
  }
924
909
  };
925
910
  function zip(data) {
@@ -951,13 +936,6 @@ function zip(data) {
951
936
  country: "Jamaica"
952
937
  });
953
938
  break;
954
- case "phoneNumber":
955
- handleTypeMismatchError({
956
- countryCode: "1",
957
- areaCode: "876",
958
- localNumber: ""
959
- });
960
- break;
961
939
  default:
962
940
  return validKey;
963
941
  }
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,11 +59,10 @@ 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 addressToString: (address: _wavy_types.Address | undefined, inline?: boolean) => string;
62
64
  declare const toMoney: (value: string | number, options?: NumberFormatterTypes["options"]["money"]) => string;
63
- 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;
65
+ declare function format<Event extends "date" | "money" | "name" | "address">(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> : never): Event extends "date" ? ReturnType<typeof dateFormat> : Event extends "money" ? ReturnType<typeof toMoney> : Event extends "name" ? ReturnType<typeof nameToString> : Event extends "address" ? ReturnType<typeof addressToString> : never;
64
66
  declare function sanitizeLocalFile({ _metadata: _, ...file }: LocalFile): SanitizeFile<LocalFile>;
65
67
  declare function isFile(value: unknown): value is File;
66
68
  declare function isLocalFile(value: unknown): value is 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,11 +59,10 @@ 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 addressToString: (address: _wavy_types.Address | undefined, inline?: boolean) => string;
62
64
  declare const toMoney: (value: string | number, options?: NumberFormatterTypes["options"]["money"]) => string;
63
- 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;
65
+ declare function format<Event extends "date" | "money" | "name" | "address">(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> : never): Event extends "date" ? ReturnType<typeof dateFormat> : Event extends "money" ? ReturnType<typeof toMoney> : Event extends "name" ? ReturnType<typeof nameToString> : Event extends "address" ? ReturnType<typeof addressToString> : never;
64
66
  declare function sanitizeLocalFile({ _metadata: _, ...file }: LocalFile): SanitizeFile<LocalFile>;
65
67
  declare function isFile(value: unknown): value is File;
66
68
  declare function isLocalFile(value: unknown): value is LocalFile;
package/dist/main.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // src/helper-functions/HelperFunctions.ts
2
- import { LOCAL_FILE_MIME_TYPES as LOCAL_FILE_MIME_TYPES2 } from "@wavy/types";
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 {
@@ -56,14 +58,6 @@ var NumberFormatter_default = NumberFormatter;
56
58
  var ObjectFormatter = class {
57
59
  static toString = {
58
60
  name: (name) => name ? `${name.first} ${name.last}`.trim() : "no_name",
59
- phoneNumber: (phoneNumber) => {
60
- if (!phoneNumber) return "no_phone_number";
61
- return `${phoneNumber.countryCode} (${phoneNumber.areaCode}) ${insertAt(
62
- phoneNumber.localNumber.split(""),
63
- 3,
64
- "-"
65
- ).join("")}`;
66
- },
67
61
  address: (address, inline) => {
68
62
  if (address === void 0) return "no_address";
69
63
  const addressKeys = Object.keys(address).map((k) => k);
@@ -357,8 +351,8 @@ import { v4 } from "uuid";
357
351
  import { LOCAL_FILE_MIME_TYPES } from "@wavy/types";
358
352
  import { log } from "console";
359
353
  function fileToLocalFile(file, options) {
354
+ const fileExt = getFileExt(file.name);
360
355
  const fileName = (() => {
361
- const fileExt = getFileExt(file.name);
362
356
  if (options?.filename && options.filename.includes(fileExt))
363
357
  return options.filename;
364
358
  else if (options?.filename) return options.filename.trim() + fileExt;
@@ -368,6 +362,7 @@ function fileToLocalFile(file, options) {
368
362
  return {
369
363
  uid: options?.uid || v4(),
370
364
  description: options?.description,
365
+ ext: fileExt,
371
366
  path: options?.filepath || file?.webkitRelativePath,
372
367
  typeAlias: options?.typeAlias || run(
373
368
  Object.keys(LOCAL_FILE_MIME_TYPES).find(
@@ -420,7 +415,6 @@ var addArticle = StringFormatter_default.addArticle;
420
415
  var pluralize = StringFormatter_default.pluralize;
421
416
  var objToString = ObjectFormatter_default.toString;
422
417
  var nameToString = objToString.name;
423
- var phoneNoToString = objToString.phoneNumber;
424
418
  var addressToString = objToString.address;
425
419
  var toMoney = (value, options) => typeof value === "string" ? StringFormatter_default.toMoney(value, options) : NumberFormatter_default.toMoney(value, options);
426
420
  function format(event, ...args) {
@@ -436,8 +430,6 @@ function format(event, ...args) {
436
430
  return getCaller(toMoney);
437
431
  case "name":
438
432
  return getCaller(nameToString);
439
- case "phone-number":
440
- return getCaller(phoneNoToString);
441
433
  default:
442
434
  return event;
443
435
  }
@@ -466,6 +458,7 @@ function isLocalFile(value) {
466
458
  description: "",
467
459
  path: "",
468
460
  sizeInBytes: 0,
461
+ ext: "",
469
462
  typeAlias: "unknown",
470
463
  uid: "",
471
464
  uploadDate: 0,
@@ -587,17 +580,17 @@ function group(arr, isGroup) {
587
580
  return groups;
588
581
  }
589
582
  function strictArray(arr) {
590
- return arr?.filter?.(
583
+ return (arr || []).filter(
591
584
  (val) => typeof val === "string" ? val.trim().length > 0 : val !== void 0 && val !== null
592
585
  );
593
586
  }
594
587
  function maxOf(arr) {
595
- const fmtArr = strictArray(arr || []);
596
- return isEmpty(arr) ? 0 : fmtArr.reduce((prev, current) => current > prev ? current : prev);
588
+ const fmtArr = strictArray(arr);
589
+ return isEmpty(fmtArr) ? 0 : fmtArr.reduce((prev, current) => current > prev ? current : prev);
597
590
  }
598
591
  function minOf(arr) {
599
592
  const fmtArr = strictArray(arr || []);
600
- return isEmpty(arr) ? 0 : fmtArr.reduce((prev, current) => current < prev ? current : prev);
593
+ return isEmpty(fmtArr) ? 0 : fmtArr.reduce((prev, current) => current < prev ? current : prev);
601
594
  }
602
595
  function averageOf(arr) {
603
596
  const fmtArr = strictArray(arr || []);
@@ -629,7 +622,7 @@ function sort(arr, sortBy, order = "asc") {
629
622
  }
630
623
  return order === "asc" ? queryA < queryB : queryA > queryB;
631
624
  };
632
- return arr.toSorted(
625
+ return (arr || []).toSorted(
633
626
  (a, b) => sortOrder(a, b) ? -1 : queryObj(a) === queryObj(b) ? 0 : 1
634
627
  );
635
628
  }
@@ -640,7 +633,7 @@ function insertAt(arr, index, value) {
640
633
  return arr.toSpliced(index, 0, value);
641
634
  }
642
635
  function overwrite(arr, index, newValue) {
643
- return arr.with(index, newValue);
636
+ return (arr || []).with(index, newValue);
644
637
  }
645
638
  function take(value, amount) {
646
639
  return [...value].splice(0, amount);
@@ -703,7 +696,7 @@ function mapToArray(map2) {
703
696
  }
704
697
  function distinct(arr) {
705
698
  const newArr = [];
706
- arr.forEach((value) => {
699
+ (arr || []).forEach((value) => {
707
700
  if (!newArr.includes(value)) newArr.push(value);
708
701
  });
709
702
  return newArr;
@@ -799,8 +792,7 @@ function arrayWithConst(array) {
799
792
  import "@wavy/types";
800
793
  var iiKeys = Object.keys({
801
794
  name: null,
802
- address: null,
803
- phoneNumber: null
795
+ address: null
804
796
  });
805
797
  var stringArrayIdPrefix = "listOf";
806
798
  var multiDimArrayIdPrefix = "2DListOf";
@@ -818,11 +810,6 @@ var INDEX_MAPPER = {
818
810
  city: 1,
819
811
  parish: 2,
820
812
  country: 3
821
- },
822
- phoneNumber: {
823
- countryCode: 0,
824
- areaCode: 1,
825
- localNumber: 2
826
813
  }
827
814
  };
828
815
  function zip(data) {
@@ -854,13 +841,6 @@ function zip(data) {
854
841
  country: "Jamaica"
855
842
  });
856
843
  break;
857
- case "phoneNumber":
858
- handleTypeMismatchError({
859
- countryCode: "1",
860
- areaCode: "876",
861
- localNumber: ""
862
- });
863
- break;
864
844
  default:
865
845
  return validKey;
866
846
  }
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@wavy/fn",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "main": "./dist/main.js",
5
5
  "module": "./dist/main.cjs",
6
6
  "types": "./dist/main.d.ts",
7
7
  "scripts": {
8
- "build": "tsup && node prepend"
8
+ "build": "tsup && node prepend",
9
+ "success": "✨ Successfully published package! ✨",
10
+ "publisher": "npm run build && npm version patch && npm publish && npm run success"
9
11
  },
10
12
  "repository": {
11
13
  "type": "git",
@@ -22,7 +24,7 @@
22
24
  "description": "",
23
25
  "devDependencies": {
24
26
  "@types/node": "^24.5.2",
25
- "@wavy/types": "^0.0.32",
27
+ "@wavy/types": "^0.0.46",
26
28
  "tsup": "^8.5.0",
27
29
  "typescript": "^5.9.2"
28
30
  },