fso - FileSystemObject
fso - FileSystemObject is a objective fs interface like Pathname(ruby).
Installation
npm install fso
Usage
node.js:
var fso = default;var FileSystemObject = FileSystemObject;
ES2015:
;
API
API Documents (with type annotations)
objective methods
constructor
var abc = "a" "b" "c";abc === "a/b/c"
new / join
dir = fso;a = dir;a;
parent
dir = fso;p = dirparent;dir = p;
children, childrenSync
dir = fso;files = dir;
childrenAll, childrenAllSync
dir = fso;files = dir;
filteredChildren, filteredChildrenSync, filteredChildrenAll, filteredChildrenAllSync
excepts = "ignore_file" "path/to/ignore_directory";entries = target;
// Sync entry;files = target; // childrenSync() minus directories
// Promise form condition also OK when Promise form call entry;files = await target;
// callback form also OK when callback form call entry;target;
path
path / toString
fooPath = fsopath;fooPath = fso;
'fs' API
Supports all the node.js 'fs' APIs that needs no first path argument.
method(...args, callback)
, methodSync(...args)
and promise = method(...args)
one file args
fs;// isfile = fso;file;
two file args
fs;// isfile = fso;file;
fd args
fd = fs;fs;fs;// isfile = fso;file;file;file;
convenient additional
mkdirAll
fso;
mkdirp (= mkdirAll)
mkpath (= mkdirAll)
readdirAll
dir// results'a.txt' 'aa' 'aa/a.txt' 'aa/b' 'aa/b/c.txt'
rmAll
await dir;
rmtree (= rmAll)
mergeDirectory
target;
copy:
target;target;
filteredMergeDirectory
excepts = "ignore_file" "path/to/ignore_directory";target;
entrypath === "ignore_file" || entrypath === "path/to/ignore_directory";target;
isChildOf
dir
isParentOf
dir
path methods
(property) delimiter
fsodelimiter; // ":" or ";"
(property) sep
fsosep; // "/" or "\\"
(static) format
var entry = FileSystemObject;
parse
var parsedObject = fso;
normalize
fso; // same as fso.new("a")
basename
fso; // same as new FileSystemObject("c")
dirname
same as parent()
extname
fso; // ".txt"
isAbsolute
fso === true
relative
fso; // same as new FileSystemObject("../d")fso; // same as new FileSystemObject("../d")
resolve
fso // same as new FileSystemObject("/a/b/c")
License
This is released under Zlib License.