Coder Social home page Coder Social logo

metarhia / metawatch Goto Github PK

View Code? Open in Web Editor NEW
15.0 13.0 4.0 232 KB

Nested directories watch for node.js ๐Ÿ•ต๏ธ

Home Page: https://metarhia.com

License: MIT License

JavaScript 100.00%
vm metarhia nodejs impress sandbox sandboxing isolate isolation v8

metawatch's Introduction

Deep nested directories watch for node.js

ci status snyk npm version npm downloads/month npm downloads license

  • Watch directories recursive
  • Rebuild recursive when new directories found or old directories remove
  • Deduplicate events with debounce

Usage

const metawatch = require('metawatch');

const watcher = new metawatch.DirectoryWatcher({ timeout: 200 });
watcher.watch('/home/marcus/Downloads');
watcher.watch('/home/marcus/Documents');

watcher.on('change', (fileName) => {
  console.log({ changed: fileName });
});

watcher.on('delete', (fileName) => {
  console.log({ deleted: fileName });
});

watcher.on('before', (changes) => {
  console.log({ changes });
});

watcher.on('after', (changes) => {
  console.log({ changes });
});

Contributors

License & Contributors

Copyright (c) 2020-2023 Metarhia contributors. Metawatch is MIT licensed. Metawatch is a part of Metarhia technology stack.

metawatch's People

Contributors

timursevimli avatar tshemsedinov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metawatch's Issues

Remove listener

Implement removeWatch or something like FSWatcher.close();

Rebuild recursive

If we create or delete directory inside watched directory, watch should be added or removed respectively.

  • linux
  • macos
  • windows

Deduplicate events

Sometimes fs.watch sends duplicate events or other processes can generate directory/file events in sequence so we need to add timeout for events deduplication and fire events just once per timeout (like debounce or throttle do).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.