@bouko/react 2.6.5 → 2.6.6
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/core/functions.d.ts +2 -5
- package/dist/core/functions.js +10 -13
- package/package.json +1 -1
package/dist/core/functions.d.ts
CHANGED
|
@@ -3,11 +3,8 @@ export declare const getFilesData: (files: File[]) => Promise<{
|
|
|
3
3
|
mimetype: string;
|
|
4
4
|
data?: string | undefined;
|
|
5
5
|
}[]>;
|
|
6
|
-
export declare
|
|
7
|
-
|
|
8
|
-
mimetype: string;
|
|
9
|
-
data?: string | undefined;
|
|
10
|
-
}>;
|
|
6
|
+
export declare function getFileData(file: File): Promise<string>;
|
|
7
|
+
export declare function getFileData(file: File | undefined): Promise<string | undefined>;
|
|
11
8
|
export declare const bufferToFile: (buffer: ArrayBuffer, name?: string | undefined) => Promise<File>;
|
|
12
9
|
export declare const getAudioDuration: (file: File) => Promise<number>;
|
|
13
10
|
export declare function getBase64(image: string): Promise<string>;
|
package/dist/core/functions.js
CHANGED
|
@@ -14,19 +14,16 @@ export const getFilesData = (files) => Promise.all(files.map((file) => {
|
|
|
14
14
|
reader.readAsDataURL(file);
|
|
15
15
|
});
|
|
16
16
|
}));
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
reader.onerror = reject;
|
|
28
|
-
reader.readAsDataURL(file);
|
|
29
|
-
});
|
|
17
|
+
export async function getFileData(file) {
|
|
18
|
+
if (!file)
|
|
19
|
+
return;
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
const reader = new FileReader();
|
|
22
|
+
reader.onload = () => resolve(reader.result);
|
|
23
|
+
reader.onerror = reject;
|
|
24
|
+
reader.readAsDataURL(file);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
30
27
|
async function detectFileExtension(buffer) {
|
|
31
28
|
const type = await fileTypeFromBuffer(buffer);
|
|
32
29
|
if (!type)
|