@wavy/fn 0.0.12 → 0.0.14

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
@@ -39,8 +39,6 @@ __export(main_exports, {
39
39
  dropLastWhile: () => dropLastWhile,
40
40
  dropWhile: () => dropWhile,
41
41
  format: () => format,
42
- formatGCTRegNo: () => formatGCTRegNo,
43
- formatInvoiceNo: () => formatInvoiceNo,
44
42
  getCaps: () => getCaps,
45
43
  getFileExt: () => getFileExt,
46
44
  getFilename: () => getFilename,
@@ -75,6 +73,7 @@ __export(main_exports, {
75
73
  removeAll: () => removeAll,
76
74
  repeat: () => repeat,
77
75
  run: () => run,
76
+ sanitizeLocalFile: () => sanitizeLocalFile,
78
77
  serverDataAdapter: () => serverDataAdapter,
79
78
  someValuesEmpty: () => someValuesEmpty,
80
79
  sort: () => sort,
@@ -279,9 +278,6 @@ var StringFormatter_default = StringFormatter;
279
278
 
280
279
  // src/helper-functions/components/time/TimeManager.ts
281
280
  var TimeManager = class _TimeManager {
282
- constructor(locale = "en-jm") {
283
- this.locale = locale;
284
- }
285
281
  static periods = {
286
282
  overview: {
287
283
  getPrevious: (period) => {
@@ -357,9 +353,12 @@ var TimeManager = class _TimeManager {
357
353
  const convertedDate = typeof time === "number" ? new Date(time) : time === "now" ? new Date(Date.now()) : time;
358
354
  let options = {};
359
355
  switch (format2) {
360
- case "HH:mm A":
356
+ case "hh:mm A":
361
357
  options = { hour: "numeric", minute: "2-digit" };
362
358
  break;
359
+ case "hh:mm:ss A":
360
+ options = { hour: "numeric", minute: "2-digit", second: "2-digit" };
361
+ break;
363
362
  case "mm/dd/yyyy":
364
363
  options = {
365
364
  year: "numeric",
@@ -367,7 +366,7 @@ var TimeManager = class _TimeManager {
367
366
  day: "2-digit"
368
367
  };
369
368
  break;
370
- case "mm/dd/yyyy HH:mm A":
369
+ case "mm/dd/yyyy hh:mm A":
371
370
  options = {
372
371
  year: "numeric",
373
372
  month: "2-digit",
@@ -384,7 +383,7 @@ var TimeManager = class _TimeManager {
384
383
  };
385
384
  break;
386
385
  }
387
- const fmtDate = convertedDate.toLocaleDateString(this.locale, options);
386
+ const fmtDate = convertedDate.toLocaleDateString(void 0, options);
388
387
  if (format2 === "MMMM")
389
388
  return takeWhile(fmtDate.split(""), (char) => char !== " ").join("");
390
389
  if (format2 === "yyyy") return takeLast(fmtDate.split(""), 4).join("");
@@ -393,11 +392,11 @@ var TimeManager = class _TimeManager {
393
392
  const year = this.format(convertedDate, "yyyy");
394
393
  return `${month} ${year}`;
395
394
  }
396
- if (format2 === "HH:mm A")
395
+ if (format2 === "hh:mm A" || format2 === "hh:mm:ss A")
397
396
  return takeLastWhile(fmtDate.split(""), (char) => char !== ",").join("").trim();
398
- if (format2 === "MMM dd, yyyy | HH:mm A" || format2 === "MMM dd, yyyy at HH:mm A") {
399
- const delimiter = format2 === "MMM dd, yyyy at HH:mm A" ? "at" : "|";
400
- const time2 = this.format(convertedDate, "HH:mm A");
397
+ if (format2 === "MMM dd, yyyy | hh:mm A" || format2 === "MMM dd, yyyy at hh:mm A") {
398
+ const delimiter = format2 === "MMM dd, yyyy at hh:mm A" ? "at" : "|";
399
+ const time2 = this.format(convertedDate, "hh:mm A");
401
400
  return [fmtDate, time2].join(` ${delimiter} `);
402
401
  }
403
402
  return fmtDate;
@@ -439,7 +438,7 @@ var TimeManager = class _TimeManager {
439
438
  return fmtDuration;
440
439
  }
441
440
  getTimeOfDay() {
442
- const time = this.format("now", "HH:mm A");
441
+ const time = this.format("now", "hh:mm A");
443
442
  const amOrPm = takeLast(time.split(""), 2).join("");
444
443
  const hour = parseInt(
445
444
  takeWhile(time.split(""), (value) => value !== ":").join("")
@@ -464,7 +463,7 @@ function fileToLocalFile(file, options) {
464
463
  })()?.trim?.();
465
464
  const { name: _, size: __, ..._metadata } = file;
466
465
  return {
467
- uid: (0, import_uuid.v4)(),
466
+ uid: options?.uid || (0, import_uuid.v4)(),
468
467
  description: options?.description,
469
468
  path: options?.filepath || file?.webkitRelativePath,
470
469
  typeAlias: options?.typeAlias || run(
@@ -540,6 +539,12 @@ function format(event, ...args) {
540
539
  return event;
541
540
  }
542
541
  }
542
+ function sanitizeLocalFile({
543
+ _metadata: _,
544
+ ...file
545
+ }) {
546
+ return file;
547
+ }
543
548
  function isFile(value) {
544
549
  const requiredKeys = [
545
550
  "name",
@@ -614,12 +619,6 @@ function indexOf(arr, key, value) {
614
619
  if (!queriedValue) return;
615
620
  return arr.indexOf(queriedValue);
616
621
  }
617
- function formatInvoiceNo(invoiceNo) {
618
- return `INV-${invoiceNo}`;
619
- }
620
- function formatGCTRegNo(regNo) {
621
- return `GCT-${regNo}`;
622
- }
623
622
  function indices(arr) {
624
623
  return arr.map((_, idx) => idx);
625
624
  }
@@ -632,10 +631,12 @@ function repeat(count2, func) {
632
631
  }
633
632
  }
634
633
  function isLetter(value) {
635
- return "abcdefghijklmnopqrstuvwxyz".includes(value.toLowerCase());
634
+ if (value.length !== 1)
635
+ throw new Error(`Expected a single character but ${value} was provided.`);
636
+ return /[a-zA-A]/.test(value);
636
637
  }
637
638
  function isNumber(value) {
638
- return "0123456789".includes(value);
639
+ return !!parseFloat(value);
639
640
  }
640
641
  function count(searchFor, arrayish) {
641
642
  const fmtArr = typeof arrayish === "string" ? arrayish.split("") : arrayish;
@@ -1098,8 +1099,6 @@ var serverDataAdapter = new ServerDataAdapter().invoke;
1098
1099
  dropLastWhile,
1099
1100
  dropWhile,
1100
1101
  format,
1101
- formatGCTRegNo,
1102
- formatInvoiceNo,
1103
1102
  getCaps,
1104
1103
  getFileExt,
1105
1104
  getFilename,
@@ -1134,6 +1133,7 @@ var serverDataAdapter = new ServerDataAdapter().invoke;
1134
1133
  removeAll,
1135
1134
  repeat,
1136
1135
  run,
1136
+ sanitizeLocalFile,
1137
1137
  serverDataAdapter,
1138
1138
  someValuesEmpty,
1139
1139
  sort,
package/dist/main.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import "@wavy/types"
2
- 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";
2
+ 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
3
 
4
4
  type NumberFormatterTypes = {
5
5
  formats: "money";
@@ -33,6 +33,7 @@ declare class StringFormatter {
33
33
 
34
34
  declare const toObject: {
35
35
  (file: File | Pick<File, "name" | "size" | "type" | "webkitRelativePath" | "lastModified">, options?: Partial<{
36
+ uid?: string;
36
37
  uploadDate: number | "now";
37
38
  description: string;
38
39
  filepath: string;
@@ -60,6 +61,7 @@ declare const phoneNoToString: (phoneNumber: PhoneNumber | undefined) => string;
60
61
  declare const addressToString: (address: Address | undefined, inline?: boolean) => string;
61
62
  declare const toMoney: (value: string | number, options?: NumberFormatterTypes["options"]["money"]) => string;
62
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;
64
+ declare function sanitizeLocalFile({ _metadata: _, ...file }: LocalFile): SanitizeFile<LocalFile>;
63
65
  declare function isFile(value: unknown): value is File;
64
66
  declare function isLocalFile(value: unknown): value is LocalFile;
65
67
  declare function getMimeTypes(typeAliases: KnownFileTypeAlias[]): string[];
@@ -80,8 +82,6 @@ declare function ordinalIndicator(amount: number): string;
80
82
  *
81
83
  */
82
84
  declare function indexOf<O extends object, K extends keyof O>(arr: O[], key: K, value: O[K]): number | undefined;
83
- declare function formatInvoiceNo(invoiceNo: string): string;
84
- declare function formatGCTRegNo(regNo: string): string;
85
85
  declare function indices(arr: unknown[]): number[];
86
86
  declare function hasIndex(arr: unknown[], index: number): boolean;
87
87
  declare function repeat<T>(count: number, func: (idx: number) => T): void;
@@ -182,4 +182,4 @@ declare const serverDataAdapter: {
182
182
  }>(event: "unzip", data: DataType): NormalizeFromServer<DataType>;
183
183
  };
184
184
 
185
- export { addArticle, arrayWithConst, asyncRun, averageOf, blankSpaces, buildArray, camelCaseToLetter, classNameExt, classNameResolver, coerceIn, copyToClipboard, count, dataSearcher, distinct, drop, dropLast, dropLastWhile, dropWhile, format, formatGCTRegNo, formatInvoiceNo, 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, serverDataAdapter, someValuesEmpty, sort, strictArray, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, toObject, trimString, undefinedIfEmpty, upperFirst, windowed };
185
+ 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 };
package/dist/main.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import "@wavy/types"
2
- 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";
2
+ 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
3
 
4
4
  type NumberFormatterTypes = {
5
5
  formats: "money";
@@ -33,6 +33,7 @@ declare class StringFormatter {
33
33
 
34
34
  declare const toObject: {
35
35
  (file: File | Pick<File, "name" | "size" | "type" | "webkitRelativePath" | "lastModified">, options?: Partial<{
36
+ uid?: string;
36
37
  uploadDate: number | "now";
37
38
  description: string;
38
39
  filepath: string;
@@ -60,6 +61,7 @@ declare const phoneNoToString: (phoneNumber: PhoneNumber | undefined) => string;
60
61
  declare const addressToString: (address: Address | undefined, inline?: boolean) => string;
61
62
  declare const toMoney: (value: string | number, options?: NumberFormatterTypes["options"]["money"]) => string;
62
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;
64
+ declare function sanitizeLocalFile({ _metadata: _, ...file }: LocalFile): SanitizeFile<LocalFile>;
63
65
  declare function isFile(value: unknown): value is File;
64
66
  declare function isLocalFile(value: unknown): value is LocalFile;
65
67
  declare function getMimeTypes(typeAliases: KnownFileTypeAlias[]): string[];
@@ -80,8 +82,6 @@ declare function ordinalIndicator(amount: number): string;
80
82
  *
81
83
  */
82
84
  declare function indexOf<O extends object, K extends keyof O>(arr: O[], key: K, value: O[K]): number | undefined;
83
- declare function formatInvoiceNo(invoiceNo: string): string;
84
- declare function formatGCTRegNo(regNo: string): string;
85
85
  declare function indices(arr: unknown[]): number[];
86
86
  declare function hasIndex(arr: unknown[], index: number): boolean;
87
87
  declare function repeat<T>(count: number, func: (idx: number) => T): void;
@@ -182,4 +182,4 @@ declare const serverDataAdapter: {
182
182
  }>(event: "unzip", data: DataType): NormalizeFromServer<DataType>;
183
183
  };
184
184
 
185
- export { addArticle, arrayWithConst, asyncRun, averageOf, blankSpaces, buildArray, camelCaseToLetter, classNameExt, classNameResolver, coerceIn, copyToClipboard, count, dataSearcher, distinct, drop, dropLast, dropLastWhile, dropWhile, format, formatGCTRegNo, formatInvoiceNo, 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, serverDataAdapter, someValuesEmpty, sort, strictArray, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, toObject, trimString, undefinedIfEmpty, upperFirst, windowed };
185
+ 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 };
package/dist/main.js CHANGED
@@ -181,9 +181,6 @@ var StringFormatter_default = StringFormatter;
181
181
 
182
182
  // src/helper-functions/components/time/TimeManager.ts
183
183
  var TimeManager = class _TimeManager {
184
- constructor(locale = "en-jm") {
185
- this.locale = locale;
186
- }
187
184
  static periods = {
188
185
  overview: {
189
186
  getPrevious: (period) => {
@@ -259,9 +256,12 @@ var TimeManager = class _TimeManager {
259
256
  const convertedDate = typeof time === "number" ? new Date(time) : time === "now" ? new Date(Date.now()) : time;
260
257
  let options = {};
261
258
  switch (format2) {
262
- case "HH:mm A":
259
+ case "hh:mm A":
263
260
  options = { hour: "numeric", minute: "2-digit" };
264
261
  break;
262
+ case "hh:mm:ss A":
263
+ options = { hour: "numeric", minute: "2-digit", second: "2-digit" };
264
+ break;
265
265
  case "mm/dd/yyyy":
266
266
  options = {
267
267
  year: "numeric",
@@ -269,7 +269,7 @@ var TimeManager = class _TimeManager {
269
269
  day: "2-digit"
270
270
  };
271
271
  break;
272
- case "mm/dd/yyyy HH:mm A":
272
+ case "mm/dd/yyyy hh:mm A":
273
273
  options = {
274
274
  year: "numeric",
275
275
  month: "2-digit",
@@ -286,7 +286,7 @@ var TimeManager = class _TimeManager {
286
286
  };
287
287
  break;
288
288
  }
289
- const fmtDate = convertedDate.toLocaleDateString(this.locale, options);
289
+ const fmtDate = convertedDate.toLocaleDateString(void 0, options);
290
290
  if (format2 === "MMMM")
291
291
  return takeWhile(fmtDate.split(""), (char) => char !== " ").join("");
292
292
  if (format2 === "yyyy") return takeLast(fmtDate.split(""), 4).join("");
@@ -295,11 +295,11 @@ var TimeManager = class _TimeManager {
295
295
  const year = this.format(convertedDate, "yyyy");
296
296
  return `${month} ${year}`;
297
297
  }
298
- if (format2 === "HH:mm A")
298
+ if (format2 === "hh:mm A" || format2 === "hh:mm:ss A")
299
299
  return takeLastWhile(fmtDate.split(""), (char) => char !== ",").join("").trim();
300
- if (format2 === "MMM dd, yyyy | HH:mm A" || format2 === "MMM dd, yyyy at HH:mm A") {
301
- const delimiter = format2 === "MMM dd, yyyy at HH:mm A" ? "at" : "|";
302
- const time2 = this.format(convertedDate, "HH:mm A");
300
+ if (format2 === "MMM dd, yyyy | hh:mm A" || format2 === "MMM dd, yyyy at hh:mm A") {
301
+ const delimiter = format2 === "MMM dd, yyyy at hh:mm A" ? "at" : "|";
302
+ const time2 = this.format(convertedDate, "hh:mm A");
303
303
  return [fmtDate, time2].join(` ${delimiter} `);
304
304
  }
305
305
  return fmtDate;
@@ -341,7 +341,7 @@ var TimeManager = class _TimeManager {
341
341
  return fmtDuration;
342
342
  }
343
343
  getTimeOfDay() {
344
- const time = this.format("now", "HH:mm A");
344
+ const time = this.format("now", "hh:mm A");
345
345
  const amOrPm = takeLast(time.split(""), 2).join("");
346
346
  const hour = parseInt(
347
347
  takeWhile(time.split(""), (value) => value !== ":").join("")
@@ -366,7 +366,7 @@ function fileToLocalFile(file, options) {
366
366
  })()?.trim?.();
367
367
  const { name: _, size: __, ..._metadata } = file;
368
368
  return {
369
- uid: v4(),
369
+ uid: options?.uid || v4(),
370
370
  description: options?.description,
371
371
  path: options?.filepath || file?.webkitRelativePath,
372
372
  typeAlias: options?.typeAlias || run(
@@ -442,6 +442,12 @@ function format(event, ...args) {
442
442
  return event;
443
443
  }
444
444
  }
445
+ function sanitizeLocalFile({
446
+ _metadata: _,
447
+ ...file
448
+ }) {
449
+ return file;
450
+ }
445
451
  function isFile(value) {
446
452
  const requiredKeys = [
447
453
  "name",
@@ -516,12 +522,6 @@ function indexOf(arr, key, value) {
516
522
  if (!queriedValue) return;
517
523
  return arr.indexOf(queriedValue);
518
524
  }
519
- function formatInvoiceNo(invoiceNo) {
520
- return `INV-${invoiceNo}`;
521
- }
522
- function formatGCTRegNo(regNo) {
523
- return `GCT-${regNo}`;
524
- }
525
525
  function indices(arr) {
526
526
  return arr.map((_, idx) => idx);
527
527
  }
@@ -534,10 +534,12 @@ function repeat(count2, func) {
534
534
  }
535
535
  }
536
536
  function isLetter(value) {
537
- return "abcdefghijklmnopqrstuvwxyz".includes(value.toLowerCase());
537
+ if (value.length !== 1)
538
+ throw new Error(`Expected a single character but ${value} was provided.`);
539
+ return /[a-zA-A]/.test(value);
538
540
  }
539
541
  function isNumber(value) {
540
- return "0123456789".includes(value);
542
+ return !!parseFloat(value);
541
543
  }
542
544
  function count(searchFor, arrayish) {
543
545
  const fmtArr = typeof arrayish === "string" ? arrayish.split("") : arrayish;
@@ -999,8 +1001,6 @@ export {
999
1001
  dropLastWhile,
1000
1002
  dropWhile,
1001
1003
  format,
1002
- formatGCTRegNo,
1003
- formatInvoiceNo,
1004
1004
  getCaps,
1005
1005
  getFileExt,
1006
1006
  getFilename,
@@ -1035,6 +1035,7 @@ export {
1035
1035
  removeAll,
1036
1036
  repeat,
1037
1037
  run,
1038
+ sanitizeLocalFile,
1038
1039
  serverDataAdapter,
1039
1040
  someValuesEmpty,
1040
1041
  sort,
package/package.json CHANGED
@@ -1 +1,32 @@
1
- {"name":"@wavy/fn","version":"0.0.12","main":"./dist/main.js","module":"./dist/main.cjs","types":"./dist/main.d.ts","scripts":{"build":"tsup && node prepend"},"repository":{"type":"git","url":"git+https://github.com/justVibes/literate-succotash.git"},"keywords":[],"author":"","license":"MIT","type":"module","bugs":{"url":"https://github.com/justVibes/literate-succotash/issues"},"homepage":"https://github.com/justVibes/literate-succotash#readme","description":"","devDependencies":{"@types/node":"^24.5.2","@wavy/types":"^0.0.32","tsup":"^8.5.0","typescript":"^5.9.2"}}
1
+ {
2
+ "name": "@wavy/fn",
3
+ "version": "0.0.14",
4
+ "main": "./dist/main.js",
5
+ "module": "./dist/main.cjs",
6
+ "types": "./dist/main.d.ts",
7
+ "scripts": {
8
+ "build": "tsup && node prepend"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/justVibes/literate-succotash.git"
13
+ },
14
+ "keywords": [],
15
+ "author": "",
16
+ "license": "MIT",
17
+ "type": "module",
18
+ "bugs": {
19
+ "url": "https://github.com/justVibes/literate-succotash/issues"
20
+ },
21
+ "homepage": "https://github.com/justVibes/literate-succotash#readme",
22
+ "description": "",
23
+ "devDependencies": {
24
+ "@types/node": "^24.5.2",
25
+ "@wavy/types": "^0.0.32",
26
+ "tsup": "^8.5.0",
27
+ "typescript": "^5.9.2"
28
+ },
29
+ "dependencies": {
30
+ "uuid": "^13.0.0"
31
+ }
32
+ }
package/publish.js CHANGED
@@ -6,15 +6,15 @@ import("child_process").then(async ({ exec }) => {
6
6
  );
7
7
  const version = jsonPackage.version;
8
8
  let newVersion = "";
9
- const updateVersion = () => {
10
- jsonPackage.version = version
11
- .split(".")
12
- .map((v, i, arr) => parseInt(v) + (i === arr.length - 1 ? 1 : 0))
13
- .join(".");
14
- newVersion = jsonPackage.version;
15
-
16
- fs.writeFileSync("./package.json", JSON.stringify(jsonPackage));
9
+ const updateVersion = async () => {
10
+ return new Promise((res, rej) => {
11
+ exec("npm version patch", (err, stdout, stderr) => {
12
+ if (err) rej(err);
13
+ res({ stdout, stderr });
14
+ });
15
+ });
17
16
  };
17
+ updateVersion();
18
18
  exec("npm run build && npm publish", async (err) => {
19
19
  const overwriteVersionError = `Cannot implicitly apply the "latest" tag because published version ${version} is higher than the new version ${version}.`;
20
20
  const getSuccessMessage = (tries = 1) =>