mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 07:27:33 +08:00
support custom script to process delimiter-separated values (data) file / data
This commit is contained in:
@@ -5,6 +5,7 @@ export class KnownFileType {
|
||||
public static readonly CSV = new KnownFileType('csv', 'text/csv');
|
||||
public static readonly TSV = new KnownFileType('tsv', 'text/tab-separated-values');
|
||||
public static readonly MARKDOWN = new KnownFileType('md', 'text/markdown');
|
||||
public static readonly JS = new KnownFileType('js', 'application/javascript');
|
||||
|
||||
public readonly extension: string;
|
||||
public readonly contentType: string;
|
||||
@@ -30,6 +31,12 @@ export class KnownFileType {
|
||||
});
|
||||
}
|
||||
|
||||
public createFile(content: string, fileName: string): File {
|
||||
return new File([content], this.formatFileName(fileName), {
|
||||
type: this.contentType,
|
||||
});
|
||||
}
|
||||
|
||||
public static parse(extension: string): KnownFileType | undefined {
|
||||
return KnownFileType.allInstancesByExtension[extension];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user