UNPKG

ts-browser-helpers

Version:

A collection of utility classes, functions and decorators for javascript/typescript projects, for use in the browser.

63 lines 2.23 kB
/** * Copyright 2019 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Modified from: https://github.com/GoogleChromeLabs/text-editor/blob/main/src/inline-scripts/fs-helpers.js */ /** * Open a handle to an existing file on the local file system. * * @return {!Promise<FileSystemFileHandle>} Handle to the existing file. * * @category File System */ export declare function getFileHandle(): Promise<FileSystemFileHandle>; /** * Create a handle to a new (text) file on the local file system. * * @return {!Promise<FileSystemFileHandle>} Handle to the new file. * * @category File System */ export declare function getNewFileHandle(): Promise<FileSystemFileHandle>; /** * Reads the raw text from a file. * * @param {File} file * @return {!Promise<string>} A promise that resolves to the parsed string. * * @category File System */ export declare function readFile(file: File): Promise<string>; /** * Writes the contents to disk. * * @param {FileSystemFileHandle} fileHandle File handle to write to. * @param {string} contents Contents to write. * * @category File System */ export declare function writeFile(fileHandle: FileSystemFileHandle, contents: FileSystemWriteChunkType): Promise<void>; /** * Verify the user has granted permission to read or write to the file, if * permission hasn't been granted, request permission. * * @param fileHandle File handle to check. * @param withWrite True if write permission should be checked. * @return True if the user has granted read/write permission. * * @category File System */ export declare function verifyPermission(fileHandle: FileSystemFileHandle, withWrite: boolean): Promise<boolean>; //# sourceMappingURL=fs-api.d.ts.map