(path: string | URL)
| 23 | * @returns A promise that resolves to a {@linkcode FsFile} instance. |
| 24 | */ |
| 25 | export async function create(path: string | URL): Promise<FsFile> { |
| 26 | if (isDeno) { |
| 27 | return Deno.create(path); |
| 28 | } else { |
| 29 | try { |
| 30 | return await open(path, { create: true, write: true, truncate: true }); |
| 31 | } catch (error) { |
| 32 | throw mapError(error); |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Creates a file if none exists or truncates an existing file and returns |
no test coverage detected