Skip to content

Repository files navigation

RxfileWrite

To -> 中文

Node.js -> fs: Simple use tool

npm i rxfile-write --save-dev
  1. Determine whether the file/directory exists
  2. Read everything in the file
  3. Erase write content to file,or add content to a file
  4. Delete file/directory

Usage

// node / cjsconstRxfileWrite=require('rxfile-write')// orimportRxfileWritefrom'rxfile-write'constpath=require('path')functionps(p){returnpath.resolve(__dirname,'..',p)}// - - RxfileWrite.read - -RxfileWrite.read(ps('LICENSE')).then(data=>{console.log('data\n\n',data)}).catch(err=>{console.log('read error=',err)})// - - RxfileWrite.exists - -RxfileWrite.exists(ps('LICENSE')).then(()=>{console.log('exists is ok')}).catch(err=>{console.log('exists error=',err)})// - - RxfileWrite.write - -RxfileWrite.write(ps('ttt.txt'),'hello world!').then(()=>{console.log('write succ')setTimeout(()=>{// - - RxfileWrite.remove - -RxfileWrite.remove(ps('ttt.txt')).then(()=>{console.log('remove succ')}).catch(err=>{console.log('remove error=',err)})},5000);}).catch(err=>{console.log('write error=',err)})

api

  1. exists
  2. read
  3. cp
  4. cpSync
  5. write
  6. writeSync
  7. writeAppend
  8. writeAppendSync
  9. writeTo
  10. remove

License

MIT

About

node.js - file -> add / remove / read

Resources

Stars

0 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages