New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

file-save

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-save

auto create path and just save the file!

  • 0.2.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
551
decreased by-74.49%
Maintainers
1
Weekly downloads
 
Created
Source

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])
.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

Keywords

FAQs

Package last updated on 08 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc