Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

memfs

Package Overview
Dependencies
Maintainers
1
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memfs - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

CODE_OF_CONDUCT.md

9

lib/index.js

@@ -13,3 +13,2 @@ "use strict";

var volume_1 = require("./volume");
var volume = require("./volume");
var _a = require('fs-monkey/lib/util/lists'), fsSyncMethods = _a.fsSyncMethods, fsAsyncMethods = _a.fsAsyncMethods;

@@ -34,6 +33,6 @@ var constants_1 = require("./constants");

}
fs.StatWatcher = volume_1.StatWatcher.bind(null, vol);
fs.FSWatcher = volume_1.FSWatcher.bind(null, vol);
fs.WriteStream = volume.WriteStream.bind(null, vol);
fs.ReadStream = volume.ReadStream.bind(null, vol);
fs.StatWatcher = vol.StatWatcher;
fs.FSWatcher = vol.FSWatcher;
fs.WriteStream = vol.WriteStream;
fs.ReadStream = vol.ReadStream;
fs._toUnixTimestamp = volume_1.toUnixTimestamp;

@@ -40,0 +39,0 @@ return fs;

@@ -9,1 +9,4 @@ "use strict";

};
exports.createFs = function (json) {
return __1.createFsFromVolume(exports.create(json));
};

@@ -306,34 +306,2 @@ "use strict";

});
describe('.closeSync(fd)', function () {
var vol = new volume_1.Volume;
it('Closes file without errors', function () {
var fd = vol.openSync('/test.txt', 'w');
vol.closeSync(fd);
});
xit('Correct error when file descriptor is not a number', function () { });
xit('Closing file descriptor that does not exist', function () { });
it('Closing same file descriptor twice throws EBADF', function () {
var fd = vol.openSync('/test.txt', 'w');
vol.closeSync(fd);
try {
vol.closeSync(fd);
throw Error('This should not throw');
}
catch (err) {
chai_1.expect(err.code).to.equal('EBADF');
}
});
it('Closing a file decreases the number of open files', function () {
var fd = vol.openSync('/test.txt', 'w');
var openFiles = vol.openFiles;
vol.closeSync(fd);
chai_1.expect(openFiles).to.be.greaterThan(vol.openFiles);
});
it('When closing a file, its descriptor is added to the pool of descriptors to be reused', function () {
var fd = vol.openSync('/test.txt', 'w');
var usedFdLength = vol.releasedFds.length;
vol.closeSync(fd);
chai_1.expect(usedFdLength).to.be.lessThan(vol.releasedFds.length);
});
});
describe('.close(fd, callback)', function () {

@@ -479,32 +447,2 @@ var vol = new volume_1.Volume;

});
describe('.writeFileSync(path, data[, options])', function () {
var data = 'asdfasidofjasdf';
it('Create a file at root (/writeFileSync.txt)', function () {
var vol = new volume_1.Volume;
vol.writeFileSync('/writeFileSync.txt', data);
var node = vol.root.getChild('writeFileSync.txt').getNode();
chai_1.expect(node).to.be.an.instanceof(node_1.Node);
chai_1.expect(node.getString()).to.equal(data);
});
it('Write to file by file descriptor', function () {
var vol = new volume_1.Volume;
var fd = vol.openSync('/writeByFd.txt', 'w');
vol.writeFileSync(fd, data);
var node = vol.root.getChild('writeByFd.txt').getNode();
chai_1.expect(node).to.be.an.instanceof(node_1.Node);
chai_1.expect(node.getString()).to.equal(data);
});
it('Write to two files (second by fd)', function () {
var vol = new volume_1.Volume;
// 1
vol.writeFileSync('/1.txt', '123');
// 2, 3, 4
var fd2 = vol.openSync('/2.txt', 'w');
var fd3 = vol.openSync('/3.txt', 'w');
var fd4 = vol.openSync('/4.txt', 'w');
vol.writeFileSync(fd2, '456');
chai_1.expect(vol.root.getChild('1.txt').getNode().getString()).to.equal('123');
chai_1.expect(vol.root.getChild('2.txt').getNode().getString()).to.equal('456');
});
});
describe('.writeFile(path, data[, options], callback)', function () {

@@ -511,0 +449,0 @@ var vol = new volume_1.Volume;

{
"name": "memfs",
"version": "2.3.0",
"version": "2.4.0",
"description": "In-memory file-system with Node's fs API.",
"main": "lib/index.js",
"keywords": [
"fs",
"filesystem",
"fs.js",
"memory-fs",
"memfs",
"file",
"file system",
"mount",
"memory",
"in-memory",
"virtual",
"test",
"testing",
"mock"
"fs", "filesystem", "fs.js", "memory-fs", "memfs",
"file", "file system", "mount", "memory", "in-memory",
"virtual", "test", "testing", "mock"
],

@@ -28,3 +17,3 @@ "repository": {

"fast-extend": "0.0.2",
"fs-monkey": "0.1.1",
"fs-monkey": "^0.1.3",
"unixify": "^1.0.0"

@@ -31,0 +20,0 @@ },

@@ -151,7 +151,6 @@ # memfs 2.0

But it does not hold constants or constructor functions:
But it does not hold constants and its methods are not bound to `vol`:
```js
vol.F_OK; // undefined
vol.ReadStream; // undefined
```

@@ -231,5 +230,31 @@

- Adds constructors `fs.Stats`, `fs.ReadStream`, `fs.WriteStream`, `fs.FileWatcher`, `fs.FSWatcher`.
- Adds constants `fs.constants`, `fs.F_OK`, etc.
# Relative paths
If you work with *absolute* paths, you should get what you expect from `memfs`.
You can also use *relative* paths but the gotcha is that then `memfs` needs
to somehow resolve those relative paths to absolute paths. `memfs` will use
the value of `process.cwd()` to resolve the absolute paths. The problem is
that `process.cwd()` specifies the *current working directory* of your
on-disk filesystem and you will probably not have that directory available in
`memfs`.
The best solution is to always use absolute paths. Alternatively, you can use
`mkdirp` method to recursively create the current working directory in your
volume:
```js
vol.mkdirpSync(process.cwd());
```
Or, you can set the current working directory to `/`, which
is one folder that exists in all your `memfs` volumes:
```js
process.chdir('/');
```
# API Status

@@ -236,0 +261,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc