<commit_before>/*
 ** © 2014 by <NAME> <<EMAIL>>
 ** Licensed under MIT License.
 */

/* jshint node:true */
'use strict';

var Native = require('./build/Release/fse');
var EventEmitter = require('events').EventEmitter;
var fs = require('fs');

inherit(Native.FSEvents, EventEmitter);
module.exports = watch;
module.exports.getInfo = getInfo;
module.exports.FSEvents = Native.FSEvents;
module.exports.Constants = Native.Constants;

function watch(path) {
  var fse = new Native.FSEvents(String(path || ''), handler);
  EventEmitter.call(fse);
  return fse;

  function handler(path, flags, id) {
    setImmediate(function() {
      fse.emit('fsevent', path, flags, id);
      var info = getInfo(path, flags);
      info.id = id;
      if (info.event === 'moved') {
        fs.stat(info.path, function(err, stat) {
          info.event = (err || !stat) ? 'moved-out' : 'moved-in';
          fse.emit('change', path, info);
          fse.emit(info.event, path, info);
        });
      } else {
        fse.emit('change', path, info);
        fse.emit(info.event, path, info);
      }
    });
  }
}

function inherit(ctor, superCtor) {
  ctor.super_ = superCtor;
  var proto = Object.create(superCtor.prototype, {
    constructor: {
      value: ctor,
      enumerable: false,
      writable: true,
      configurable: true
    }<commit_msg>Fallback to nextTick for node 0.8<commit_after>/*
 ** © 2014 by <NAME> <<EMAIL>>
 ** Licensed under MIT License.
 */

/* jshint node:true */
'use strict';

var Native = require('./build/Release/fse');
var EventEmitter = require('events').EventEmitter;
var fs = require('fs');

inherit(Native.FSEvents, EventEmitter);
module.exports = watch;
module.exports.getInfo = getInfo;
module.exports.FSEvents = Native.FSEvents;
module.exports.Constants = Native.Constants;

function watch(path) {
  var fse = new Native.FSEvents(String(path || ''), handler);
  EventEmitter.call(fse);
  return fse;

  function handler(path, flags, id) {
    (global.setImmediate || process.nextTick)(function() {
      fse.emit('fsevent', path, flags, id);
      var info = getInfo(path, flags);
      info.id = id;
      if (info.event === 'moved') {
        fs.stat(info.path, function(err, stat) {
          info.event = (err || !stat) ? 'moved-out' : 'moved-in';
          fse.emit('change', path, info);
          fse.emit(info.event, path, info);
        });
      } else {
        fse.emit('change', path, info);
        fse.emit(info.event, path, info);
      }
    });
  }
}

function inherit(ctor, superCtor) {
  ctor.super_ = superCtor;
  var proto = Object.create(superCtor.prototype, {
    constructor: {
      value: ctor,
      enumerable: false,
      writable: true,
      configurable: true
    }
{'fraction_non_alphanumeric': 0.16024935826916026, 'fraction_numerical': 0.003667033370003667, 'mean_word_length': 2.970887918486172, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '44962', 'n_tokens_mistral': 927, 'n_tokens_neox': 912, 'n_words': 204}