@wavy/fn 0.0.1 → 0.0.2
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 +17 -11
- package/dist/main.d.cts +7 -9
- package/dist/main.d.ts +7 -9
- package/dist/main.js +17 -11
- package/package.json +1 -1
- package/prepend.js +1 -0
package/dist/main.cjs
CHANGED
|
@@ -498,38 +498,44 @@ function isFile(obj) {
|
|
|
498
498
|
return true;
|
|
499
499
|
return false;
|
|
500
500
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
const options = args[0];
|
|
501
|
+
var toObject = new class T {
|
|
502
|
+
fileToLocalFile(file, options) {
|
|
504
503
|
const fileName = (() => {
|
|
505
|
-
const fileExt = getFileExt(
|
|
504
|
+
const fileExt = getFileExt(file.name);
|
|
506
505
|
if (options?.filename && options.filename.includes(fileExt))
|
|
507
506
|
return options.filename;
|
|
508
507
|
else if (options?.filename) return options.filename.trim() + fileExt;
|
|
509
|
-
return
|
|
508
|
+
return file.name;
|
|
510
509
|
})()?.trim?.();
|
|
511
510
|
return {
|
|
512
511
|
uid: (0, import_uuid.v4)(),
|
|
513
512
|
description: options?.description,
|
|
514
|
-
path: options?.filepath ||
|
|
513
|
+
path: options?.filepath || file.webkitRelativePath,
|
|
515
514
|
typeAlias: options?.typeAlias || run(
|
|
516
515
|
Object.keys(import_types.LOCAL_FILE_MIME_TYPES).find(
|
|
517
|
-
(key) => import_types.LOCAL_FILE_MIME_TYPES[key].includes(
|
|
516
|
+
(key) => import_types.LOCAL_FILE_MIME_TYPES[key].includes(file.type)
|
|
518
517
|
),
|
|
519
518
|
(type) => {
|
|
520
519
|
if (!type) {
|
|
521
|
-
(0, import_console.log)("An unknown file type was found ",
|
|
520
|
+
(0, import_console.log)("An unknown file type was found ", file.type);
|
|
522
521
|
return "unknown";
|
|
523
522
|
}
|
|
524
523
|
return type;
|
|
525
524
|
}
|
|
526
525
|
),
|
|
527
|
-
sizeInBytes:
|
|
528
|
-
uploadDate: options?.uploadDate === "now" ? Date.now() : options?.uploadDate ??
|
|
526
|
+
sizeInBytes: file.size,
|
|
527
|
+
uploadDate: options?.uploadDate === "now" ? Date.now() : options?.uploadDate ?? file.lastModified,
|
|
529
528
|
name: fileName
|
|
530
529
|
};
|
|
531
530
|
}
|
|
532
|
-
|
|
531
|
+
invoke(...args) {
|
|
532
|
+
if (isFile(args[0]))
|
|
533
|
+
return this.fileToLocalFile(
|
|
534
|
+
...args
|
|
535
|
+
);
|
|
536
|
+
else throw new Error(`The arguments supplied are insufficient.`);
|
|
537
|
+
}
|
|
538
|
+
}().invoke;
|
|
533
539
|
function classNameResolver(baseClassName) {
|
|
534
540
|
return (className) => {
|
|
535
541
|
return `${baseClassName}-${className}`;
|
package/dist/main.d.cts
CHANGED
|
@@ -50,15 +50,13 @@ declare const addressToString: (address: Address | undefined, inline?: boolean)
|
|
|
50
50
|
declare const toMoney: (value: string | number, options?: NumberFormatterTypes["options"]["money"]) => string;
|
|
51
51
|
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;
|
|
52
52
|
declare function isFile(obj: unknown): obj is File;
|
|
53
|
-
declare
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}>
|
|
61
|
-
] : []): O extends File ? LocalFile | undefined : void;
|
|
53
|
+
declare const toObject: (file: File, options?: Partial<{
|
|
54
|
+
uploadDate: number | "now";
|
|
55
|
+
description: string;
|
|
56
|
+
filepath: string;
|
|
57
|
+
filename: string;
|
|
58
|
+
typeAlias: LocalFile["typeAlias"];
|
|
59
|
+
}> | undefined) => LocalFile;
|
|
62
60
|
declare function classNameResolver(baseClassName: string): (className: string) => string;
|
|
63
61
|
declare function classNameExt(rootClassName: string): (className: string) => string;
|
|
64
62
|
declare function range(start: number, end: number): number[];
|
package/dist/main.d.ts
CHANGED
|
@@ -50,15 +50,13 @@ declare const addressToString: (address: Address | undefined, inline?: boolean)
|
|
|
50
50
|
declare const toMoney: (value: string | number, options?: NumberFormatterTypes["options"]["money"]) => string;
|
|
51
51
|
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;
|
|
52
52
|
declare function isFile(obj: unknown): obj is File;
|
|
53
|
-
declare
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}>
|
|
61
|
-
] : []): O extends File ? LocalFile | undefined : void;
|
|
53
|
+
declare const toObject: (file: File, options?: Partial<{
|
|
54
|
+
uploadDate: number | "now";
|
|
55
|
+
description: string;
|
|
56
|
+
filepath: string;
|
|
57
|
+
filename: string;
|
|
58
|
+
typeAlias: LocalFile["typeAlias"];
|
|
59
|
+
}> | undefined) => LocalFile;
|
|
62
60
|
declare function classNameResolver(baseClassName: string): (className: string) => string;
|
|
63
61
|
declare function classNameExt(rootClassName: string): (className: string) => string;
|
|
64
62
|
declare function range(start: number, end: number): number[];
|
package/dist/main.js
CHANGED
|
@@ -403,38 +403,44 @@ function isFile(obj) {
|
|
|
403
403
|
return true;
|
|
404
404
|
return false;
|
|
405
405
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
const options = args[0];
|
|
406
|
+
var toObject = new class T {
|
|
407
|
+
fileToLocalFile(file, options) {
|
|
409
408
|
const fileName = (() => {
|
|
410
|
-
const fileExt = getFileExt(
|
|
409
|
+
const fileExt = getFileExt(file.name);
|
|
411
410
|
if (options?.filename && options.filename.includes(fileExt))
|
|
412
411
|
return options.filename;
|
|
413
412
|
else if (options?.filename) return options.filename.trim() + fileExt;
|
|
414
|
-
return
|
|
413
|
+
return file.name;
|
|
415
414
|
})()?.trim?.();
|
|
416
415
|
return {
|
|
417
416
|
uid: v4(),
|
|
418
417
|
description: options?.description,
|
|
419
|
-
path: options?.filepath ||
|
|
418
|
+
path: options?.filepath || file.webkitRelativePath,
|
|
420
419
|
typeAlias: options?.typeAlias || run(
|
|
421
420
|
Object.keys(LOCAL_FILE_MIME_TYPES).find(
|
|
422
|
-
(key) => LOCAL_FILE_MIME_TYPES[key].includes(
|
|
421
|
+
(key) => LOCAL_FILE_MIME_TYPES[key].includes(file.type)
|
|
423
422
|
),
|
|
424
423
|
(type) => {
|
|
425
424
|
if (!type) {
|
|
426
|
-
log("An unknown file type was found ",
|
|
425
|
+
log("An unknown file type was found ", file.type);
|
|
427
426
|
return "unknown";
|
|
428
427
|
}
|
|
429
428
|
return type;
|
|
430
429
|
}
|
|
431
430
|
),
|
|
432
|
-
sizeInBytes:
|
|
433
|
-
uploadDate: options?.uploadDate === "now" ? Date.now() : options?.uploadDate ??
|
|
431
|
+
sizeInBytes: file.size,
|
|
432
|
+
uploadDate: options?.uploadDate === "now" ? Date.now() : options?.uploadDate ?? file.lastModified,
|
|
434
433
|
name: fileName
|
|
435
434
|
};
|
|
436
435
|
}
|
|
437
|
-
|
|
436
|
+
invoke(...args) {
|
|
437
|
+
if (isFile(args[0]))
|
|
438
|
+
return this.fileToLocalFile(
|
|
439
|
+
...args
|
|
440
|
+
);
|
|
441
|
+
else throw new Error(`The arguments supplied are insufficient.`);
|
|
442
|
+
}
|
|
443
|
+
}().invoke;
|
|
438
444
|
function classNameResolver(baseClassName) {
|
|
439
445
|
return (className) => {
|
|
440
446
|
return `${baseClassName}-${className}`;
|
package/package.json
CHANGED
package/prepend.js
CHANGED