src/index.js
function watch(paths, callback, options = {}) {
    paths = paths === '*' ? paths : _pathsArray(paths);
    let id = randomString();
    let defaultOptions = { async: false, priority: 0 };

    options = Object.assign({}, defaultOptions, options);

    watchers.push({
      callback,
      id,
      options,
      paths,
    });

    watchers = watchers.sort(_sortByPriority);

    return id;
  }
function watch(paths, callback, options = {}) {
    paths = paths === '*' ? paths : _pathsArray(paths);
    let id = randomString();
    let defaultOptions = { async: false, priority: 0 };

    options = Object.assign({}, defaultOptions, options);

    watchers.push({
      callback,
      id,
      options,
      paths,
    });

    watchers = watchers.sort(_sortByPriority);

    return id;
  }
function watch ( paths , callback , options = { } ) { paths = paths === '*' ? paths : _pathsArray ( paths ) ; let id = randomString ( ) ; let defaultOptions = { async : false , priority : 0 } ; options = Object . assign ( { } , defaultOptions , options ) ; watchers . push ( { callback , id , options , paths , } ) ; watchers = watchers . sort ( _sortByPriority ) ; return id ; }
Watch for changes on a given key, and execute the provided callback when there are changes

@param {String[]|String} String path or array of paths to watch
@param {Function} callback to execute when there are changes
@param {Object} options Options
@param {Boolean} options.async Callback execution is async (in next cycle) or sync (as soon as the key changes)
@param {Number} options.priority Controls the order the provided callback is called when multiple watches exist on the same key.
@return {String} id of watcher (useful for unwatch())
Watch for changes on a given key and execute the provided callback when there are changes