A Promise-based class that can offers different ways of loading files from disk, including wrappers around the synchronous I/O methods from node.
npm install @wessberg/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.
This library will be deprecated. There are better alternatives built directly
into the fs module now. Use that instead.
- Description
- DISCLAIMER
- Table of Contents
- Install
- npm
- Yarn
- pnpm
- Usage
- Contributing
- Maintainers
- Backers
- Patreon
- License
```
$ npm install @wessberg/fileloader
``
$ yarn add @wessberg/fileloader
``
$ pnpm add @wessberg/fileloader
`typescript
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"]);
``
Do you want to contribute? Awesome! Please follow these recommendations.
| |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Frederik Wessberg
Twitter: @FredWessberg
Github: @wessberg
_Lead Developer_ |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Bubbles
Twitter: @use_bubbles |
MIT © Frederik Wessberg (@FredWessberg) (Website)