
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
file-timestamp-stream
Advanced tools
This module creates stream.Writable to a file which is automatically rotated based on current time and uses strftime template for file names.
This module requires ES2021 with Node >= 16.
npm install file-timestamp-stream
Additionally for Typescript:
npm install -D @types/node
Example:
import FileTimestampStream from "file-timestamp-stream"
// or
import {FileTimestampStream} from "file-timestamp-stream"
flags
is a string with
flags
for the opened stream (default: 'a'
)fs
is a custom fs module (optional)path
is a template for new filenames (default: 'out.log'
)Example:
Basic path based on strftime
parameters:
const stream = new FileTimestampStream({
path: "%Y-%m-%dT%H.log",
flags: "a",
})
This method can be overridden in the subclass.
The method generates a filename for new files. By default, it returns a new filename based on path and current time.
Example:
import strftime from "ultra-strftime"
class MyFileTimestampStream extends FileTimestampStream {
/** count how many files has been created */
counter = 0
// for pure Javascript explicit constructor is necessary
// constructor (options) { super(options); this.counter = 0 }
protected newFilename(): string {
const filename = strftime(this.path)
if (filename !== this.currentFilename) this.counter++
return filename
}
}
const stream = new MyFileTimestampStream({
path: "%Y-%m-%dT%H:%M.log",
})
Readonly public properties based on contructor's options:
flags
fs
path
Protected properties for a custom subclass:
currentFilename
contains the last opened filenamestream
contains current
fs.WriteStream
objectA path can contain strftime specifiers.
This stream has to be closed to free streams and timers.
Copyright (c) 2017-2024 Piotr Roszatycki piotr.roszatycki@gmail.com
v3.0.0 2024-06-26
FAQs
Writing stream with file rotating based on timestamp
We found that file-timestamp-stream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.