Nature's Particle Manager
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    socketfspublic

    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?

    Keywords

    none

    install

    npm i socketfs

    Downloadsweekly downloads

    6

    version

    0.2.1

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar