2.0.6 • Published 4 years ago
arc-fs v2.0.6
arc-fs
Wrap a filesystem to provide a read-only fs api that adapts files according to an active flagset
API
new AdaptiveFS(options);
options.fs(optional): a filesystem that conforms to the node.jsfsapi. Defaults to the built-infsmoduleoptions.flags(required): anObjectwhere each key represents a flag and the value is a boolean indicating whether that flag is active orArrayof strings that represent the active flags
Instance methods
resolveSync(path)
Returns the resolved path based on the active flagset
getMatchesSync(path)
Returns a MatchSet for the path
isAdaptiveSync(path)
Returns a boolean indicating if the path can be adapted
clearCache()
Clears the adaptive resolver's cache
Read methods from fs
statstatSyncreaddirreaddirSyncreadFilereadFileSyncreadlinkreadlinkSyncexistsexistsSync
Examples
Default filesystem
import fs from 'fs';
import AdaptiveFS from 'arc-fs';
const afs = new AdaptiveFS({ flags:['test'] });
fs.writeFileSync('message[test].txt', 'Hello Test');
afs.readFileSync('message.txt'); // Hello TestIn-Memory filesystem
import MemoryFS from 'memory-fs';
import AdaptiveFS from 'arc-fs';
const mfs = new MemoryFS();
const afs = new AdaptiveFS({ fs:mfs, flags:['test'] });
mfs.writeFileSync('message[test].txt', 'Hello Test');
afs.readFileSync('message.txt'); // Hello Test2.0.6
4 years ago
2.0.0
6 years ago
2.0.0-alpha.2
7 years ago
2.0.0-alpha.1
7 years ago
2.0.0-alpha.0
8 years ago