Skip to main content
Module

x/mock_file/mod.ts>prepareVirtualFile

Synchronous file system API polyfill for deno deploy.
Go to Latest
function prepareVirtualFile
import { prepareVirtualFile } from "https://deno.land/x/mock_file@v1.0.1/mod.ts";

Preloads virtual file that will be opened/read later.

Parameters

path: string | URL

Path to file.

optional
content = [UNSUPPORTED]

Content of file. Default to empty Uint8Array.

optional
fileInfo: Partial<Deno.FileInfo> = [UNSUPPORTED]

The object used as the return value of file.stat.

import { prepareVirtualFile } from "https://deno.land/x/mock_file@$VERSION/mod.ts";

const content = new TextEncoder().encode("hello world");
prepareVirtualFile("./no/such/file.txt", content);

const file = Deno.openSync("./no/such/file.txt");