diff --git a/lib/index.js b/lib/index.js index b8eea9b..5b045f0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,11 +1,12 @@ -var Server = require('./server'); -var Client = require('./client'); -var debug = require('debug')('tinylr'); +import Server from './server'; +import Client from './client'; + +const debug = require('debug')('tinylr'); // Need to keep track of LR servers when notifying -var servers = []; +const servers = []; -module.exports = tinylr; +export default tinylr; // Expose Server / Client objects tinylr.Server = Server; @@ -17,14 +18,14 @@ tinylr.changed = changed; // Main entry point function tinylr (opts) { - var srv = new Server(opts); + const srv = new Server(opts); servers.push(srv); return srv; } // A facade to Server#handle function middleware (opts) { - var srv = new Server(opts); + const srv = new Server(opts); servers.push(srv); return function tinylr (req, res, next) { srv.handler(req, res, next); @@ -33,12 +34,12 @@ function middleware (opts) { // Changed helper, helps with notifying the server of a file change function changed (done) { - var files = [].slice.call(arguments); + const files = [].slice.call(arguments); if (files[files.length - 1] === 'function') done = files.pop(); - done = typeof done === 'function' ? done : function () {}; + done = typeof done === 'function' ? done : () => {}; debug('Notifying %d servers - Files: ', servers.length, files); - servers.forEach(function (srv) { - var params = { params: { files: files } }; + servers.forEach(srv => { + const params = { params: { files: files } }; srv && srv.changed(params); }); done();