{"id":13446749,"url":"https://github.com/lucagrulla/node-tail","last_synced_at":"2025-05-14T19:09:47.493Z","repository":{"id":527431,"uuid":"1929395","full_name":"lucagrulla/node-tail","owner":"lucagrulla","description":"The zero dependency Node.js module for tailing a file","archived":false,"fork":false,"pushed_at":"2023-05-05T14:28:39.000Z","size":1052,"stargazers_count":467,"open_issues_count":13,"forks_count":76,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-30T11:05:50.370Z","etag":null,"topics":["coffeescript","logs","no-dependencies","nodejs","npm-package","tail"],"latest_commit_sha":null,"homepage":"https://www.lucagrulla.com/node-tail/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucagrulla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"lucagrulla"}},"created_at":"2011-06-21T13:59:57.000Z","updated_at":"2025-04-30T09:12:56.000Z","dependencies_parsed_at":"2023-07-05T15:02:23.083Z","dependency_job_id":null,"html_url":"https://github.com/lucagrulla/node-tail","commit_stats":{"total_commits":219,"total_committers":27,"mean_commits":8.11111111111111,"dds":0.3470319634703196,"last_synced_commit":"c448d23d6c2b79f634b019330bff229ff50e026c"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucagrulla%2Fnode-tail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucagrulla%2Fnode-tail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucagrulla%2Fnode-tail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucagrulla%2Fnode-tail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucagrulla","download_url":"https://codeload.github.com/lucagrulla/node-tail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251930128,"owners_count":21666772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coffeescript","logs","no-dependencies","nodejs","npm-package","tail"],"created_at":"2024-07-31T05:00:58.733Z","updated_at":"2025-05-14T19:09:46.286Z","avatar_url":"https://github.com/lucagrulla.png","language":"JavaScript","funding_links":["https://github.com/sponsors/lucagrulla"],"categories":["CoffeeScript","JavaScript"],"sub_categories":[],"readme":"# Tail\n\nThe **zero** dependency Node.js module for tailing a file\n\n[![NPM](https://nodei.co/npm/tail.png?downloads=true\u0026downloadRank=true)](https://nodei.co/npm/tail.png?downloads=true\u0026downloadRank=true)\n\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/lucagrulla/node-tail/blob/master/LICENSE)\n[![npm](https://img.shields.io/npm/v/tail.svg?style=plastic)](https://www.npmjs.com/package/tail)\n![npm](https://img.shields.io/npm/dm/tail.svg)\n\nMade with ❤️ by [Luca Grulla](https://www.lucagrulla.com) \n\n1. TOC\n{:toc}\n\n## Installation\n\n```bash\nnpm install tail\n```\n\n## Use\n\n```javascript\nTail = require(\"tail\").Tail;\n\ntail = new Tail(\"fileToTail\");\n\ntail.on(\"line\", function(data) {\n  console.log(data);\n});\n\ntail.on(\"error\", function(error) {\n  console.log(\"ERROR: \", error);\n});\n```\n\nIf you want to stop tail:\n\n```javascript\ntail.unwatch()\n```\n\nTo start watching again:\n\n```javascript\ntail.watch()\n```\n\n## Configuration\n\nThe only mandatory parameter is the path to the file to tail.\n\n```javascript\nvar fileToTail = \"/path/to/fileToTail.txt\";\nnew Tail(fileToTail)\n```\n\nIf the file is **missing or invalid** ```Tail``` constructor will throw an Exception and won't initialize.\n\n```javascript\ntry {\n  new Tail(\"missingFile.txt\")\n} catch (ex) {\n  console.log(ex)\n}\n```\n\nOptional parameters can be passed via a hash:\n\n```javascript\nvar options= {separator: /[\\r]{0,1}\\n/, fromBeginning: false, fsWatchOptions: {}, follow: true, logger: console}\nnew Tail(fileToTail, options)\n```\n\n### Constructor parameters\n\n* `separator`:  the line separator token (default: `/[\\r]{0,1}\\n/` to handle linux/mac (9+)/windows). Pass `null` for binary files with no line separator.\n* `fsWatchOptions`: the full set of options that can be passed to `fs.watch` as per node documentation (default: `{}`).\n* `fromBeginning`:  tail from the beginning of the file (default: `false`). If `fromBeginning` is true `nLines` will be ignored.\n* `follow`: simulate `tail -F` option. In the case the file is moved/renamed/logrotated, if set to `true`  will start tailing again after a 1 second delay; if set to `false` it will  emit an error event (default: `true`).\n* `logger`: a logger object(default: no logger). The passed logger should follow the following signature:\n  * `info([data][, ...])`\n  * `error([data][, ...])`\n* `nLines`: tail from the last n lines. (default: `undefined`). Ignored if `fromBeginning` is set to `true`. \n* `useWatchFile`: if set to `true` will force the use of `fs.watchFile` over delegating to the library the choice between `fs.watch` and `fs.watchFile` (default: `false`).\n* `encoding`: the file encoding (default:`utf-8`).\n* `flushAtEOF`: set to `true` to force flush of content when end of file is reached. Useful when there's no separator character at the end of the file (default: `false`).\n\n## Emitted events\n\n`Tail` emits two events:\n\n* line\n\n```javascript\ntail.on(\"line\", (data) =\u003e {\n  console.log(data)  \n})\n```\n\n* error\n\n```javascript\ntail.on(\"error\", (err) =\u003e {\n  console.log(err)  \n})\n```\nThe error emitted is either the underlying exception or a descriptive string.\n\n## How to contribute\nNode Tail code repo is [here](https://github.com/lucagrulla/node-tail/)\nTail is written in ES6. Pull Requests are welcome.\n\n## History\n\nTail was born as part of a data firehose. Read more about that project [here](https://www.lucagrulla.com/posts/building-a-firehose-with-nodejs/).\nTail originally was written in [CoffeeScript](https://coffeescript.org/). Since December 2020 it's pure ES6.\n\n## License\n\nMIT. Please see [License](https://github.com/lucagrulla/node-tail/blob/master/LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucagrulla%2Fnode-tail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucagrulla%2Fnode-tail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucagrulla%2Fnode-tail/lists"}