# @types/watch

> TypeScript definitions for watch

Latest version **1.0.6** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/watch
pnpm add @types/watch
yarn add @types/watch
bun add @types/watch
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2023-11-07 |
| First published | 2016-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51446 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/watch
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/watch
- npm.io page: https://npm.io/package/@types/watch

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) *

## Recent versions

- 1.0.6 (latest) — 2023-11-07
- 1.0.3 (ts3.8) — 2022-01-05
- 1.0.2 (ts3.6) — 2021-07-02
- 1.0.1 (ts2.0) — 2019-04-01
- 1.0.5 — 2023-10-18
- 1.0.4 — 2023-09-25
- 1.0.0 — 2017-05-05
- 0.0.28 — 2016-09-19
- 0.0.27 — 2016-07-14
- 0.0.26-alpha — 2016-07-08
- 0.0.25-alpha — 2016-07-04
- 0.0.24-alpha — 2016-07-02
- 0.0.23-alpha — 2016-07-02
- 0.0.22-alpha — 2016-07-01
- 0.0.21-alpha — 2016-05-25
- … 3 more at https://npm.io/package/@types/watch/versions

## README

# Installation
> `npm install --save @types/watch`

# Summary
This package contains type definitions for watch (https://github.com/mikeal/watch).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/watch.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/watch/index.d.ts)
````ts
// Imported from: https://github.com/soywiz/typescript-node-definitions/watch.d.ts

/// <reference types="node" />

import fs = require("fs");
import events = require("events");

export interface Files {
    [key: string]: fs.Stats;
}

export interface Monitor extends events.EventEmitter {
    files: Files;

    on(event: "created" | "removed", listener: (f: string, stat: fs.Stats) => void): this;
    on(event: "changed", listener: (f: string, current: fs.Stats, prev: fs.Stats) => void): this;
    on(event: string, listener: (...args: any[]) => void): this;
    stop(): void;
}

export interface BaseOptions {
    ignoreDotFiles?: boolean | undefined;
    filter?(path: string, stat: fs.Stats): boolean;
}

export interface Options extends BaseOptions {
    interval?: number | undefined;
}

export interface WalkOptions extends BaseOptions {
    ignoreUnreadableDir?: boolean | undefined;
    ignoreNotPermitted?: boolean | undefined;
    ignoreDirectoryPattern?: RegExp | undefined;
}

export function watchTree(root: string, callback: (f: string, curr: fs.Stats, prev: fs.Stats) => void): void;
export function watchTree(
    root: string,
    options: Options,
    callback: (f: string, curr: fs.Stats, prev: fs.Stats) => void,
): void;
export function unwatchTree(root: string): void;
export function createMonitor(root: string, callback: (monitor: Monitor) => void): void;
export function createMonitor(root: string, options: Options, callback: (monitor: Monitor) => void): void;
export function walk(root: string, callback: (error: Error | null, files: Files | undefined) => void): void;
export function walk(
    root: string,
    options: WalkOptions,
    callback: (error: Error | null, files: Files | undefined) => void,
): void;

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 15:11:36 GMT
 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)

# Credits
These definitions were written by [Carlos Ballesteros Velasco](https://github.com/soywiz), and [Gyusun Yeom](https://github.com/Perlmint).

---
_Source: https://npm.io/package/@types/watch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
