Package Exports
- @wessberg/fileloader
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@wessberg/fileloader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
FileLoader
A Promise-based class that can offers different ways of loading files from disk, including wrappers around the synchronous I/O methods from node.
Installation
Simply do: npm install @wessberg/fileloader.
DISCLAIMER
This is a very early version. The API may still change greatly.
Usage
const fileLoader = new FileLoader();
// Just a simple Promise-based async I/O method.
const buffer = await fileLoader.load("some_file.ts");
// A wrapper around the "readSync" method from node's "fs" module.
const sync = fileLoader.loadSync("some_file.ts");
// Loads the first matched file associated with the given path
// combined with the given array of ordered extensions.
const [result, path] = await fileLoader.loadWithFirstMatchedExtension("some_path", [".ts", ".fs"]);
// Loads all files in the given directory.
const buffers = await fileLoader.loadAllInDirectory("some_dir");
// Gets a list of all files in the given directory with an extension of "ts".
const buffers = await fileLoader.getFilesInDirectory("some_dir", [".ts"]);