The drop in Filer replacement you have been waiting for. Completely Typed and Built with TypeScript
npm install @terbiumos/tfs@terbiumos/tfs.
tfsPath import
js
import { tfsPath } from "@terbiumos/tfs";
// tfsPath is the path of the web folder of the TFS files
`
Aditionally, All of the classes are also typed and can be imported as such if needed:
`js
import { FSType } from "@terbiumos/tfs";
// Types for tfs.fs
`
If you do not wish to host the files and use it directly in your code you can import the TFS class directly however you MUST use @terbiumos/tfs/browser for this import:
`js
import { TFS } from "@terbiumos/tfs/browser";
const { fs } = await tfs.init();
`
The TFS Object consists of: FS, Path, Shell, and Buffer.
The Buffer utility is actually the same as Filer and is powered by the Ferros Buffer Library with the same exact syntax as node:buffer and Filer.Buffer
To load TFS conviently, simply run:
`js
const tfs = await tfs.init()
`
If you need a specific module from TFS, you can desctructure the object for the one that you need
`js
const { fs } = await tfs.init()
`
If your working in a non asyncronous workspace or a service worker, you can use tfs.initSw() to initialize the TFS object on window (or in service worker contexts, self) automatically:
Or if you do not wish to use one of the following methods to initialize TFS, you can also use the constructor as normal;
`js
const handle = await navigator.storage.getDirectory();
const tfs = new tfs(handle);
`
The TFS Shell works slightly different than the Filer Shell, it is already instantiated so you do not need to create a new instance of the Shell and you can directly call it as:
`js
const shell = tfs.shell
`
`js
const shell = tfs.fs.shell
`
however, if your lazy or are using some kind of compatability layer and still want the 1 to 1 support, TFS provides tfs.sh` as a uninitialized shell however this isnt recommended.