In-memory file system
JSFS provides a nice and clean way to create file systems that are stored in memory with a nice and clean API which is almost identical to the NodeJS FS API.
;// we can use the NodeJS API while everything is stored in memory!fs1.writeFileSync'bar.txt', 'some content for the file';fs1.writeFileSync'foo.txt', 'yet another file with some other content';
Get rid of absolute paths
Want to provide a file system interface to your users but you don't want to
expose internal directory structure? Use
isolate() to do the work for you!
⚠️ This method is not guaranteed to be fully secure. If you want full isolation, use a virtualizer such as KVM or Xen.
// now all files will be relative to /path/to/project!console.logfs2.readFileSync'package.json'.toString;
Use one or more file systems as a fallback
In some cases, you may need to write to a specific directory or file system
while you data is coming from somewhere else. This is an ideal scenario for
// a more complex example ... the following statement will merge the two file// systems together and provide one API to access them both;// the following statement will try to read foo.txt from memory and then fallback to /path/to/project/foo.txtmergedfs.readFileSync'foo.txt';
- Robust and future-proof TypeScript interface based on the NodeJS FileSystem API
- Code splitting: only
requirewhat you really need
- File system transforms: change the behaviour of an existing file system
- Comes shipped with an in-memory file system
NodeJS-style callbacks are supported but are not type-checked
- Code still has to be extensively tested
- Currently no support for watching files
- API is still prone to changes. View the change log in order to remain up to date.
For more information see the list of open issues.
- The FileSystem Interface
- Defining a New File System
- Transforming an Existing File System
- Built-in File Systems
- File Watching API
- Extra Operations
Copyright 2017 Sam Vervaeck
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.