Re-enabled stubs for PNG analyser and ICO maker, Implemented Data utils, file utils and PNG parser, Still testing
Update png-analyser.yml, png-chunk-analyser.yml, and 17 more files...
This commit is contained in:
28
static/resources/NibblePoker/libs/file-utils.mjs
Normal file
28
static/resources/NibblePoker/libs/file-utils.mjs
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
/**
|
||||
* Reads a file and returns its content as a string.
|
||||
* @param {File} file - The file to read.
|
||||
* @returns {Promise<string>} A promise that resolves with the file content as a string.
|
||||
*/
|
||||
export function loadFileAsText(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => resolve(reader.result);
|
||||
reader.onerror = reject;
|
||||
reader.readAsText(file);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a file and returns its content as a `Uint8Array`.
|
||||
* @param {File} file - The file to read.
|
||||
* @returns {Promise<Uint8Array>} A promise that resolves with the file content as a byte buffer.
|
||||
*/
|
||||
export function loadFileAsUint8Array(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => resolve(new Uint8Array(reader.result));
|
||||
reader.onerror = reject;
|
||||
reader.readAsArrayBuffer(file);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user