MCPcopy Index your code
hub / github.com/markmap/markmap / _watch

Method _watch

packages/markmap-cli/src/util/dev-server.ts:286–301  ·  view source on GitHub ↗
(filePath: string, callback: () => MaybePromise<void>)

Source from the content-addressed store, hash-verified

284 }
285
286 private _watch(filePath: string, callback: () => MaybePromise<void>) {
287 let { watcher } = this;
288 if (!watcher) {
289 watcher = watch([]).on('all', (_event, path) => {
290 const callback = this.callbacks[path];
291 callback?.();
292 });
293 this.watcher = watcher;
294 }
295 watcher.add(filePath);
296 this.callbacks[filePath] = sequence(callback);
297 return () => {
298 watcher.unwatch(filePath);
299 delete this.callbacks[filePath];
300 };
301 }
302
303 addProvider(options?: { key?: string; filePath?: string }) {
304 const filePath = options?.filePath && resolve(options.filePath);

Callers 1

addProviderMethod · 0.95

Calls 1

sequenceFunction · 0.85

Tested by

no test coverage detected