Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/mock_file/src/memory_file.ts>prepareVirtualFile

Synchronous file system API polyfill for deno deploy.
Latest
function prepareVirtualFile
import { prepareVirtualFile } from "https://deno.land/x/mock_file@v1.1.2/src/memory_file.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");