@wavy/fn 0.0.17 → 0.0.18
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 +87 -56
- package/dist/main.d.cts +13 -13
- package/dist/main.d.ts +13 -13
- package/dist/main.js +87 -56
- package/package.json +2 -2
package/dist/main.cjs
CHANGED
|
@@ -98,6 +98,91 @@ module.exports = __toCommonJS(main_exports);
|
|
|
98
98
|
// src/helper-functions/HelperFunctions.ts
|
|
99
99
|
var import_types2 = require("@wavy/types");
|
|
100
100
|
|
|
101
|
+
// src/helper-functions/components/ObjectConverter.ts
|
|
102
|
+
var import_uuid = require("uuid");
|
|
103
|
+
var import_types = require("@wavy/types");
|
|
104
|
+
var import_console = require("console");
|
|
105
|
+
function fileToLocalFile(file, options) {
|
|
106
|
+
const fileExt = getFileExt(file.name);
|
|
107
|
+
const fileName = (() => {
|
|
108
|
+
if (options?.filename && options.filename.includes(fileExt))
|
|
109
|
+
return options.filename;
|
|
110
|
+
else if (options?.filename) return options.filename.trim() + fileExt;
|
|
111
|
+
return file.name;
|
|
112
|
+
})()?.trim?.();
|
|
113
|
+
const { name: _, size: __, ..._metadata } = file;
|
|
114
|
+
return {
|
|
115
|
+
uid: options?.uid || (0, import_uuid.v4)(),
|
|
116
|
+
description: options?.description,
|
|
117
|
+
ext: fileExt,
|
|
118
|
+
path: options?.filepath || file?.webkitRelativePath,
|
|
119
|
+
typeAlias: options?.typeAlias || run(
|
|
120
|
+
Object.keys(import_types.LOCAL_FILE_MIME_TYPES).find(
|
|
121
|
+
(key) => import_types.LOCAL_FILE_MIME_TYPES[key].includes(file.type)
|
|
122
|
+
),
|
|
123
|
+
(type) => {
|
|
124
|
+
if (!type) {
|
|
125
|
+
(0, import_console.log)("An unknown file type was found ", file.type);
|
|
126
|
+
return "unknown";
|
|
127
|
+
}
|
|
128
|
+
return type;
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
sizeInBytes: file.size,
|
|
132
|
+
uploadDate: options?.uploadDate === "now" ? Date.now() : options?.uploadDate ?? file?.lastModified,
|
|
133
|
+
name: fileName,
|
|
134
|
+
_metadata
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function localFileToFile(localFile) {
|
|
138
|
+
return {
|
|
139
|
+
name: localFile.name,
|
|
140
|
+
size: localFile.sizeInBytes,
|
|
141
|
+
...localFile._metadata
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
var Overloader = class {
|
|
145
|
+
invoke(...args) {
|
|
146
|
+
if (isFile(args[0])) {
|
|
147
|
+
return fileToLocalFile(...args);
|
|
148
|
+
}
|
|
149
|
+
if (isLocalFile(args[0])) {
|
|
150
|
+
return localFileToFile(...args);
|
|
151
|
+
} else throw new Error(`The arguments supplied are insufficient.`);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var toObject = new Overloader().invoke;
|
|
155
|
+
var ObjectConverter_default = toObject;
|
|
156
|
+
|
|
157
|
+
// src/helper-functions/components/formatter/FileSizeFormatter.ts
|
|
158
|
+
var FileSizeFormatter = class {
|
|
159
|
+
constructor(bytes) {
|
|
160
|
+
this.bytes = bytes;
|
|
161
|
+
}
|
|
162
|
+
bytes;
|
|
163
|
+
toKb() {
|
|
164
|
+
return { amount: this.scaleUp(this.bytes), unit: "KB" };
|
|
165
|
+
}
|
|
166
|
+
toMb() {
|
|
167
|
+
return { amount: this.scaleUp(this.toKb().amount), unit: "MB" };
|
|
168
|
+
}
|
|
169
|
+
toGb() {
|
|
170
|
+
return { amount: this.scaleUp(this.toMb().amount), unit: "GB" };
|
|
171
|
+
}
|
|
172
|
+
toTb() {
|
|
173
|
+
return { amount: this.scaleUp(this.toGb().amount), unit: "TB" };
|
|
174
|
+
}
|
|
175
|
+
format() {
|
|
176
|
+
const size = [this.toTb(), this.toGb(), this.toMb(), this.toKb()].map(
|
|
177
|
+
(size2) => ({ ...size2, amount: Math.floor(size2.amount) })
|
|
178
|
+
).find((size2) => size2.amount >= 1);
|
|
179
|
+
return size ? `${size.amount} ${size.unit}` : `${this.bytes} B`;
|
|
180
|
+
}
|
|
181
|
+
scaleUp(bytes) {
|
|
182
|
+
return bytes / 1e3;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
101
186
|
// src/helper-functions/components/formatter/number/NumberFormatter.ts
|
|
102
187
|
var NumberFormatter = class _NumberFormatter {
|
|
103
188
|
static format(value, format2, options) {
|
|
@@ -441,62 +526,6 @@ var TimeManager = class _TimeManager {
|
|
|
441
526
|
};
|
|
442
527
|
var TimeManager_default = TimeManager;
|
|
443
528
|
|
|
444
|
-
// src/helper-functions/components/ObjectConverter.ts
|
|
445
|
-
var import_uuid = require("uuid");
|
|
446
|
-
var import_types = require("@wavy/types");
|
|
447
|
-
var import_console = require("console");
|
|
448
|
-
function fileToLocalFile(file, options) {
|
|
449
|
-
const fileExt = getFileExt(file.name);
|
|
450
|
-
const fileName = (() => {
|
|
451
|
-
if (options?.filename && options.filename.includes(fileExt))
|
|
452
|
-
return options.filename;
|
|
453
|
-
else if (options?.filename) return options.filename.trim() + fileExt;
|
|
454
|
-
return file.name;
|
|
455
|
-
})()?.trim?.();
|
|
456
|
-
const { name: _, size: __, ..._metadata } = file;
|
|
457
|
-
return {
|
|
458
|
-
uid: options?.uid || (0, import_uuid.v4)(),
|
|
459
|
-
description: options?.description,
|
|
460
|
-
ext: fileExt,
|
|
461
|
-
path: options?.filepath || file?.webkitRelativePath,
|
|
462
|
-
typeAlias: options?.typeAlias || run(
|
|
463
|
-
Object.keys(import_types.LOCAL_FILE_MIME_TYPES).find(
|
|
464
|
-
(key) => import_types.LOCAL_FILE_MIME_TYPES[key].includes(file.type)
|
|
465
|
-
),
|
|
466
|
-
(type) => {
|
|
467
|
-
if (!type) {
|
|
468
|
-
(0, import_console.log)("An unknown file type was found ", file.type);
|
|
469
|
-
return "unknown";
|
|
470
|
-
}
|
|
471
|
-
return type;
|
|
472
|
-
}
|
|
473
|
-
),
|
|
474
|
-
sizeInBytes: file.size,
|
|
475
|
-
uploadDate: options?.uploadDate === "now" ? Date.now() : options?.uploadDate ?? file?.lastModified,
|
|
476
|
-
name: fileName,
|
|
477
|
-
_metadata
|
|
478
|
-
};
|
|
479
|
-
}
|
|
480
|
-
function localFileToFile(localFile) {
|
|
481
|
-
return {
|
|
482
|
-
name: localFile.name,
|
|
483
|
-
size: localFile.sizeInBytes,
|
|
484
|
-
...localFile._metadata
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
|
-
var Overloader = class {
|
|
488
|
-
invoke(...args) {
|
|
489
|
-
if (isFile(args[0])) {
|
|
490
|
-
return fileToLocalFile(...args);
|
|
491
|
-
}
|
|
492
|
-
if (isLocalFile(args[0])) {
|
|
493
|
-
return localFileToFile(...args);
|
|
494
|
-
} else throw new Error(`The arguments supplied are insufficient.`);
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
var toObject = new Overloader().invoke;
|
|
498
|
-
var ObjectConverter_default = toObject;
|
|
499
|
-
|
|
500
529
|
// src/helper-functions/HelperFunctions.ts
|
|
501
530
|
var dateFormat = new TimeManager_default().format;
|
|
502
531
|
var timeDuration = new TimeManager_default().getDuration;
|
|
@@ -525,6 +554,8 @@ function format(event, ...args) {
|
|
|
525
554
|
return getCaller(toMoney);
|
|
526
555
|
case "name":
|
|
527
556
|
return getCaller(nameToString);
|
|
557
|
+
case "file-size":
|
|
558
|
+
return new FileSizeFormatter(args[0]).format();
|
|
528
559
|
default:
|
|
529
560
|
return event;
|
|
530
561
|
}
|
package/dist/main.d.cts
CHANGED
|
@@ -4,6 +4,18 @@ import { LocalFile, SanitizeFile, KnownFileTypeAlias, TaskResult, FromServer, No
|
|
|
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
|
|
|
7
|
+
declare const toObject: {
|
|
8
|
+
(file: File | Pick<File, "size" | "name" | "type" | "webkitRelativePath" | "lastModified">, options?: Partial<{
|
|
9
|
+
uid?: string;
|
|
10
|
+
uploadDate: number | "now";
|
|
11
|
+
description: string;
|
|
12
|
+
filepath: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
typeAlias: LocalFile["typeAlias"];
|
|
15
|
+
}> | undefined): LocalFile;
|
|
16
|
+
(localFile: LocalFile): File;
|
|
17
|
+
};
|
|
18
|
+
|
|
7
19
|
type NumberFormatterTypes = {
|
|
8
20
|
formats: "money";
|
|
9
21
|
options: {
|
|
@@ -34,18 +46,6 @@ declare class StringFormatter {
|
|
|
34
46
|
static upperFirst(value: string): string;
|
|
35
47
|
}
|
|
36
48
|
|
|
37
|
-
declare const toObject: {
|
|
38
|
-
(file: File | Pick<File, "name" | "size" | "type" | "webkitRelativePath" | "lastModified">, options?: Partial<{
|
|
39
|
-
uid?: string;
|
|
40
|
-
uploadDate: number | "now";
|
|
41
|
-
description: string;
|
|
42
|
-
filepath: string;
|
|
43
|
-
filename: string;
|
|
44
|
-
typeAlias: LocalFile["typeAlias"];
|
|
45
|
-
}> | undefined): LocalFile;
|
|
46
|
-
(localFile: LocalFile): File;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
49
|
declare const dateFormat: (time: number | Date | "now", format?: DateFormat) => string;
|
|
50
50
|
declare const timeDuration: (from: number | "now" | Date, to: number | "now" | Date, options?: {
|
|
51
51
|
disableRemainder?: boolean;
|
|
@@ -62,7 +62,7 @@ declare const pluralize: typeof StringFormatter.pluralize;
|
|
|
62
62
|
declare const nameToString: (name: _wavy_types.Name | undefined) => string;
|
|
63
63
|
declare const addressToString: (address: _wavy_types.Address | undefined, inline?: boolean) => string;
|
|
64
64
|
declare const toMoney: (value: string | number, options?: NumberFormatterTypes["options"]["money"]) => string;
|
|
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> :
|
|
65
|
+
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;
|
|
66
66
|
declare function sanitizeLocalFile({ _metadata: _, ...file }: LocalFile): SanitizeFile<LocalFile>;
|
|
67
67
|
declare function isFile(value: unknown): value is File;
|
|
68
68
|
declare function isLocalFile(value: unknown): value is LocalFile;
|
package/dist/main.d.ts
CHANGED
|
@@ -4,6 +4,18 @@ import { LocalFile, SanitizeFile, KnownFileTypeAlias, TaskResult, FromServer, No
|
|
|
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
|
|
|
7
|
+
declare const toObject: {
|
|
8
|
+
(file: File | Pick<File, "size" | "name" | "type" | "webkitRelativePath" | "lastModified">, options?: Partial<{
|
|
9
|
+
uid?: string;
|
|
10
|
+
uploadDate: number | "now";
|
|
11
|
+
description: string;
|
|
12
|
+
filepath: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
typeAlias: LocalFile["typeAlias"];
|
|
15
|
+
}> | undefined): LocalFile;
|
|
16
|
+
(localFile: LocalFile): File;
|
|
17
|
+
};
|
|
18
|
+
|
|
7
19
|
type NumberFormatterTypes = {
|
|
8
20
|
formats: "money";
|
|
9
21
|
options: {
|
|
@@ -34,18 +46,6 @@ declare class StringFormatter {
|
|
|
34
46
|
static upperFirst(value: string): string;
|
|
35
47
|
}
|
|
36
48
|
|
|
37
|
-
declare const toObject: {
|
|
38
|
-
(file: File | Pick<File, "name" | "size" | "type" | "webkitRelativePath" | "lastModified">, options?: Partial<{
|
|
39
|
-
uid?: string;
|
|
40
|
-
uploadDate: number | "now";
|
|
41
|
-
description: string;
|
|
42
|
-
filepath: string;
|
|
43
|
-
filename: string;
|
|
44
|
-
typeAlias: LocalFile["typeAlias"];
|
|
45
|
-
}> | undefined): LocalFile;
|
|
46
|
-
(localFile: LocalFile): File;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
49
|
declare const dateFormat: (time: number | Date | "now", format?: DateFormat) => string;
|
|
50
50
|
declare const timeDuration: (from: number | "now" | Date, to: number | "now" | Date, options?: {
|
|
51
51
|
disableRemainder?: boolean;
|
|
@@ -62,7 +62,7 @@ declare const pluralize: typeof StringFormatter.pluralize;
|
|
|
62
62
|
declare const nameToString: (name: _wavy_types.Name | undefined) => string;
|
|
63
63
|
declare const addressToString: (address: _wavy_types.Address | undefined, inline?: boolean) => string;
|
|
64
64
|
declare const toMoney: (value: string | number, options?: NumberFormatterTypes["options"]["money"]) => string;
|
|
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> :
|
|
65
|
+
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;
|
|
66
66
|
declare function sanitizeLocalFile({ _metadata: _, ...file }: LocalFile): SanitizeFile<LocalFile>;
|
|
67
67
|
declare function isFile(value: unknown): value is File;
|
|
68
68
|
declare function isLocalFile(value: unknown): value is LocalFile;
|
package/dist/main.js
CHANGED
|
@@ -3,6 +3,91 @@ import {
|
|
|
3
3
|
LOCAL_FILE_MIME_TYPES as LOCAL_FILE_MIME_TYPES2
|
|
4
4
|
} from "@wavy/types";
|
|
5
5
|
|
|
6
|
+
// src/helper-functions/components/ObjectConverter.ts
|
|
7
|
+
import { v4 } from "uuid";
|
|
8
|
+
import { LOCAL_FILE_MIME_TYPES } from "@wavy/types";
|
|
9
|
+
import { log } from "console";
|
|
10
|
+
function fileToLocalFile(file, options) {
|
|
11
|
+
const fileExt = getFileExt(file.name);
|
|
12
|
+
const fileName = (() => {
|
|
13
|
+
if (options?.filename && options.filename.includes(fileExt))
|
|
14
|
+
return options.filename;
|
|
15
|
+
else if (options?.filename) return options.filename.trim() + fileExt;
|
|
16
|
+
return file.name;
|
|
17
|
+
})()?.trim?.();
|
|
18
|
+
const { name: _, size: __, ..._metadata } = file;
|
|
19
|
+
return {
|
|
20
|
+
uid: options?.uid || v4(),
|
|
21
|
+
description: options?.description,
|
|
22
|
+
ext: fileExt,
|
|
23
|
+
path: options?.filepath || file?.webkitRelativePath,
|
|
24
|
+
typeAlias: options?.typeAlias || run(
|
|
25
|
+
Object.keys(LOCAL_FILE_MIME_TYPES).find(
|
|
26
|
+
(key) => LOCAL_FILE_MIME_TYPES[key].includes(file.type)
|
|
27
|
+
),
|
|
28
|
+
(type) => {
|
|
29
|
+
if (!type) {
|
|
30
|
+
log("An unknown file type was found ", file.type);
|
|
31
|
+
return "unknown";
|
|
32
|
+
}
|
|
33
|
+
return type;
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
sizeInBytes: file.size,
|
|
37
|
+
uploadDate: options?.uploadDate === "now" ? Date.now() : options?.uploadDate ?? file?.lastModified,
|
|
38
|
+
name: fileName,
|
|
39
|
+
_metadata
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function localFileToFile(localFile) {
|
|
43
|
+
return {
|
|
44
|
+
name: localFile.name,
|
|
45
|
+
size: localFile.sizeInBytes,
|
|
46
|
+
...localFile._metadata
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
var Overloader = class {
|
|
50
|
+
invoke(...args) {
|
|
51
|
+
if (isFile(args[0])) {
|
|
52
|
+
return fileToLocalFile(...args);
|
|
53
|
+
}
|
|
54
|
+
if (isLocalFile(args[0])) {
|
|
55
|
+
return localFileToFile(...args);
|
|
56
|
+
} else throw new Error(`The arguments supplied are insufficient.`);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var toObject = new Overloader().invoke;
|
|
60
|
+
var ObjectConverter_default = toObject;
|
|
61
|
+
|
|
62
|
+
// src/helper-functions/components/formatter/FileSizeFormatter.ts
|
|
63
|
+
var FileSizeFormatter = class {
|
|
64
|
+
constructor(bytes) {
|
|
65
|
+
this.bytes = bytes;
|
|
66
|
+
}
|
|
67
|
+
bytes;
|
|
68
|
+
toKb() {
|
|
69
|
+
return { amount: this.scaleUp(this.bytes), unit: "KB" };
|
|
70
|
+
}
|
|
71
|
+
toMb() {
|
|
72
|
+
return { amount: this.scaleUp(this.toKb().amount), unit: "MB" };
|
|
73
|
+
}
|
|
74
|
+
toGb() {
|
|
75
|
+
return { amount: this.scaleUp(this.toMb().amount), unit: "GB" };
|
|
76
|
+
}
|
|
77
|
+
toTb() {
|
|
78
|
+
return { amount: this.scaleUp(this.toGb().amount), unit: "TB" };
|
|
79
|
+
}
|
|
80
|
+
format() {
|
|
81
|
+
const size = [this.toTb(), this.toGb(), this.toMb(), this.toKb()].map(
|
|
82
|
+
(size2) => ({ ...size2, amount: Math.floor(size2.amount) })
|
|
83
|
+
).find((size2) => size2.amount >= 1);
|
|
84
|
+
return size ? `${size.amount} ${size.unit}` : `${this.bytes} B`;
|
|
85
|
+
}
|
|
86
|
+
scaleUp(bytes) {
|
|
87
|
+
return bytes / 1e3;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
6
91
|
// src/helper-functions/components/formatter/number/NumberFormatter.ts
|
|
7
92
|
var NumberFormatter = class _NumberFormatter {
|
|
8
93
|
static format(value, format2, options) {
|
|
@@ -346,62 +431,6 @@ var TimeManager = class _TimeManager {
|
|
|
346
431
|
};
|
|
347
432
|
var TimeManager_default = TimeManager;
|
|
348
433
|
|
|
349
|
-
// src/helper-functions/components/ObjectConverter.ts
|
|
350
|
-
import { v4 } from "uuid";
|
|
351
|
-
import { LOCAL_FILE_MIME_TYPES } from "@wavy/types";
|
|
352
|
-
import { log } from "console";
|
|
353
|
-
function fileToLocalFile(file, options) {
|
|
354
|
-
const fileExt = getFileExt(file.name);
|
|
355
|
-
const fileName = (() => {
|
|
356
|
-
if (options?.filename && options.filename.includes(fileExt))
|
|
357
|
-
return options.filename;
|
|
358
|
-
else if (options?.filename) return options.filename.trim() + fileExt;
|
|
359
|
-
return file.name;
|
|
360
|
-
})()?.trim?.();
|
|
361
|
-
const { name: _, size: __, ..._metadata } = file;
|
|
362
|
-
return {
|
|
363
|
-
uid: options?.uid || v4(),
|
|
364
|
-
description: options?.description,
|
|
365
|
-
ext: fileExt,
|
|
366
|
-
path: options?.filepath || file?.webkitRelativePath,
|
|
367
|
-
typeAlias: options?.typeAlias || run(
|
|
368
|
-
Object.keys(LOCAL_FILE_MIME_TYPES).find(
|
|
369
|
-
(key) => LOCAL_FILE_MIME_TYPES[key].includes(file.type)
|
|
370
|
-
),
|
|
371
|
-
(type) => {
|
|
372
|
-
if (!type) {
|
|
373
|
-
log("An unknown file type was found ", file.type);
|
|
374
|
-
return "unknown";
|
|
375
|
-
}
|
|
376
|
-
return type;
|
|
377
|
-
}
|
|
378
|
-
),
|
|
379
|
-
sizeInBytes: file.size,
|
|
380
|
-
uploadDate: options?.uploadDate === "now" ? Date.now() : options?.uploadDate ?? file?.lastModified,
|
|
381
|
-
name: fileName,
|
|
382
|
-
_metadata
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
function localFileToFile(localFile) {
|
|
386
|
-
return {
|
|
387
|
-
name: localFile.name,
|
|
388
|
-
size: localFile.sizeInBytes,
|
|
389
|
-
...localFile._metadata
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
var Overloader = class {
|
|
393
|
-
invoke(...args) {
|
|
394
|
-
if (isFile(args[0])) {
|
|
395
|
-
return fileToLocalFile(...args);
|
|
396
|
-
}
|
|
397
|
-
if (isLocalFile(args[0])) {
|
|
398
|
-
return localFileToFile(...args);
|
|
399
|
-
} else throw new Error(`The arguments supplied are insufficient.`);
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
var toObject = new Overloader().invoke;
|
|
403
|
-
var ObjectConverter_default = toObject;
|
|
404
|
-
|
|
405
434
|
// src/helper-functions/HelperFunctions.ts
|
|
406
435
|
var dateFormat = new TimeManager_default().format;
|
|
407
436
|
var timeDuration = new TimeManager_default().getDuration;
|
|
@@ -430,6 +459,8 @@ function format(event, ...args) {
|
|
|
430
459
|
return getCaller(toMoney);
|
|
431
460
|
case "name":
|
|
432
461
|
return getCaller(nameToString);
|
|
462
|
+
case "file-size":
|
|
463
|
+
return new FileSizeFormatter(args[0]).format();
|
|
433
464
|
default:
|
|
434
465
|
return event;
|
|
435
466
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wavy/fn",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"main": "./dist/main.js",
|
|
5
5
|
"module": "./dist/main.cjs",
|
|
6
6
|
"types": "./dist/main.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsup && node prepend",
|
|
9
|
-
"success": "✨ Successfully published package! ✨",
|
|
9
|
+
"success": "echo ✨ Successfully published package! ✨",
|
|
10
10
|
"publisher": "npm run build && npm version patch && npm publish && npm run success"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|