class for watching a path with custom events and options
187837
function Hey(options) {

		// force the use of new
		if (this.constructor !== Hey) {
			throw "Hey must be instantiated with \"new\"!";
		}

		// we need some options, don't we?
		if (!options || !options.path) {
			throw "Option object must be set with a valid path to watch.";
		}

		// start EventEmitter
		EventEmitter.call(this);

		// folders and descriptors, just in case
		this.__paths = [];
		this.__descriptors = [];

		// helpful boolean
		this.__end_of_buffer = false;

		// some filepath properties
		this.__isDirectory = false;
		this.__isFile = false;

		Object.defineProperty(this, "isDirectory", {
			enumerable: true,
			get: function () {
				return this.__isDirectory;
			}
		 });

		Object.defineProperty(this, "isFile", {
			enumerable: true,
			get: function () {
				return this.__isFile;
			}
		 });

		// define options as "property"
		this.__options = options;

		Object.defineProperty(this, "options", {
			enumerable: true,
			get: function () {
				return this.__options;
			}
		 });

		// default mask
		Object.defineProperty(this, "defaultMask", {
			enumerable: true,
			get: function () {
				return Hey.FLAGS.MODIFY | Hey.FLAGS.CREATE | Hey.FLAGS.DELETE
					| Hey.FLAGS.SELF_DELETE | Hey.FLAGS.MOVE
					| Hey.FLAGS.SELF_MOVE;
			}
		});

		this.initialize();
	}
171500
function startWatcherForLinting (src)
{
    watch(src,
        function (file)
        {
            if (file.path)
            {
                lintFiles(file.path);
            }
        }
    );
}
957062
public static WatchMonitor create(Path path, int maxDepth, WatchEvent.Kind<?>... events){
		return new WatchMonitor(path, maxDepth, events);
	}
630919
public List<String> watchForChilds(final String path) {
        if (_zookeeperEventThread != null && Thread.currentThread() == _zookeeperEventThread) {
            throw new IllegalArgumentException("Must not be done in the zookeeper event thread.");
        }
        return retryUntilConnected(new Callable<List<String>>() {

            @Override
            public List<String> call() throws Exception {
                exists(path, true);
                try {
                    return getChildren(path, true);
                } catch (ZkNoNodeException e) {
                    // ignore, the "exists" watch will listen for the parent node to appear
                }
                return null;
            }
        });
    }
