@ajukno/mite
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Mite banner

Mite is a simple tool to watch file changes. It is built with TypeScript and uses the Chokidar library for file watching.

NPM Version

Features

  • Watches for file changes in specified paths
  • Supports multiple event types including 'add', 'addDir', 'change', 'unlink', 'unlinkDir', and 'all'
  • Provides an easy-to-use API to initialize the watcher and add event listeners

Usage

First, import Mite into your project:

import { mite } from '@ajukno/mite';

Then, initialize Mite with the paths you want to watch:

mite.init({ paths: '.' });

You can add event listeners using the on method:

mite.on(['add'], (path) => {
  console.log(`File added: ${path}`);
});

To stop the watcher, use the stop method:

await mite.stop();

API

init(options: MiteOptions): void

Initializes Mite with the given options. The options object should have the following properties:

  • paths: A string or an array of strings specifying the paths to watch
  • options (optional): An object specifying the watch options

on(events: MiteEventName[], callback: (path: string) => Promise<void> | void): void

Adds an event listener. The events parameter is an array of event names to listen for. The callback is a function that is called when any of the specified events occur.

stop(): Promise<void>

Stops the file watcher.

Tests

Mite has a suite of tests that can be run using Vitest. To run the tests, use the following command:

npm run test

License

Mite is licensed under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i @ajukno/mite

Weekly Downloads

7

Version

1.0.1

License

MIT

Unpacked Size

10.9 kB

Total Files

7

Last publish

Collaborators

  • ajukno