fs-promise-polyfill

1.1.3 • Public • Published

fs API promise

fs API promise file

  const fs = require('fs-promise-polyfill')
  fs.readFile(path).then(data => {
    console.log(data)
  })

Even a synchronous API, it does not need to use try-catch

  // return the data or instanceof Error
  const data = fs.readFileSync(path, 'utf-8')
  console.log(data instanceof Error)
  console.log(data)
  // or
  // return the data or null
  const data = fs.readFileSyncNull(path, 'utf-8')
  console.log(data)
  // or
  fs.readFileSyncP(path, 'utf-8').then(data => {
    console.log(data)
  })

API List

  • for native
    • constants
    • Stats
    • F_OK
    • R_OK
    • W_OK
    • X_OK
    • access
    • accessSync
    • exists
    • existsSync
    • readFile
    • readFileSync
    • close
    • closeSync
    • open
    • openSync
    • read
    • readSync
    • write
    • writeSync
    • rename
    • renameSync
    • truncate
    • truncateSync
    • ftruncate
    • ftruncateSync
    • rmdir
    • rmdirSync
    • fdatasync
    • fdatasyncSync
    • fsync
    • fsyncSync
    • mkdir
    • mkdirSync
    • readdir
    • readdirSync
    • fstat
    • lstat
    • stat
    • fstatSync
    • lstatSync
    • statSync
    • readlink
    • readlinkSync
    • symlink
    • symlinkSync
    • link
    • linkSync
    • unlink
    • unlinkSync
    • fchmod
    • fchmodSync
    • chmod
    • chmodSync
    • fchown
    • fchownSync
    • chown
    • chownSync
    • _toUnixTimestamp
    • utimes
    • utimesSync
    • futimes
    • futimesSync
    • writeFile
    • writeFileSync
    • appendFile
    • appendFileSync
    • watch
    • watchFile
    • unwatchFile
    • realpathSync
    • realpath
    • mkdtemp
    • mkdtempSync
    • copyFile
    • copyFileSync
    • createReadStream
    • ReadStream
    • FileReadStream
    • createWriteStream
    • WriteStream
    • FileWriteStream
  • extensions
    • exsits
    • exsitsSync
    • mkdirSync

Readme

Keywords

none

Package Sidebar

Install

npm i fs-promise-polyfill

Weekly Downloads

463

Version

1.1.3

License

ISC

Unpacked Size

8.51 kB

Total Files

13

Last publish

Collaborators

  • huoqishi