0.0.3 • Published 7 years ago

file-chain v0.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

📒⛓ file-chain

NPM version MIT License fliphub flipfam

fluent api for File operations, with concurrency safe read/writes & plugins

📦 install

yarn add file-chain
npm i file-chain --save

👽 use

const File = require('file-chain')

// can also import destructured
// const {File} = require('file-chain')

📘 examples

const datas = File
  .init()
  .dir(__dirname)
  .src('./index.js')
  .load()
  .json()
  .setIfNotEmpty({eh: true})
  .update({moose: true})
  .parse() // optional, is done for you
  .clean()
  .write()

const stats = datas
  .getStats() // read stats
  .del() // delete file
  .info() // stats are already loaded

👣 dir

const file = File
  .src('./index.js')
  .dir(__dirname)
  .load(true)
  .setContent('...')
  .prependContent('alpha')
  .appendContent('omega')
  .write() // alpha...omega

🔌 plugins

const plugin = {
  setContentToMagic() {
    this.contents = 'magic'
    return this
  }
}

const file = new File()

file
  .use(plugin)
  .src('./index.js')
  .dir(__dirname)
  .setContentToMagic()
  .write()

🔗 more