0.0.8 • Published 2 years ago

rxfile-write v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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 / cjs
  const RxfileWrite = require('rxfile-write')
  // or
  import RxfileWrite from 'rxfile-write'
  const path = require('path')

  function ps (p) {
    return path.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

0.0.8

2 years ago

0.0.7

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.6

2 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago