socketfs

Allows your browser to watch a file.

Usage no npm install needed!

<script type="module">
  import socketfs from 'https://cdn.skypack.dev/socketfs';
</script>

README

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')
})

License

MIT

Author

Breck Yunits