Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
file-timestamp-stream
Advanced tools
Changelog
v2.2.3 2019-07-10
Readme
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 ES6 with Node >= 6.
npm install file-timestamp-stream
Additionally for Typescript:
npm install -D @types/node
Example:
const {FileTimestampStream} = require("file-timestamp-stream")
Typescript:
import FileTimestampStream from "file-timestamp-stream"
// or
import {FileTimestampStream} from "file-timestamp-stream"
flags
is a string with
flags
for 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 overriden in subclass.
The method generates a filename for new files. By default it returns 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 custom subclass:
currentFilename
contains last opened filenamestream
contains current
fs.WriteStream
objectPath can contain strftime specifiers.
This stream have to be closed to free own streams and timers.
Copyright (c) 2017-2019 Piotr Roszatycki piotr.roszatycki@gmail.com
FAQs
Writing stream with file rotating based on timestamp
The npm package file-timestamp-stream receives a total of 220 weekly downloads. As such, file-timestamp-stream popularity was classified as not popular.
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 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.