HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/1233/cwd/home/arjun/projects/buyercall/node_modules/watch/test/test_watchTree.js
var fs = require('fs')
  , watch = require('../main')
  , assert = require('assert')
  ;

//
// Demonstrate that the function of 'filter' is semantically inconsistent with
// usual convention, that returning true means 'keep this'.
//
function isDirOrQ(f, stat) { return stat.isDirectory() || f === 'Q'; }

watch.watchTree(__dirname, { filter: isDirOrQ }, function (f, curr, prev) {
  if (typeof f == 'object' && prev === null && curr === null) {
    Object.keys(f).forEach(function(name) {
      var stat = f[name];
      assert(isDirOrQ(name, stat));
    });

    // If the process never exits then `unwatchTree` failed to unwatch all
    // the files.
    watch.unwatchTree(__dirname);
  }
});