diff --git a/README.md b/README.md index 12cdd7134..365f08ddf 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ In-memory file-system with [Node's `fs` API](https://nodejs.org/api/fs.html). - Implements *soft links* (aka symlinks, symbolic links) - More testing coming soon* - Permissions may* be implemented in the future + - Can be used in browser, see `memfs-webpack` Usage: @@ -67,6 +68,9 @@ import {Volume} from 'memfs'; const vol = Volume.fromJSON({'/foo': 'bar'}); vol.readFileSync('/foo'); // bar + +const vol2 = Volume.fromJSON({'/foo': 'bar 2'}); +vol2.readFileSync('/foo'); // bar 2 ``` Use `memfs` together with [`unionfs`][unionfs] to create one filesystem @@ -112,12 +116,12 @@ filesystem operations but are slightly different. import {vol, fs} from 'memfs'; ``` -`vol` is an instance of `Volume` constructor, it is a default volume created -for your convenience. `fs` in an *fs-like* object created from `vol` using +`vol` is an instance of `Volume` constructor, it is the default volume created +for your convenience. `fs` is an *fs-like* object created from `vol` using `createFsFromVolume(vol)`, see reference below. All contents of the `fs` object are also exported individually, so you can use -`memfs` just like you would `fs` module: +`memfs` just like you would use the `fs` module: ```js import {readFileSync, F_OK, ReadStream} from 'memfs'; @@ -183,19 +187,19 @@ Exports the whole contents of the volume recursively to a flat JSON object. If this argument is omitted, the whole volume is exported. `paths` can be an array of paths. A path can be a string, `Buffer` or an `URL` object. -`json` is an optional object parameter where the list of files will be added. +`json` is an optional object parameter which will be populated with the exported files. `isRelative` is boolean that specifies if returned paths should be relative. ###### `vol.mkdirp(path, callback)` -Creates a directory tree recursively. `path` is specifies a directory to +Creates a directory tree recursively. `path` specifies a directory to create and can be a string, `Buffer`, or an `URL` object. `callback` is called on completion and may receive only one argument - an `Error` object. ###### `vol.mkdirpSync(path)` -A synchronous version of `vol.mkdirp`. This method throws. +A synchronous version of `vol.mkdirp()`. This method throws. #### `createFsFromVolume(vol)` @@ -222,89 +226,93 @@ you get from `require('fs')`. Here are some things this function does: # API Status - - [x] Constants - - [x] `FSWatcher` - - [x] `ReadStream` - - [x] `WriteStream` - - [x] `Stats` - - [x] `access(path[, mode], callback)` - - Does not check permissions - - [x] `accessSync(path[, mode])` - - Does not check permissions - - [x] `appendFile(file, data[, options], callback)` - - [x] `appendFileSync(file, data[, options])` - - [x] `chmod(path, mode, callback)` - - [x] `chmodSync(path, mode)` - - [x] `chown(path, uid, gid, callback)` - - [x] `chownSync(path, uid, gid)` - - [x] `close(fd, callback)` - - [x] `closeSync(fd)` - - [x] `createReadStream(path[, options])` - - [x] `createWriteStream(path[, options])` - - [x] `exists(path, callback)` - - [x] `existsSync(path)` - - [x] `fchmod(fd, mode, callback)` - - [x] `fchmodSync(fd, mode)` - - [x] `fchown(fd, uid, gid, callback)` - - [x] `fchownSync(fd, uid, gid)` - - [x] `fdatasync(fd, callback)` - - [x] `fdatasyncSync(fd)` - - [x] `fstat(fd, callback)` - - [x] `fstatSync(fd)` - - [x] `fsync(fd, callback)` - - [x] `fsyncSync(fd)` - - [x] `ftruncate(fd[, len], callback)` - - [x] `ftruncateSync(fd[, len])` - - [x] `futimes(fd, atime, mtime, callback)` - - [x] `futimesSync(fd, atime, mtime)` - - [x] `lchmod(path, mode, callback)` - - [x] `lchmodSync(path, mode)` - - [x] `lchown(path, uid, gid, callback)` - - [x] `lchownSync(path, uid, gid)` - - [x] `link(existingPath, newPath, callback)` - - [x] `linkSync(existingPath, newPath)` - - [x] `lstat(path, callback)` - - [x] `lstatSync(path)` - - [x] `mkdir(path[, mode], callback)` - - [x] `mkdirSync(path[, mode])` - - [x] `mkdtemp(prefix[, options], callback)` - - [x] `mkdtempSync(prefix[, options])` - - [x] `open(path, flags[, mode], callback)` - - [x] `openSync(path, flags[, mode])` - - [x] `read(fd, buffer, offset, length, position, callback)` - - [x] `readSync(fd, buffer, offset, length, position)` - - [x] `readdir(path[, options], callback)` - - [x] `readdirSync(path[, options])` - - [x] `readFile(path[, options], callback)` - - [x] `readFileSync(path[, options])` - - [x] `readlink(path[, options], callback)` - - [x] `readlinkSync(path[, options])` - - [x] `realpath(path[, options], callback)` - - [x] `realpathSync(path[, options])` - - Caching not implemented - - [x] `rename(oldPath, newPath, callback)` - - [x] `renameSync(oldPath, newPath)` - - [x] `rmdir(path, callback)` - - [x] `rmdirSync(path)` - - [x] `stat(path, callback)` - - [x] `statSync(path)` - - [x] `symlink(target, path[, type], callback)` - - [x] `symlinkSync(target, path[, type])` - - [x] `truncate(path[, len], callback)` - - [x] `truncateSync(path[, len])` - - [x] `unlink(path, callback)` - - [x] `unlinkSync(path)` - - [x] `utimes(path, atime, mtime, callback)` - - [x] `utimesSync(path, atime, mtime)` - - [x] `watch(filename[, options][, listener])` - - [x] `watchFile(filename[, options], listener)` - - [x] `unwatchFile(filename[, listener])` - - [x] `write(fd, buffer[, offset[, length[, position]]], callback)` - - [x] `write(fd, string[, position[, encoding]], callback)` - - [x] `writeFile(file, data[, options], callback)` - - [x] `writeFileSync(file, data[, options])` - - [x] `writeSync(fd, buffer[, offset[, length[, position]]])` - - [x] `writeSync(fd, string[, position[, encoding]])` +All of the [Node's `fs` API](https://nodejs.org/api/fs.html) is implemented. +Some error messages may be inaccurate. File permissions are currently not +implemented (you have access to any file), basically `fs.access()` is a no-op. + + - [x] Constants + - [x] `FSWatcher` + - [x] `ReadStream` + - [x] `WriteStream` + - [x] `Stats` + - [x] `access(path[, mode], callback)` + - Does not check permissions + - [x] `accessSync(path[, mode])` + - Does not check permissions + - [x] `appendFile(file, data[, options], callback)` + - [x] `appendFileSync(file, data[, options])` + - [x] `chmod(path, mode, callback)` + - [x] `chmodSync(path, mode)` + - [x] `chown(path, uid, gid, callback)` + - [x] `chownSync(path, uid, gid)` + - [x] `close(fd, callback)` + - [x] `closeSync(fd)` + - [x] `createReadStream(path[, options])` + - [x] `createWriteStream(path[, options])` + - [x] `exists(path, callback)` + - [x] `existsSync(path)` + - [x] `fchmod(fd, mode, callback)` + - [x] `fchmodSync(fd, mode)` + - [x] `fchown(fd, uid, gid, callback)` + - [x] `fchownSync(fd, uid, gid)` + - [x] `fdatasync(fd, callback)` + - [x] `fdatasyncSync(fd)` + - [x] `fstat(fd, callback)` + - [x] `fstatSync(fd)` + - [x] `fsync(fd, callback)` + - [x] `fsyncSync(fd)` + - [x] `ftruncate(fd[, len], callback)` + - [x] `ftruncateSync(fd[, len])` + - [x] `futimes(fd, atime, mtime, callback)` + - [x] `futimesSync(fd, atime, mtime)` + - [x] `lchmod(path, mode, callback)` + - [x] `lchmodSync(path, mode)` + - [x] `lchown(path, uid, gid, callback)` + - [x] `lchownSync(path, uid, gid)` + - [x] `link(existingPath, newPath, callback)` + - [x] `linkSync(existingPath, newPath)` + - [x] `lstat(path, callback)` + - [x] `lstatSync(path)` + - [x] `mkdir(path[, mode], callback)` + - [x] `mkdirSync(path[, mode])` + - [x] `mkdtemp(prefix[, options], callback)` + - [x] `mkdtempSync(prefix[, options])` + - [x] `open(path, flags[, mode], callback)` + - [x] `openSync(path, flags[, mode])` + - [x] `read(fd, buffer, offset, length, position, callback)` + - [x] `readSync(fd, buffer, offset, length, position)` + - [x] `readdir(path[, options], callback)` + - [x] `readdirSync(path[, options])` + - [x] `readFile(path[, options], callback)` + - [x] `readFileSync(path[, options])` + - [x] `readlink(path[, options], callback)` + - [x] `readlinkSync(path[, options])` + - [x] `realpath(path[, options], callback)` + - [x] `realpathSync(path[, options])` + - Caching not implemented + - [x] `rename(oldPath, newPath, callback)` + - [x] `renameSync(oldPath, newPath)` + - [x] `rmdir(path, callback)` + - [x] `rmdirSync(path)` + - [x] `stat(path, callback)` + - [x] `statSync(path)` + - [x] `symlink(target, path[, type], callback)` + - [x] `symlinkSync(target, path[, type])` + - [x] `truncate(path[, len], callback)` + - [x] `truncateSync(path[, len])` + - [x] `unlink(path, callback)` + - [x] `unlinkSync(path)` + - [x] `utimes(path, atime, mtime, callback)` + - [x] `utimesSync(path, atime, mtime)` + - [x] `watch(filename[, options][, listener])` + - [x] `watchFile(filename[, options], listener)` + - [x] `unwatchFile(filename[, listener])` + - [x] `write(fd, buffer[, offset[, length[, position]]], callback)` + - [x] `write(fd, string[, position[, encoding]], callback)` + - [x] `writeFile(file, data[, options], callback)` + - [x] `writeFileSync(file, data[, options])` + - [x] `writeSync(fd, buffer[, offset[, length[, position]]])` + - [x] `writeSync(fd, string[, position[, encoding]])` [npm-url]: https://www.npmjs.com/package/memfs diff --git a/package.json b/package.json index e6427fd0d..0e7d849f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "memfs", - "version": "2.0.2", + "version": "2.0.3", "description": "In-memory file-system with Node's fs API.", "main": "lib/index.js", "keywords": [