Socket
Socket
Sign inDemoInstall

file-timestamp-stream

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-timestamp-stream - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

5

CHANGELOG.md
# Changelog
## v0.2.0 2018-02-02
* Only public interface of Writable is used.
* Implemented `_destroy` method which cleans up file stream.
## v0.1.0 2017-10-24

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

16

lib/file-timestamp-stream.d.ts

@@ -14,13 +14,13 @@ /// <reference types="node" />

export class FileTimestampStream extends Writable {
options: Options
readonly options: Options
flags: string
fs: typeof fs
newFilename: () => string
path: string
readonly flags: string
readonly fs: typeof fs
readonly newFilename: () => string
readonly path: string
currentFilename: string
stream: Writable
currentFilename?: string
stream?: Writable
constructor (options: Options)
constructor (options?: Options)
}

@@ -21,4 +21,8 @@ 'use strict'

this.currentFilename = null
this.stream = null
this.currentFilename = undefined
this.stream = undefined
this._streamErrorHandler = (err) => {
this.emit('error', err)
}
}

@@ -32,3 +36,5 @@

this.stream.end()
this.stream.removeListener('error', this._streamErrorHandler)
}
this.stream = this.fs.createWriteStream(newFilename, {

@@ -38,2 +44,5 @@ flags: this.flags,

})
this.stream.on('error', this._streamErrorHandler)
this.currentFilename = newFilename

@@ -46,17 +55,15 @@ }

this._rotate(encoding)
// call private method (bypass additional buffers)
return this.stream._write(chunk, encoding, callback)
this.stream.write(chunk, encoding, callback)
} catch (e) {
return callback(e)
callback(e)
}
}
_writev (chunks, callback) {
try {
this._rotate('buffer')
// call private method (not supported before node 4.0?)
return this.stream._writev(chunks, callback)
} catch (e) {
return callback(e)
_destroy (err, callback) {
if (this.stream) {
this.stream.destroy()
this.stream.removeListener('error', this._streamErrorHandler)
this.stream = undefined
}
super._destroy(err, callback)
}

@@ -63,0 +70,0 @@ }

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

@@ -5,0 +5,0 @@ "main": "lib/file-timestamp-stream.js",

@@ -48,11 +48,6 @@ ## file-timestamp-stream

### Warning
This module uses internal API of `fs.WriteStream`: `_write` and `_writev`
methods directly for maximal performance.
### License
Copyright (c) 2017 Piotr Roszatycki <piotr.roszatycki@gmail.com>
Copyright (c) 2017-2018 Piotr Roszatycki <piotr.roszatycki@gmail.com>
[MIT](https://opensource.org/licenses/MIT)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc