
Security News
The Next Open Source Security Race: Triage at Machine Speed
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.
Writable file stream that can write to different files based upon the condition
of what's being written. i.e. Intead of passing filePath as the first
parameter to your stream, you pass a function that returns the path.
This saves you time because you no longer have to manage many different writable streams.
Best use case is to only have one writable fs stream that writes log files, except the log file path changes depending up the date or log data.
npm i --save cfs
Write log data to different files depending upon the date.
var cfs = require('cfs')
var path = require('path')
var ymd = require('ymd')
var pathFn = function () {
// get date in YYYY-MM-dd
var date = ymd(new Date())
return path.join('/tmp/logs/' + date + '.txt')
}
var logWriter = cfs.createWriteStream(pathFn, { flags: 'a' })
logWriter.write(someLogData)
Write data to different files depending upon what's being written.
Write even numbers to evens.txt and odd numbers to odds.txt.
No need to worry about opening a bunch of files. File descriptors are cached.
var cfs = require('cfs')
var pathFn = function (data) {
if (data == null) return null
if (parseInt(data.toString('utf8'), 10) % 2 === 0) {
return 'evens.txt'
} else {
return 'odds.txt'
}
}
var logWriter = cfs.createWriteStream(pathFn, { flags: 'a' })
logWriter.write(someLogData)
pathFunction: A function that should return the path. Method signature (data, encoding).options: These are the standard options that you'd pass to fs.createWriteStream.
Also, cacheOptions which are the options that you'd pass to lru-cache.MIT
Copyright (c) JP Richardson
FAQs
Conditional file streams
The npm package cfs receives a total of 5 weekly downloads. As such, cfs popularity was classified as not popular.
We found that cfs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.

Research
/Security News
Malicious dYdX client packages were published to npm and PyPI after a maintainer compromise, enabling wallet credential theft and remote code execution.

Security News
gem.coop is testing registry-level dependency cooldowns to limit exposure during the brief window when malicious gems are most likely to spread.