Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Abstract away any filesystem (NodeJS) instance to a smarter interface
Any-fs was designed to wrap filesystem interfaces like the following:
Into a common interface that provides a more intuitive syntax. Any-fs is designed to blindly take any of these systems and return a common API.
Usage with the built-in fs
interface is the simplest use-case:
const fs = require("fs");
const anyFs = require("any-fs");
const afs = anyFs(fs);
afs
.readDirectory("/")
.then(function(contents) {
console.log(contents.pop());
// returns something like:
// {
// name: "filename.txt,
// isFile: Function,
// isDirectory: Function,
// }
});
This example returns an array if stat objects.
Once WebDAV-fs has been setup with a remote location, it too can be wrapped by any-fs:
const wfs = require("webdav-fs")(
"http://example.com/webdav/",
"username",
"password"
);
const anyFs = require("any-fs");
const afs = anyFs(fs);
afs
.readFile("/movie.mp4")
.then(function(data) {
// `data` is a Buffer
});
Any-fs supports a few handy commands.
Read the contents of a directory, returning a Promise with an array of stats (refer to the stat output of the wrapped fs module).
Parameter | Type | Description |
---|---|---|
directoryPath | String | The path to scan |
options | String or Object | Encoding (string) or config options (object) |
options
may contain propertiesmode
andencoding
(mode
being either"node"
or"stat"
), but it is essentially passed down into whatever fs interface is being wrapped.
options
is not used forreaddir
in Node's 'fs' module.
Read the contents of a file, returning a Promise with a Buffer or string.
Parameter | Type | Description |
---|---|---|
filePath | String | The file to read |
options | String or Object | Encoding (string) or config options (object) |
options.encoding
is set tonull
by default, returning the raw buffer. Use"utf8"
to convert it to a UTF8 string.
Get statistics on a file or directory - returns a Promise with the stat object.
Parameter | Type | Description |
---|---|---|
filePath | String | The file or directory to check |
Write data to a file - returns a Promise that resolves after writing has completed.
Parameter | Type | Description |
---|---|---|
filePath | String | The file to write to |
data | Buffer or String | The data to write |
encoding | String or undefined | The encoding to use for writing. utf8 writes text. |
v0.4.1
2017-09-12
FAQs
Abstract away any NodeJS fs-style object into a smarter interface
The npm package any-fs receives a total of 13 weekly downloads. As such, any-fs popularity was classified as not popular.
We found that any-fs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.