Skip to content

Watch on set of files and stream changed data. Simple. Fast. No dependencies.

License

Notifications You must be signed in to change notification settings

MaxSvargal/fs-watch-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fs-watch-stream

The NodeJs library that watch for changes of sets of files and stream out their differences. It usable, for example, for streaming server logs to browser in real time.

Type definition:

type fsWatchStream = (
  filesList: { [string]: string }[],
  callback: (err: Error, res: string) => void
) => void

Example with web sockets

const fsWatchStream = require('fs-watch-stream')
const WebSocket = require('ws')

const wss = new WebSocket.Server({ port: 8080 })

fsWatchStream([
  { system: '/var/log/system.log' },
  { wifi: '/var/log/wifi.log' }
], (err, res) => {
  if (err) throw err
  wss.clients.forEach(client => client.send(res))
})

About

Watch on set of files and stream changed data. Simple. Fast. No dependencies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published