Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rotating-file-stream

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rotating-file-stream - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

20

compress.js

@@ -15,3 +15,3 @@ "use strict";

if(this.options.rotate == count)
if(this.options.rotate === count)
delete this.rotatedName;

@@ -34,3 +34,3 @@

try {
prevName = count == 1 ? this.name : this.generator(count - 1);
prevName = count === 1 ? this.name : this.generator(count - 1);
thisName = this.generator(count);

@@ -45,3 +45,3 @@ }

if(err) {
if(err.code != "ENOENT")
if(err.code !== "ENOENT")
return callback(err);

@@ -71,3 +71,3 @@

if(count != 1)
if(count !== 1)
return doIt(self.classical.bind(self, count - 1));

@@ -87,3 +87,3 @@

if(err.code != "ENOENT")
if(err.code !== "ENOENT")
return callback(err);

@@ -123,3 +123,3 @@

if(typeof self.options.compress == "function")
if(typeof self.options.compress === "function")
self.external(tmp, name, done);

@@ -195,8 +195,8 @@ else

}
catch(err) {
return process.nextTick(callback.bind(null, err));
catch(e) {
return process.nextTick(callback.bind(null, e));
}
fs.stat(name, function(err) {
if((! err) || err.code != "ENOENT") {
if((! err) || err.code !== "ENOENT") {
if(name in attempts)

@@ -232,3 +232,3 @@ attempts[name]++;

fs.open(name, "a", function(err, fd) {
if(err && err.code != "ENOENT" && ! retry)
if(err && err.code !== "ENOENT" && ! retry)
return callback(err);

@@ -235,0 +235,0 @@

@@ -17,6 +17,6 @@ "use strict";

if(typeof filename == "function")
if(typeof filename === "function")
this.generator = filename;
else
if(typeof filename == "string") {
if(typeof filename === "string") {
if(options.rotate)

@@ -132,3 +132,3 @@ this.generator = utils.createClassical(filename);

for(var i in arguments) {
if("function" == typeof arguments[i]) {
if("function" === typeof arguments[i]) {
this.once("finish", arguments[i]);

@@ -170,3 +170,3 @@

if(err) {
if(err.code == "ENOENT")
if(err.code === "ENOENT")
return self.open();

@@ -217,3 +217,3 @@

fs.rename(self.name, name, function(err) {
if(err && err.code != "ENOENT" && ! retry)
if(err && err.code !== "ENOENT" && ! retry)
return callback(err);

@@ -262,3 +262,3 @@

stream.once("error", function(err) {
if(err.code != "ENOENT" && ! retry)
if(err.code !== "ENOENT" && ! retry)
return callback(err);

@@ -287,5 +287,5 @@

for(var i in interval)
for(i in interval)
RotatingFileStream.prototype[i] = interval[i];
module.exports = RotatingFileStream;

@@ -19,10 +19,10 @@ "use strict";

if(unit == "d")
if(unit === "d")
hours = 0;
else
hours = parseInt(hours / num) * num;
hours = parseInt(hours / num, 10) * num;
this.prev = new Date(year, month, day, hours, 0, 0, 0).getTime();
if(unit == "d")
if(unit === "d")
this.next = new Date(year, month, day + num, hours, 0, 0, 0).getTime();

@@ -40,3 +40,3 @@ else

if(unit == "d" || unit == "h") {
if(unit === "d" || unit === "h") {
this._interval(now);

@@ -47,6 +47,6 @@ }

if(unit == "m")
if(unit === "m")
period *= 60;
this.prev = parseInt(now / period) * period;
this.prev = parseInt(now / period, 10) * period;
this.next = this.prev + period;

@@ -53,0 +53,0 @@ }

{
"name": "rotating-file-stream",
"version": "1.1.5",
"version": "1.1.6",
"description": "Opens a stream.Writable to a file rotated by interval and/or size. A logrotate alternative.",
"engines": {
"node": ">=0.11"
},
"scripts": {
"all": "npm run npmignore && npm run eslint && npm run coverage",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --recursive test",
"jshint": "./node_modules/.bin/jshint *.js test",
"npmignore": "echo '.gitignore\\n.jshintrc\\n.travis.yml\\nsleep.js\\ntest' > .npmignore ; cat .gitignore >> .npmignore",
"t": "./node_modules/.bin/_mocha test",
"test": "npm run npmignore && npm run jshint && npm run coverage"
"eslint": "./node_modules/.bin/eslint *.js test/*js",
"npmignore": "echo '.codeclimate.yml\\n.eslintrc\\n.gitignore\\n.travis.yml\\ntest' > .npmignore ; cat .gitignore >> .npmignore",
"test": "./node_modules/.bin/_mocha test"
},

@@ -22,2 +19,5 @@ "bugs": "https://github.com/iccicci/rotating-file-stream/issues",

],
"engines": {
"node": ">=0.11"
},
"author": "Daniele Ricci <daniele.icc@gmail.com> (https://github.com/iccicci)",

@@ -33,7 +33,7 @@ "contributors": [

"devDependencies": {
"eslint": "3.14.1",
"istanbul": "0.4.5",
"jshint": "2.9.4",
"mocha": "3.2.0",
"mocha-istanbul": "0.3.0"
"mocha-istanbul": "0.3.0",
"mocha": "3.2.0"
}
}

@@ -36,3 +36,3 @@ # rotating-file-stream

```sh
npm install rotating-file-stream
$ npm install --save rotating-file-stream
```

@@ -114,7 +114,5 @@

* compress: {String|Function|True} (default: null) Specifies compression method of rotated files.
* highWaterMark: {Number} (default: null) Proxied to [new stream.Writable]
(https://nodejs.org/api/stream.html#stream_constructor_new_stream_writable_options)
* highWaterMark: {Number} (default: null) Proxied to [new stream.Writable](https://nodejs.org/api/stream.html#stream_constructor_new_stream_writable_options)
* interval: {String} (default: null) Specifies the time interval to rotate the file.
* mode: {Integer} (default: null) Proxied to [fs.createWriteStream]
(https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options)
* mode: {Integer} (default: null) Proxied to [fs.createWriteStream](https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options)
* path: {String} (default: null) Specifies the base path for files.

@@ -240,7 +238,7 @@ * rotate: {Integer} (default: null) Enables the classical UNIX __logrotate__ behaviour.

// here are reported blocking errors
// once this event is fired, the stream will be closed as well
// once this event is emitted, the stream will be closed as well
});
stream.on('open', function() {
// no rotated file is open (fired after each rotation as well)
// no rotated file is open (emitted after each rotation as well)
});

@@ -276,3 +274,3 @@

The package sets a [Timeout](https://nodejs.org/api/timers.html#timers_settimeout_callback_delay_arg)
The package sets a [Timeout](https://nodejs.org/api/timers.html#timers_settimeout_callback_delay_args)
to start a rotation job at the right moment.

@@ -313,2 +311,4 @@

* 2017-02-03 - v1.1.6
* eslint
* 2017-01-23 - v1.1.5

@@ -315,0 +315,0 @@ * README fix

@@ -9,3 +9,3 @@ "use strict";

ret.num = parseInt(v);
ret.num = parseInt(v, 10);

@@ -41,3 +41,3 @@ if(isNaN(ret.num))

case "m":
if(parseInt(60 / ret.num) * ret.num != 60)
if(parseInt(60 / ret.num, 10) * ret.num !== 60)
throw new Error("An integer divider of 60 is expected as minutes for 'options.interval'");

@@ -47,3 +47,3 @@ break;

case "h":
if(parseInt(24 / ret.num) * ret.num != 24)
if(parseInt(24 / ret.num, 10) * ret.num !== 24)
throw new Error("An integer divider of 24 is expected as hours for 'options.interval'");

@@ -53,3 +53,3 @@ break;

case "s":
if(parseInt(60 / ret.num) * ret.num != 60)
if(parseInt(60 / ret.num, 10) * ret.num !== 60)
throw new Error("An integer divider of 60 is expected as seconds for 'options.interval'");

@@ -72,9 +72,9 @@ break;

if(ret.unit == "K")
if(ret.unit === "K")
return ret.num * 1024;
if(ret.unit == "M")
if(ret.unit === "M")
return ret.num * 1048576;
if(ret.unit == "G")
if(ret.unit === "G")
return ret.num * 1073741824;

@@ -90,12 +90,12 @@

if(typ == "boolean")
if(typ === "boolean")
options.compress = function(src, dst) { return "cat " + src + " | gzip -c9 > " + dst; };
else
if(typ == "string") {
if(typ === "string") {
//if(val != "bzip" && val != "gzip")
if(val != "gzip")
if(val !== "gzip")
throw new Error("Don't know how to handle compression method: " + val);
}
else
if(typ != "function")
if(typ !== "function")
throw new Error("Don't know how to handle 'options.compress' type: " + typ);

@@ -107,3 +107,3 @@ },

"interval": function(typ, options, val) {
if(typ != "string")
if(typ !== "string")
throw new Error("Don't know how to handle 'options.interval' type: " + typ);

@@ -117,3 +117,3 @@

"path": function(typ) {
if(typ != "string")
if(typ !== "string")
throw new Error("Don't know how to handle 'options.path' type: " + typ);

@@ -123,5 +123,5 @@ },

"rotate": function(typ, options, val) {
var rotate = parseInt(val);
var rotate = parseInt(val, 10);
if(rotate != val || rotate <= 0)
if(rotate !== val || rotate <= 0 || typ !== "number")
throw new Error("'rotate' option must be a positive integer number");

@@ -133,3 +133,3 @@ },

"size": function(typ, options, val) {
if(typ != "string")
if(typ !== "string")
throw new Error("Don't know how to handle 'options.size' type: " + typ);

@@ -145,3 +145,3 @@

if(typeof options != "object")
if(typeof options !== "object")
throw new Error("Don't know how to handle 'options' type: " + typeof options);

@@ -197,3 +197,3 @@

if(e) {
if(e.code == "ENOENT")
if(e.code === "ENOENT")
return makePath(dir, callback);

@@ -200,0 +200,0 @@

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