stc-file
v1.0.5
Published
Virtual file for stc
Downloads
42
Readme
stc-file
Virtual File for stc
How to use
import File from 'stc-file';
let file = new File({
cwd: '', //current work path
base: '', //base name
path: 'path/to/file', //file path
stat: null //file stat
});
API
path
get or set file path.
file.path = 'xxx';
file.path;
extname
get or set file extname.
file.extname; // html
file.extname = 'txt'; //
stat
get or set file stat.
let stat = file.stat;
file.stat = stat;
isFile()
let isFile = file.isFile();
isDirectory()
let isDirectory = file.isDirectory();
pipe(stream, opt)
pipe file stream to another stream.
file.pipe(stream, {
end: true
});
isPath(filepath)
check file path
getContent(encoding)
get file content,
encoding
default isnull
setContent(content)
hasAst()
check file aleady have ast
getAst()
setAst(ast)
prop(name, value)
get or set other property for file