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

tail

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tail - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

28

lib/tail.js

@@ -33,16 +33,24 @@ // Generated by CoffeeScript 2.3.1

if (this.queue.length > 0) {
return this.internalDispatcher.emit("next");
this.internalDispatcher.emit("next");
}
if (this.flushAtEOF && this.buffer.length > 0) {
this.emit("line", this.buffer);
return this.buffer = '';
}
});
return stream.on('data', (data) => {
var chunk, i, len, parts, results;
this.buffer += data;
parts = this.buffer.split(this.separator);
this.buffer = parts.pop();
results = [];
for (i = 0, len = parts.length; i < len; i++) {
chunk = parts[i];
results.push(this.emit("line", chunk));
if (this.separator === null) {
return this.emit("line", data);
} else {
this.buffer += data;
parts = this.buffer.split(this.separator);
this.buffer = parts.pop();
results = [];
for (i = 0, len = parts.length; i < len; i++) {
chunk = parts[i];
results.push(this.emit("line", chunk));
}
return results;
}
return results;
});

@@ -58,3 +66,3 @@ }

this.filename = filename;
({separator: this.separator = /[\r]{0,1}\n/, fsWatchOptions: this.fsWatchOptions = {}, fromBeginning: this.fromBeginning = false, follow: this.follow = true, logger: this.logger, useWatchFile: this.useWatchFile = false, encoding: this.encoding = "utf-8"} = options);
({separator: this.separator = /[\r]{0,1}\n/, fsWatchOptions: this.fsWatchOptions = {}, fromBeginning: this.fromBeginning = false, follow: this.follow = true, logger: this.logger, useWatchFile: this.useWatchFile = false, flushAtEOF: this.flushAtEOF = false, encoding: this.encoding = "utf-8"} = options);
if (this.logger) {

@@ -61,0 +69,0 @@ this.logger.info("Tail starting...");

@@ -17,3 +17,3 @@ {

],
"version": "1.3.0",
"version": "1.4.0",
"homepage": "https://www.lucagrulla.com/node-tail",

@@ -20,0 +20,0 @@ "repository": {

@@ -12,3 +12,3 @@ # Tail

# Installation
## Installation

@@ -19,3 +19,4 @@ ```bash

# Use:
## Use:
```javascript

@@ -42,2 +43,3 @@ Tail = require('tail').Tail;

To start watching again:
```javascript

@@ -47,3 +49,3 @@ tail.watch()

# Configuration
## Configuration
The only mandatory parameter is the path to the file to tail.

@@ -63,19 +65,22 @@

# Available parameters:
## Available parameters
* `separator`: the line separator token (default `/[\r]{0,1}\n/` to handle linux/mac (9+)/windows)
* `fsWatchOptions`: the full set of options that can be passed to `fs.watch` as per node documentation (default: {})
* `fromBeginning`: forces the tail of the file from the very beginning of it instead of from the first new line that will be appended (default: `false`)
* `follow`: simulate `tail -F` option. In the case the file is moved/renamed (or logrotated), if set to `true` `tail` will try to start tailing again after a 1 second delay, if set to `false` it will just emit an error event (default: `true`)
* `separator`: the line separator token (default: `/[\r]{0,1}\n/` to handle linux/mac (9+)/windows). Pass null if your file is binary there's no line separator.
* `fsWatchOptions`: the full set of options that can be passed to `fs.watch` as per node documentation (default: {}).
* `fromBeginning`: forces the tail of the file from the very beginning of it instead of from the first new line that will be appended (default: `false`).
* `follow`: simulate `tail -F` option. In the case the file is moved/renamed (or logrotated), if set to `true` `tail` will try to start tailing again after a 1 second delay, if set to `false` it will just emit an error event (default: `true`).
* `logger`: a logger object(default: no logger). The passed logger has to respond to two methods:
* `info([data][, ...])`
* `error([data][, ...])`
* `useWatchFile`: if set to `true` will force the use of `fs.watchFile` rather than delegating to the library the choice between `fs.watch` and `fs.watchFile` (default: `false`)
* `encoding`: the encoding of the file to tail (default:`utf-8`)
* `info([data][, ...])`
* `error([data][, ...])`
* `useWatchFile`: if set to `true` will force the use of `fs.watchFile` rather than delegating to the library the choice between `fs.watch` and `fs.watchFile` (default: `false`).
* `encoding`: the encoding of the file to tail (default:`utf-8`).
* `flushAtEOF`: set to `true` if you want to force flush of content when end of file is reached. Particularly useful when there's no separator character at the end of the file (default: `false`).
# Emitted events
## Emitted events
`Tail` emits two events:
* line
```
```javascript
function(data){

@@ -85,8 +90,10 @@ console.log(data)

```
* error
```
```javascript
function(exception){}
```
# Want to fork?
## How to contribute

@@ -97,7 +104,8 @@ Tail is written in [CoffeeScript](http://jashkenas.github.com/coffee-script/).

# Why tail was born?
## History
Tail was born as part of a data firehose. Read about it [here](https://www.lucagrulla.com/posts/building-a-firehose-with-nodejs/).
# License
## License
MIT. Please see License file for more details.
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