133617
function handlePathObj(path, event, EventObject, newIndex) {
  if (typeof path === 'function') {
    return path(event, newIndex);
  } else if ((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && !Array.isArray(path) && path) {
    return EventObject.reduce((0, _helpers.matchAndAddition)(path, event), {});
  } else if ((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && Array.isArray(path) && path) {
    return EventObject.reduce((0, _helpers.matchAndAddition)(path[newIndex], event), {});
  }
  return {};
}
1289381
def run_watcher(self):
        
        # Create observer
        observer = Observer()

        # Start observer
        observer.start()

        # Dict that maps file path to `watch object`
        watche_obj_map = {}

        # Run change check in a loop
        while not self._watcher_to_stop:
            # Get current watch paths
            old_watch_path_s = set(watche_obj_map)

            # Get new watch paths
            new_watch_path_s = self._find_watch_paths()

            # For each new watch path
            for new_watch_path in new_watch_path_s:
                # Remove from the old watch paths if exists
                old_watch_path_s.discard(new_watch_path)

                # If the new watch path was not watched
                if new_watch_path not in watche_obj_map:
                    try:
                        # Schedule a watch
                        watch_obj = observer.schedule(
                            # 2KGRW
                            # `FileSystemEventHandler` instance
                            self,
                            # File path to watch
                            new_watch_path,
                            # Whether recursive
                            recursive=True,
                        )

                        # Store the watch obj
                        watche_obj_map[new_watch_path] = watch_obj

                    # If have error
                    except OSError:
                        # Set the watch object be None
                        watche_obj_map[new_watch_path] = None

            # For each old watch path that is not in the new watch paths
            for old_watch_path in old_watch_path_s:
                # Get watch object
                watch_obj = watche_obj_map.pop(old_watch_path, None)

                # If have watch object
                if watch_obj is not None:
                    # Unschedule the watch
                    observer.unschedule(watch_obj)

            # Store new watch paths
            self._watch_paths = new_watch_path_s

            # Sleep before next check
            time.sleep(self._interval)
269965
public static WatchMonitor create(String path, int maxDepth, WatchEvent.Kind<?>... events){
		return create(Paths.get(path), maxDepth, events);
	}
859541
function watchedEvents(obj) {
      var listeners = obj['__ember_meta__'].listeners, ret = [];

      if (listeners) {
        for(var eventName in listeners) {
          if (listeners[eventName]) { ret.push(eventName); }
        }
      }
      return ret;
    }
170380
def _watch_file(self, filepath, trigger_event=True):
        """"""
        is_new = filepath not in self._watched_files
        if trigger_event:
            if is_new:
                self.trigger_created(filepath)
            else:
                self.trigger_modified(filepath)
        try:
            self._watched_files[filepath] = self._get_modified_time(filepath)
        except OSError:
            return
624230
function PointerEvent(options) {
    var _this = this;

    _classCallCheck(this, PointerEvent);

    this.startHandlers = {};
    this.lastHandlerId = 0;
    this.curPointerClass = null;
    this.curTouchId = null;
    this.lastPointerXY = { clientX: 0, clientY: 0 };
    this.lastTouchTime = 0;

    // Options
    this.options = { // Default
      preventDefault: true,
      stopPropagation: true
    };
    if (options) {
      ['preventDefault', 'stopPropagation'].forEach(function (option) {
        if (typeof options[option] === 'boolean') {
          _this.options[option] = options[option];
        }
      });
    }
  }
1326847
function createTreeListener({ handler, restPath }) {
    const newHandler = function treeListener(changeEvent) {
        const extendedChangeEvent = {
            restPath,
            ...changeEvent
        };
        const { previousValue, value } = changeEvent;

        // removes listener for all branches of the path on old object
        if (previousValue && typeof previousValue === 'object') {
            removeTreeListener(previousValue, restPath, handler);
        }

        // adds listener for all branches of "restPath" path on newly assigned object
        if (value && typeof value === 'object') {
            addTreeListener(value, restPath, handler);
        }

        // call original handler
        handler.call(this, extendedChangeEvent);
    };

    newHandler._callback = handler;

    return newHandler;
}
1031678
def watch_dir(path: str) -> None:
    """"""
    _compile_exclude_patterns()
    if config.autoreload or config.debug:
        # Add files to watch for autoreload
        p = pathlib.Path(path)
        p.resolve()
        _add_watch_path(p)
944576
def handle_path(self, event):
        
        self.job.LOG.debug("Notification %r" % event)
        if event.dir:
            return

        if any(event.pathname.endswith(i) for i in self.METAFILE_EXT):
            MetafileHandler(self.job, event.pathname).handle()
        elif os.path.basename(event.pathname) == "watch.ini":
            self.job.LOG.info("NOT YET Reloading watch config for '%s'" % event.path)
577440
function getWatcherByPath(path) {
        var rlt = undefined;

        watchers.forEach(function(watcher) {
            if (watcher.path == path)
                rlt = watcher;
        });

        return rlt;
    }
961532
def _call_watcher(self_, watcher, event):
        
        if self_.self_or_cls.param._TRIGGER:
            pass
        elif watcher.onlychanged and (not self_._changed(event)):
            return

        if self_.self_or_cls.param._BATCH_WATCH:
            self_._events.append(event)
            if watcher not in self_._watchers:
                self_._watchers.append(watcher)
        elif watcher.mode == 'args':
            with batch_watch(self_.self_or_cls, run=False):
                watcher.fn(self_._update_event_type(watcher, event, self_.self_or_cls.param._TRIGGER))
        else:
            with batch_watch(self_.self_or_cls, run=False):
                event = self_._update_event_type(watcher, event, self_.self_or_cls.param._TRIGGER)
                watcher.fn(**{event.name: event.new})
1296071
def watched(self, option):
    
    params = join_params(self.parameters, {"watched": option})

    return self.__class__(**params)
595757
function dispatchCustomEvent(node, type) {
	const event = document.createEvent('CustomEvent');

	event.initCustomEvent(type, true, true, undefined);

	node.dispatchEvent(event);
}