rxfile-write
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i rxfile-write

Weekly Downloads

3

Version

0.0.8

License

MIT

Unpacked Size

32.7 kB

Total Files

10

Last publish

Collaborators

  • srxboys