stc-file

1.0.5 • Public • Published

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 is null

setContent(content)

hasAst()

check file aleady have ast

getAst()

setAst(ast)

prop(name, value)

get or set other property for file

Readme

Keywords

none

Package Sidebar

Install

npm i stc-file

Weekly Downloads

11

Version

1.0.5

License

none

Last publish

Collaborators

  • welefen