file-chain

0.0.3 • Public • Published

📒⛓ 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

Package Sidebar

Install

npm i file-chain

Weekly Downloads

1

Version

0.0.3

License

MIT

Last publish

Collaborators

  • aretecode