1. file-save
auto create path and just save the file!
file-save
Package: file-save
Created by: chilijung
Last modified: Fri, 09 Dec 2022 07:32:38 GMT
Version: 0.2.0
License: MIT
Downloads: 13,698
Repository: https://github.com/chilijung/file-save

Install

npm install file-save
yarn add file-save

Streaming saving file

Build Status

Streaming data to file and save it using Stream.(the module will make directory itself if the directory is not exist).

Install

npm install file-save

Example

 var fileSave = require('file-save');

// the first line will create a writeStream to the file path
fileSave('sample/test')
    .write('this is the first line', 'utf8')
    .write('this is the second line', 'utf8', function() {
        console.log('writer callback')
    })
    .end('this is the end')
    .error(function() {
        console.log('error goes here')
    })
    .finish(function() {
        console.log('write finished.')
    })

Usage

fileSave(<filename>)

file-save module will build a write stream to the file, and automatically make directory if the directory is not exist and need to create.

Chaining methods

.write(chunk, [encoding], [callbak])

  • chunk (string)
  • encoding (string): like the encoding settings in writeable stream. http://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback
  • callback (function): callback function settings in writeable http://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback

.end([string], [encoding], [callback])

Same as .write method, but string is also optional.

.error(callback)

You can make a callback, while the stream prompt error

see more: http://nodejs.org/api/stream.html#stream_event_error_1

.finish(callback)

Make a callback while finished, **using this method you have to call ** .foot before calling this method

see more: http://nodejs.org/api/stream.html#stream_event_finish

License

MIT @chilijung

Dependencies

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin