Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cumberbatch

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cumberbatch - npm Package Compare versions

Comparing version 0.1.15 to 0.1.16

lib/MinimatchTree.js

52

lib/GlobEmitter.js
var minimatch = require('minimatch');
var oid = require('oid');
var MinimatchTree = require('./MinimatchTree');
var GlobEmitter = function(options) {

@@ -9,2 +11,3 @@ this._options = options || {};

this._hashLookup = {};
this._patternTree = new MinimatchTree();

@@ -29,2 +32,3 @@ if (typeof this._options.debounceMs !== 'number') {

if (listeners[j].hash === hash) {
this._patternTree.remove(glob, listeners[j]);
this._globListeners[glob].splice(j, 1);

@@ -52,2 +56,3 @@ j--;

this._globListeners[glob].push(listener);
this._patternTree.add(glob, listener);
}

@@ -78,42 +83,17 @@

var globData = this._nextEvent.globs;
var paths = Object.keys(globData);
this._nextEvent = null;
var callbackHash;
var negatedPaths = {};
var callbackData = {};
var callbacks = {};
for (var path in globData) {
for (var glob in this._globListeners) {
var isNegation = glob.indexOf('!') === 0;
var usedGlob = isNegation ? glob.substr(1) : glob;
if (minimatch(path, usedGlob)) {
var listeners = this._globListeners[glob];
for (var i = 0; i < listeners.length; i++) {
callbackHash = listeners[i].hash;
if (!callbacks[callbackHash]) {
callbacks[callbackHash] = listeners[i].fn;
callbackData[callbackHash] = {};
negatedPaths[callbackHash] = {};
}
if (isNegation) {
negatedPaths[callbackHash][path] = true;
delete callbackData[callbackHash][path];
} else if (!negatedPaths[callbackHash][path]) {
callbackData[callbackHash][path] = globData[path];
}
}
}
var calls = this._patternTree.find(paths);
for (var i = 0; i < calls.length; i++) {
var call = calls[i];
var callData = {};
for (var j = 0; j < call.files.length; j++) {
callData[call.files[j]] = globData[call.files[j]];
}
}
for (callbackHash in callbacks) {
if (Object.keys(callbackData[callbackHash]).length) {
try {
callbacks[callbackHash](callbackData[callbackHash]);
} catch (e) {
console.error(e, e.stack);
}
try {
call.data.fn(callData);
} catch (e) {
console.error(e, e.stack);
}

@@ -120,0 +100,0 @@ }

{
"name": "cumberbatch",
"description": "crazy watcher stuff",
"version": "0.1.15",
"version": "0.1.16",
"homepage": "https://github.com/azulus/cumberbatch",

@@ -6,0 +6,0 @@ "authors": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc