mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 12:16:01 +00:00
SYNC: Merge branch 'feature/firestore'
This commit is contained in:
committed by
Diflow
parent
b12587626d
commit
ca145967dc
@@ -1,26 +1,3 @@
|
||||
/**
|
||||
* @template [T = any]
|
||||
* @typedef {Object} FileParseResultSuccess
|
||||
* @property {true} success
|
||||
* @property {T} data
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} FileParseResultError
|
||||
* @property {false} success
|
||||
* @property {string} error
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template [T = any]
|
||||
* @typedef {FileParseResultSuccess<T> | FileParseResultError} FileParseResult
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template [T = any]
|
||||
* @param {File} file
|
||||
* @returns {Promise<FileParseResult<T>>}
|
||||
*/
|
||||
export async function parseFileAsJson(file) {
|
||||
try {
|
||||
const text = await file.text();
|
||||
|
||||
15
packages/web/src/utility/parseFileAsString.js
Normal file
15
packages/web/src/utility/parseFileAsString.js
Normal file
@@ -0,0 +1,15 @@
|
||||
export async function parseFileAsString(file) {
|
||||
try {
|
||||
const text = await file.text();
|
||||
const data = text;
|
||||
return {
|
||||
success: true,
|
||||
data,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Unknown parsing error',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user