@wavy/fn 0.0.11 → 0.0.13

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
@@ -88,6 +88,7 @@ __export(main_exports, {
88
88
  takeWhile: () => takeWhile,
89
89
  timeDuration: () => timeDuration,
90
90
  toNumber: () => toNumber,
91
+ toObject: () => ObjectConverter_default,
91
92
  trimString: () => trimString,
92
93
  undefinedIfEmpty: () => undefinedIfEmpty,
93
94
  upperFirst: () => upperFirst,
@@ -356,9 +357,12 @@ var TimeManager = class _TimeManager {
356
357
  const convertedDate = typeof time === "number" ? new Date(time) : time === "now" ? new Date(Date.now()) : time;
357
358
  let options = {};
358
359
  switch (format2) {
359
- case "HH:mm A":
360
+ case "hh:mm A":
360
361
  options = { hour: "numeric", minute: "2-digit" };
361
362
  break;
363
+ case "hh:mm:ss A":
364
+ options = { hour: "numeric", minute: "2-digit", second: "2-digit" };
365
+ break;
362
366
  case "mm/dd/yyyy":
363
367
  options = {
364
368
  year: "numeric",
@@ -366,7 +370,7 @@ var TimeManager = class _TimeManager {
366
370
  day: "2-digit"
367
371
  };
368
372
  break;
369
- case "mm/dd/yyyy HH:mm A":
373
+ case "mm/dd/yyyy hh:mm A":
370
374
  options = {
371
375
  year: "numeric",
372
376
  month: "2-digit",
@@ -392,11 +396,11 @@ var TimeManager = class _TimeManager {
392
396
  const year = this.format(convertedDate, "yyyy");
393
397
  return `${month} ${year}`;
394
398
  }
395
- if (format2 === "HH:mm A")
399
+ if (format2 === "hh:mm A" || format2 === "hh:mm:ss A")
396
400
  return takeLastWhile(fmtDate.split(""), (char) => char !== ",").join("").trim();
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
+ if (format2 === "MMM dd, yyyy | hh:mm A" || format2 === "MMM dd, yyyy at hh:mm A") {
402
+ const delimiter = format2 === "MMM dd, yyyy at hh:mm A" ? "at" : "|";
403
+ const time2 = this.format(convertedDate, "hh:mm A");
400
404
  return [fmtDate, time2].join(` ${delimiter} `);
401
405
  }
402
406
  return fmtDate;
@@ -438,7 +442,7 @@ var TimeManager = class _TimeManager {
438
442
  return fmtDuration;
439
443
  }
440
444
  getTimeOfDay() {
441
- const time = this.format("now", "HH:mm A");
445
+ const time = this.format("now", "hh:mm A");
442
446
  const amOrPm = takeLast(time.split(""), 2).join("");
443
447
  const hour = parseInt(
444
448
  takeWhile(time.split(""), (value) => value !== ":").join("")
@@ -463,7 +467,7 @@ function fileToLocalFile(file, options) {
463
467
  })()?.trim?.();
464
468
  const { name: _, size: __, ..._metadata } = file;
465
469
  return {
466
- uid: (0, import_uuid.v4)(),
470
+ uid: options?.uid || (0, import_uuid.v4)(),
467
471
  description: options?.description,
468
472
  path: options?.filepath || file?.webkitRelativePath,
469
473
  typeAlias: options?.typeAlias || run(
@@ -502,6 +506,7 @@ var Overloader = class {
502
506
  }
503
507
  };
504
508
  var toObject = new Overloader().invoke;
509
+ var ObjectConverter_default = toObject;
505
510
 
506
511
  // src/helper-functions/HelperFunctions.ts
507
512
  var dateFormat = new TimeManager_default().format;
@@ -1145,6 +1150,7 @@ var serverDataAdapter = new ServerDataAdapter().invoke;
1145
1150
  takeWhile,
1146
1151
  timeDuration,
1147
1152
  toNumber,
1153
+ toObject,
1148
1154
  trimString,
1149
1155
  undefinedIfEmpty,
1150
1156
  upperFirst,
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";
@@ -31,6 +31,18 @@ declare class StringFormatter {
31
31
  static upperFirst(value: string): string;
32
32
  }
33
33
 
34
+ declare const toObject: {
35
+ (file: File | Pick<File, "name" | "size" | "type" | "webkitRelativePath" | "lastModified">, options?: Partial<{
36
+ uid?: string;
37
+ uploadDate: number | "now";
38
+ description: string;
39
+ filepath: string;
40
+ filename: string;
41
+ typeAlias: LocalFile["typeAlias"];
42
+ }> | undefined): LocalFile;
43
+ (localFile: LocalFile): File;
44
+ };
45
+
34
46
  declare const dateFormat: (time: number | Date | "now", format?: DateFormat) => string;
35
47
  declare const timeDuration: (from: number | "now" | Date, to: number | "now" | Date, options?: {
36
48
  disableRemainder?: boolean;
@@ -171,4 +183,4 @@ declare const serverDataAdapter: {
171
183
  }>(event: "unzip", data: DataType): NormalizeFromServer<DataType>;
172
184
  };
173
185
 
174
- 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, trimString, undefinedIfEmpty, upperFirst, windowed };
186
+ 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 };
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";
@@ -31,6 +31,18 @@ declare class StringFormatter {
31
31
  static upperFirst(value: string): string;
32
32
  }
33
33
 
34
+ declare const toObject: {
35
+ (file: File | Pick<File, "name" | "size" | "type" | "webkitRelativePath" | "lastModified">, options?: Partial<{
36
+ uid?: string;
37
+ uploadDate: number | "now";
38
+ description: string;
39
+ filepath: string;
40
+ filename: string;
41
+ typeAlias: LocalFile["typeAlias"];
42
+ }> | undefined): LocalFile;
43
+ (localFile: LocalFile): File;
44
+ };
45
+
34
46
  declare const dateFormat: (time: number | Date | "now", format?: DateFormat) => string;
35
47
  declare const timeDuration: (from: number | "now" | Date, to: number | "now" | Date, options?: {
36
48
  disableRemainder?: boolean;
@@ -171,4 +183,4 @@ declare const serverDataAdapter: {
171
183
  }>(event: "unzip", data: DataType): NormalizeFromServer<DataType>;
172
184
  };
173
185
 
174
- 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, trimString, undefinedIfEmpty, upperFirst, windowed };
186
+ 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 };
package/dist/main.js CHANGED
@@ -259,9 +259,12 @@ var TimeManager = class _TimeManager {
259
259
  const convertedDate = typeof time === "number" ? new Date(time) : time === "now" ? new Date(Date.now()) : time;
260
260
  let options = {};
261
261
  switch (format2) {
262
- case "HH:mm A":
262
+ case "hh:mm A":
263
263
  options = { hour: "numeric", minute: "2-digit" };
264
264
  break;
265
+ case "hh:mm:ss A":
266
+ options = { hour: "numeric", minute: "2-digit", second: "2-digit" };
267
+ break;
265
268
  case "mm/dd/yyyy":
266
269
  options = {
267
270
  year: "numeric",
@@ -269,7 +272,7 @@ var TimeManager = class _TimeManager {
269
272
  day: "2-digit"
270
273
  };
271
274
  break;
272
- case "mm/dd/yyyy HH:mm A":
275
+ case "mm/dd/yyyy hh:mm A":
273
276
  options = {
274
277
  year: "numeric",
275
278
  month: "2-digit",
@@ -295,11 +298,11 @@ var TimeManager = class _TimeManager {
295
298
  const year = this.format(convertedDate, "yyyy");
296
299
  return `${month} ${year}`;
297
300
  }
298
- if (format2 === "HH:mm A")
301
+ if (format2 === "hh:mm A" || format2 === "hh:mm:ss A")
299
302
  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");
303
+ if (format2 === "MMM dd, yyyy | hh:mm A" || format2 === "MMM dd, yyyy at hh:mm A") {
304
+ const delimiter = format2 === "MMM dd, yyyy at hh:mm A" ? "at" : "|";
305
+ const time2 = this.format(convertedDate, "hh:mm A");
303
306
  return [fmtDate, time2].join(` ${delimiter} `);
304
307
  }
305
308
  return fmtDate;
@@ -341,7 +344,7 @@ var TimeManager = class _TimeManager {
341
344
  return fmtDuration;
342
345
  }
343
346
  getTimeOfDay() {
344
- const time = this.format("now", "HH:mm A");
347
+ const time = this.format("now", "hh:mm A");
345
348
  const amOrPm = takeLast(time.split(""), 2).join("");
346
349
  const hour = parseInt(
347
350
  takeWhile(time.split(""), (value) => value !== ":").join("")
@@ -366,7 +369,7 @@ function fileToLocalFile(file, options) {
366
369
  })()?.trim?.();
367
370
  const { name: _, size: __, ..._metadata } = file;
368
371
  return {
369
- uid: v4(),
372
+ uid: options?.uid || v4(),
370
373
  description: options?.description,
371
374
  path: options?.filepath || file?.webkitRelativePath,
372
375
  typeAlias: options?.typeAlias || run(
@@ -405,6 +408,7 @@ var Overloader = class {
405
408
  }
406
409
  };
407
410
  var toObject = new Overloader().invoke;
411
+ var ObjectConverter_default = toObject;
408
412
 
409
413
  // src/helper-functions/HelperFunctions.ts
410
414
  var dateFormat = new TimeManager_default().format;
@@ -1047,6 +1051,7 @@ export {
1047
1051
  takeWhile,
1048
1052
  timeDuration,
1049
1053
  toNumber,
1054
+ ObjectConverter_default as toObject,
1050
1055
  trimString,
1051
1056
  undefinedIfEmpty,
1052
1057
  upperFirst,
package/package.json CHANGED
@@ -1 +1,32 @@
1
- {"name":"@wavy/fn","version":"0.0.11","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.13",
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
@@ -5,27 +5,33 @@ import("child_process").then(async ({ exec }) => {
5
5
  fs.readFileSync("./package.json").toString("utf-8")
6
6
  );
7
7
  const version = jsonPackage.version;
8
- const updateVersion = () => {
9
- jsonPackage.version = version
10
- .split(".")
11
- .map((v, i, arr) => parseInt(v) + (i === arr.length - 1 ? 1 : 0))
12
- .join(".");
13
- fs.writeFileSync("./package.json", JSON.stringify(jsonPackage));
8
+ let newVersion = "";
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
+ });
14
16
  };
17
+ updateVersion();
15
18
  exec("npm run build && npm publish", async (err) => {
16
19
  const overwriteVersionError = `Cannot implicitly apply the "latest" tag because published version ${version} is higher than the new version ${version}.`;
17
- const successMessage = "✨ Successfully published package 😁! ✨";
20
+ const getSuccessMessage = (tries = 1) =>
21
+ `✨ Successfully published package (${
22
+ newVersion ? `v${version}-v${newVersion}` : `v${version}`
23
+ }) after ${tries} tries 😁! ✨`;
18
24
 
19
25
  if (err && err.message.includes(overwriteVersionError)) {
20
26
  updateVersion();
21
27
  exec("npm publish", (err) => {
22
28
  if (err) console.error(err);
23
- else console.log(successMessage);
29
+ else console.log(getSuccessMessage(2));
24
30
  });
25
31
  } else if (err) {
26
32
  console.log(err);
27
33
  } else {
28
- console.log(successMessage);
34
+ console.log(getSuccessMessage());
29
35
  }
30
36
  });
31
37
  });