Socket
Socket
Sign inDemoInstall

file-timestamp-stream

Package Overview
Dependencies
15
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.1.1

5

CHANGELOG.md
# Changelog
## v2.1.1 2018-09-17
* Do not use `timers-obj` as far as pure NodeJS timers have better support for
debugging.
## v2.1.0 2018-09-17

@@ -4,0 +9,0 @@

22

lib/file-timestamp-stream.js

@@ -7,6 +7,4 @@ "use strict";

const stream_1 = require("stream");
const timers_obj_1 = require("timers-obj");
const stream_finished_1 = tslib_1.__importDefault(require("stream.finished"));
const ultra_strftime_1 = tslib_1.__importDefault(require("ultra-strftime"));
// tslint:disable-next-line:no-var-requires
const finished = require('stream.finished'); // TODO: wait for new typings for node
class FileTimestampStream extends stream_1.Writable {

@@ -93,4 +91,4 @@ constructor(options = {}) {

if (this.closers.size > 0) {
for (const timer of this.closers.values()) {
timer.remove();
for (const closer of this.closers.values()) {
clearInterval(closer);
}

@@ -118,3 +116,3 @@ this.streams.clear();

if (currentFilename && stream && closer) {
closer.remove();
clearInterval(closer);
stream.end();

@@ -137,13 +135,13 @@ const streamErrorHandler = this.streamErrorHandlers.get(currentFilename);

this.streamErrorHandlers.set(newFilename, newStreamErrorHandler);
const newTimer = timers_obj_1.interval(FileTimestampStream.CLOSE_UNUSED_FILE_AFTER, () => {
const newCloser = setInterval(() => {
if (newFilename !== this.newFilename()) {
newTimer.remove();
clearInterval(newCloser);
this.closers.delete(newFilename);
newStream.end();
}
});
}, FileTimestampStream.CLOSE_UNUSED_FILE_AFTER);
this.closer = closer;
this.closers.set(newFilename, newTimer);
const newStreamCancelFinisher = finished(newStream, () => {
newTimer.remove();
this.closers.set(newFilename, newCloser);
const newStreamCancelFinisher = stream_finished_1.default(newStream, () => {
clearInterval(newCloser);
this.closers.delete(newFilename);

@@ -150,0 +148,0 @@ // tslint:disable-next-line:strict-type-predicates

{
"name": "file-timestamp-stream",
"version": "2.1.0",
"version": "2.1.1",
"description": "Writing stream with file rotating based on timestamp",

@@ -26,4 +26,3 @@ "main": "lib/file-timestamp-stream.js",

"dependencies": {
"stream.finished": "^1.0.1",
"timers-obj": "^0.2.1",
"stream.finished": "^1.1.0",
"tslib": "^1.9.3",

@@ -35,7 +34,7 @@ "ultra-strftime": "^1.0.2"

"@types/mocha": "^5.2.5",
"@types/node": "^10.9.4",
"@types/node": "^10.10.1",
"@types/ultra-strftime": "^1.0.0",
"chai": "^4.1.2",
"coveralls": "^3.0.2",
"eslint": "^5.5.0",
"eslint": "^5.6.0",
"eslint-config-standard": "^12.0.0",

@@ -42,0 +41,0 @@ "eslint-plugin-import": "^2.14.0",

@@ -123,2 +123,6 @@ # file-timestamp-stream

### Warning
This stream have to be closed to free own streams and timers.
## License

@@ -125,0 +129,0 @@

@@ -5,8 +5,5 @@ /// <reference types="node" />

import { Writable, WritableOptions } from 'stream'
import { interval, Interval } from 'timers-obj'
import finished from 'stream.finished'
import strftime from 'ultra-strftime'
// tslint:disable-next-line:no-var-requires
const finished = require('stream.finished') as (stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, callback?: (err: NodeJS.ErrnoException) => void) => () => void // TODO: wait for new typings for node
export interface FileTimestampStreamOptions extends WritableOptions {

@@ -37,4 +34,4 @@ /** a string with [flags](https://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback) for opened stream (default: `'a'`) */

private streamErrorHandlers: Map<string, (err: Error) => void> = new Map()
private closer?: Interval
private closers: Map<string, Interval> = new Map()
private closer?: NodeJS.Timer
private closers: Map<string, NodeJS.Timer> = new Map()

@@ -120,4 +117,4 @@ constructor (options: FileTimestampStreamOptions = {}) {

if (this.closers.size > 0) {
for (const timer of this.closers.values()) {
timer.remove()
for (const closer of this.closers.values()) {
clearInterval(closer)
}

@@ -150,3 +147,3 @@ this.streams.clear()

if (currentFilename && stream && closer) {
closer.remove()
clearInterval(closer)
stream.end()

@@ -174,5 +171,5 @@

const newTimer = interval(FileTimestampStream.CLOSE_UNUSED_FILE_AFTER, () => {
const newCloser = setInterval(() => {
if (newFilename !== this.newFilename()) {
newTimer.remove()
clearInterval(newCloser)
this.closers.delete(newFilename)

@@ -182,8 +179,8 @@

}
})
}, FileTimestampStream.CLOSE_UNUSED_FILE_AFTER)
this.closer = closer
this.closers.set(newFilename, newTimer)
this.closers.set(newFilename, newCloser)
const newStreamCancelFinisher = finished(newStream, () => {
newTimer.remove()
clearInterval(newCloser)
this.closers.delete(newFilename)

@@ -190,0 +187,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc