file-timestamp-stream
Advanced tools
Comparing version 0.4.0 to 0.5.0
# Changelog | ||
## v0.5.0 2018-02-15 | ||
* Implemented `_writev` method which corks file stream, then makes this writter | ||
fast enough. | ||
## v0.4.0 2018-02-04 | ||
* Support `import FileTimestampStream from 'file-timestamp-stream'` syntax. | ||
* Typescript: export options as `FileTimestampStreamOptions`. | ||
* Support `import FileTimestampStream from 'file-timestamp-stream'` syntax. | ||
* Typescript: export options as `FileTimestampStreamOptions`. | ||
## v0.3.1 2018-02-04 | ||
* Better clean up on `destroy`. | ||
* Better clean up on `destroy`. | ||
## v0.3.0 2018-02-03 | ||
* Implemented `_final` method which calls `end` on file stream. | ||
* Implemented `_final` method which calls `end` on file stream. | ||
## v0.2.0 2018-02-02 | ||
* Only public interface of Writable is used. | ||
* Implemented `_destroy` method which cleans up file stream. | ||
* Only public interface of Writable is used. | ||
* Implemented `_destroy` method which cleans up file stream. | ||
## v0.1.0 2017-10-24 | ||
* Exports also as a class and namespace and the default. | ||
* Property `wstream` was renamed to `stream`. | ||
* Typescript: typings added. | ||
* Exports also as a class and namespace and the default. | ||
* Property `wstream` was renamed to `stream`. | ||
* Typescript: typings added. | ||
## v0.0.4 2017-06-22 | ||
* Upgraded chai@4.0.2, standard@10.0.2, tap@10.5.1, tap-given@0.4.1 | ||
* Use snazzy and dirty-chai for tests | ||
* Upgraded chai@4.0.2, standard@10.0.2, tap@10.5.1, tap-given@0.4.1 | ||
* Use snazzy and dirty-chai for tests | ||
## v0.0.3 2017-02-19 | ||
* Upgraded tap-given | ||
* Upgraded tap-given | ||
## v0.0.2 2017-02-17 | ||
* Minor optimizations and better error handling | ||
* BDD tests | ||
* Relicensed to MIT | ||
* Minor optimizations and better error handling | ||
* BDD tests | ||
* Relicensed to MIT | ||
## v0.0.1 2017-02-16 | ||
* Initial release | ||
* Initial release |
@@ -26,3 +26,3 @@ 'use strict' | ||
_rotate (encoding) { | ||
_rotate () { | ||
const newFilename = this.newFilename() | ||
@@ -37,4 +37,3 @@ | ||
this.stream = this.fs.createWriteStream(newFilename, { | ||
flags: this.flags, | ||
encoding: encoding === 'buffer' ? 'utf8' : null | ||
flags: this.flags | ||
}) | ||
@@ -50,3 +49,3 @@ | ||
try { | ||
this._rotate(encoding) | ||
this._rotate() | ||
this.stream.write(chunk, encoding, callback) | ||
@@ -58,2 +57,21 @@ } catch (e) { | ||
_writev (chunks, callback) { | ||
let corked = false | ||
try { | ||
this._rotate() | ||
corked = true | ||
this.stream.cork() | ||
for (const chunk of chunks) { | ||
this.stream.write(chunk.chunk, chunk.encoding) | ||
} | ||
process.nextTick(() => this.stream.uncork()) | ||
callback() | ||
} catch (e) { | ||
if (corked) { | ||
process.nextTick(() => this.stream.uncork()) | ||
} | ||
callback(e) | ||
} | ||
} | ||
_final (callback) { | ||
@@ -60,0 +78,0 @@ if (this.stream) { |
{ | ||
"name": "file-timestamp-stream", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Writing stream with file rotating based on timestamp", | ||
@@ -29,3 +29,3 @@ "main": "lib/file-timestamp-stream.js", | ||
"devDependencies": { | ||
"@types/node": "^9.4.0", | ||
"@types/node": "^9.4.6", | ||
"chai": "^4.1.2", | ||
@@ -32,0 +32,0 @@ "delay": "^2.0.0", |
@@ -1,2 +0,2 @@ | ||
## file-timestamp-stream | ||
# file-timestamp-stream | ||
@@ -9,3 +9,3 @@ [![Build Status](https://secure.travis-ci.org/dex4er/js-file-timestamp-stream.svg)](http://travis-ci.org/dex4er/js-file-timestamp-stream) [![Coverage Status](https://coveralls.io/repos/github/dex4er/js-file-timestamp-stream/badge.svg)](https://coveralls.io/github/dex4er/js-file-timestamp-stream) [![npm](https://img.shields.io/npm/v/file-timestamp-stream.svg)](https://www.npmjs.com/package/file-timestamp-stream) | ||
### Installation | ||
## Installation | ||
@@ -16,3 +16,3 @@ ```shell | ||
### Usage | ||
## Usage | ||
@@ -36,3 +36,3 @@ _Example:_ | ||
#### Options | ||
### Options | ||
@@ -47,3 +47,3 @@ * `newFilename` is a custom function which returns new filename (default: | ||
#### Properties | ||
### Properties | ||
@@ -55,7 +55,7 @@ * `currentFilename` contains last opened filename | ||
#### Path template format | ||
### Path template format | ||
Path can contain [strftime](https://www.npmjs.com/package/strftime) specifiers. | ||
### License | ||
## License | ||
@@ -62,0 +62,0 @@ Copyright (c) 2017-2018 Piotr Roszatycki <piotr.roszatycki@gmail.com> |
8741
113