2
2
3
3
import fs , { WriteStream } from 'fs'
4
4
import { Writable , WritableOptions } from 'stream'
5
- import { interval , Interval } from 'timers-obj'
6
5
import strftime from 'ultra-strftime'
7
6
8
7
// tslint:disable-next-line:no-var-requires
@@ -33,8 +32,8 @@ export class FileTimestampStream extends Writable {
33
32
private streams : Map < string , WriteStream > = new Map ( )
34
33
private streamCancelFinishers : Map < string , ( ) => void > = new Map ( )
35
34
private streamErrorHandlers : Map < string , ( err : Error ) => void > = new Map ( )
36
- private closer ?: Interval
37
- private closers : Map < string , Interval > = new Map ( )
35
+ private closer ?: NodeJS . Timer
36
+ private closers : Map < string , NodeJS . Timer > = new Map ( )
38
37
39
38
constructor ( options : FileTimestampStreamOptions = { } ) {
40
39
super ( options )
@@ -115,8 +114,8 @@ export class FileTimestampStream extends Writable {
115
114
this . streams . clear ( )
116
115
}
117
116
if ( this . closers . size > 0 ) {
118
- for ( const timer of this . closers . values ( ) ) {
119
- timer . remove ( )
117
+ for ( const closer of this . closers . values ( ) ) {
118
+ clearInterval ( closer )
120
119
}
121
120
this . streams . clear ( )
122
121
}
@@ -144,7 +143,7 @@ export class FileTimestampStream extends Writable {
144
143
145
144
if ( newFilename !== currentFilename ) {
146
145
if ( currentFilename && stream && closer ) {
147
- closer . remove ( )
146
+ clearInterval ( closer )
148
147
stream . end ( )
149
148
150
149
const streamErrorHandler = this . streamErrorHandlers . get ( currentFilename )
@@ -167,19 +166,19 @@ export class FileTimestampStream extends Writable {
167
166
newStream . on ( 'error' , newStreamErrorHandler )
168
167
this . streamErrorHandlers . set ( newFilename , newStreamErrorHandler )
169
168
170
- const newTimer = interval ( FileTimestampStream . CLOSE_UNUSED_FILE_AFTER , ( ) => {
169
+ const newCloser = setInterval ( ( ) => {
171
170
if ( newFilename !== this . newFilename ( ) ) {
172
- newTimer . remove ( )
171
+ clearInterval ( newCloser )
173
172
this . closers . delete ( newFilename )
174
173
175
174
newStream . end ( )
176
175
}
177
- } )
176
+ } , FileTimestampStream . CLOSE_UNUSED_FILE_AFTER )
178
177
this . closer = closer
179
- this . closers . set ( newFilename , newTimer )
178
+ this . closers . set ( newFilename , newCloser )
180
179
181
180
const newStreamCancelFinisher = finished ( newStream , ( ) => {
182
- newTimer . remove ( )
181
+ clearInterval ( newCloser )
183
182
this . closers . delete ( newFilename )
184
183
185
184
// tslint:disable-next-line:strict-type-predicates
0 commit comments