diff options
Diffstat (limited to 'src/Utils.ts')
| -rw-r--r-- | src/Utils.ts | 16 | 
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts index dba802f98..a01a94134 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -7,6 +7,22 @@ import { ColorState } from 'react-color';  export namespace Utils {      export let DRAG_THRESHOLD = 4; +    export function readUploadedFileAsText(inputFile: File) { +        const temporaryFileReader = new FileReader(); + +        return new Promise((resolve, reject) => { +            temporaryFileReader.onerror = () => { +                temporaryFileReader.abort(); +                reject(new DOMException("Problem parsing input file.")); +            }; + +            temporaryFileReader.onload = () => { +                resolve(temporaryFileReader.result); +            }; +            temporaryFileReader.readAsText(inputFile); +        }); +    } +      export function GenerateGuid(): string {          return v4();      }  | 
