Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Converted to ESM module.
- Requires Node >= 16.
- Uses timers-obj@3.

## v2.2.4 2019-10-07

Expand Down
5 changes: 3 additions & 2 deletions examples/ticker-ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import FileTimestampStream from "../src/file-timestamp-stream.js"

import * as timers from "timers-obj"
import strftime from "ultra-strftime"

class MyFileTimestampStream extends FileTimestampStream {
Expand All @@ -23,8 +24,8 @@ const stream = new MyFileTimestampStream({
path: "%Y-%m-%dT%H:%M:%S.log",
})

setInterval(() => {
timers.interval(800, () => {
const date = new Date()
stream.write(`tick: ${date}\r\n`)
stream.countWrittenLines()
}, 800)
})
5 changes: 3 additions & 2 deletions examples/ticker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import FileTimestampStream from "../lib/file-timestamp-stream.js"

import * as timers from "timers-obj"
import strftime from "ultra-strftime"

class MyFileTimestampStream extends FileTimestampStream {
Expand All @@ -23,8 +24,8 @@ const stream = new MyFileTimestampStream({
path: "%Y-%m-%dT%H:%M:%S.log",
})

setInterval(() => {
timers.interval(800, () => {
const date = new Date()
stream.write(`tick: ${date}\r\n`)
stream.countWrittenLines()
}, 800)
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"node": ">=16.0.0"
},
"dependencies": {
"timers-obj": "^2.1.0",
"timers-obj": "^3.0.0",
"ultra-strftime": "^1.0.2"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/file-timestamp-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class FileTimestampStream extends Writable {
}
if (this.closers.size > 0) {
for (const closer of this.closers.values()) {
closer.remove()
closer.close()
}
this.streams.clear()
}
Expand Down Expand Up @@ -165,7 +165,7 @@ export class FileTimestampStream extends Writable {

const newCloser = timers.interval(FileTimestampStream.CLOSE_UNUSED_FILE_AFTER, () => {
if (newFilename !== this.newFilename()) {
newCloser.remove()
newCloser.close()
this.closers.delete(newFilename)
newStream.end()
}
Expand All @@ -174,7 +174,7 @@ export class FileTimestampStream extends Writable {
this.closers.set(newFilename, newCloser)

const newStreamCancelFinisher = finished(newStream, () => {
newCloser.remove()
newCloser.close()
this.closers.delete(newFilename)

if (typeof newStream.destroy === "function") {
Expand Down