Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

cfs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cfs

Conditional file streams

Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Node.js: conditional file streams

build status Coverage Status

Write to a file stream based upon some condition. Currently only writable fs streams.

Why?

Maybe you want to have just one writable file stream in your application and based upon the date, it writes to different files.

Usage

npm install -g cfs

Example

var cfs = require('cfs')
var ymd = require('ymd')

var options = {
  flags: 'a',
  encoding: 'utf8',
  mode: parseInt('666', 8)
}

var logWriter = cfs.createWriteStream(function(data, encoding) {
  // get date in YYYY-MM-dd
  var date = ymd(new Date())
  return date + '.txt'
}, options)

logWriter.write(someLogData)

License

MIT

Keywords

fs

FAQs

Package last updated on 03 Feb 2015

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