You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
786 B

4 years ago
  1. # memory-fs
  2. A simple in-memory filesystem. Holds data in a javascript object.
  3. ``` javascript
  4. var MemoryFileSystem = require("memory-fs");
  5. var fs = new MemoryFileSystem(); // Optionally pass a javascript object
  6. fs.mkdirpSync("/a/test/dir");
  7. fs.writeFileSync("/a/test/dir/file.txt", "Hello World");
  8. fs.readFileSync("/a/test/dir/file.txt"); // returns Buffer("Hello World")
  9. // Async variants too
  10. fs.unlink("/a/test/dir/file.txt", function(err) {
  11. // ...
  12. });
  13. fs.readdirSync("/a/test"); // returns ["dir"]
  14. fs.statSync("/a/test/dir").isDirectory(); // returns true
  15. fs.rmdirSync("/a/test/dir");
  16. fs.mkdirpSync("C:\\use\\windows\\style\\paths");
  17. ```
  18. ## License
  19. Copyright (c) 2012-2014 Tobias Koppers
  20. MIT (http://www.opensource.org/licenses/mit-license.php)