socketfs

Allows your browser to watch a file.

npm install socketfs
12 downloads in the last month

socketfs

socketfs adds watch and unwatch methods so you can watch files from your browser.

How to Use

Server

Start the included app.js:

node app.js

Or you can extend your existing express app:

require('./socketfs.server.js')(app, httpServer)

Browser

Include requirements:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="space.js"></script>
<script type="text/javascript" src="socket-io.js"></script>
<script type="text/javascript" src="socketfs.browser.js"></script>

Call your methods:

socketfs.connect()
socketfs.watch('test/hello.txt', function () {
  $('pre').append('test/hello.txt changed\n')
})

Spec - Server

Properties:

filename
 tailFn Function
 watcherFn bool
 tails
  socketID String
  socketID...
 mtime Int
 watchers
  socketID String
  socketID...
filename...

Methods:

inspect
resetGlobal
tail
untail
unwatch
watch

Spec - Client

Properties:

filename
 tails
  0 fn
  ...
 watches
  0 fn
  ...
filename...

Methods:

inspect
resetGlobal
tail
untail
unwatch
watch

License

MIT

Author

Breck Yunits

Todo

v0.1 - done

watch files

v0.1.1 - done

watch dirs

todo

  • more robust tests
  • server method to clear all watchers (to make testing easier)
  • reestablish watchers when server resets ?
  • rate limit?
  • tail?
npm loves you