Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var release = function () {
var data, fnCb;
// eslint-disable-next-line no-unmodified-loop-condition
while (count < limit && (data = queue.shift())) {
try {
data.fn.apply(data.context, data.args);
} catch (e) {
fnCb = last.call(data.args);
if (typeof fnCb === "function") fnCb(e);
}
}
};
(emitter._watchSwitchListener = function () {
var candidate;
watchers.alt.sort(compare);
if (watchers.alt[0] !== watcher) return;
if (isAvail()) {
switchAltsToReg();
} else if (watchers.reg.length) {
candidate = last.call(watchers.reg.sort(compare));
if (candidate.count >= watcher.count) return;
// Move last regular watcher to lstat watch
switchToAlt(candidate);
// Move current watcher to regular watch
switchToReg(watcher);
}
})
);
if (ast.callee.type !== 'MemberExpression') return false;
object = ast.callee.object;
if (object.type === 'MemberExpression') {
if (!asProperty) return;
if (object.property.name !== objName) return;
} else if (object.name !== objName) {
return;
}
if (ast.callee.property.name !== fnName) return;
if (this.code[ast.range[0]] === '(') return;
dep = { point: this.code.indexOf('(', ast.range[0]) + 2 };
dep.raw = this.code.slice(dep.point - 1, ast.range[1] - 1);
lines = this.code.slice(ast.range[0], dep.point).split(eolRe);
dep.line = ast.loc.start.line + lines.length - 1;
dep.column = (lines.length > 1)
? last.call(lines).length : ast.loc.start.column + lines[0].length;
this.deps.push(dep);
} else {
if ((ast.type === 'CallExpression') && (ast.callee.type === 'Identifier') &&
(ast.callee.name === fnName) && (this.code[ast.range[0]] !== '(')) {
dep = { point: this.code.indexOf('(', ast.range[0]) + 2 };
dep.raw = this.code.slice(dep.point - 1, ast.range[1] - 1);
lines = this.code.slice(ast.range[0], dep.point).split(eolRe);
dep.line = ast.loc.start.line + lines.length - 1;
dep.column = (lines.length > 1)
? last.call(lines).length : ast.loc.start.column + lines[0].length;
this.deps.push(dep);
}
}
};
if (!ast || (typeof ast !== 'object')) return;
if (isArray(ast)) {
ast.forEach(walker, this);
return;
}
keys(ast).forEach(function (key) {
if (key !== 'range') walker.call(this, ast[key]);
}, this);
if (((ast.type === 'CallExpression') || (ast.type === 'NewExpression')) &&
(ast.callee.type === 'Identifier') &&
(ast.callee.name === 'require') && (this.code[ast.range[0]] !== '(')) {
dep = { point: this.code.indexOf('(', ast.range[0]) + 2 };
dep.raw = this.code.slice(dep.point - 1, ast.range[1] - 1);
lines = this.code.slice(ast.range[0], dep.point).split(eolRe);
dep.line = ast.loc.start.line + lines.length - 1;
dep.column = (lines.length > 1) ? last.call(lines).length :
ast.loc.start.column + lines[0].length;
if ((ast.arguments.length === 1) && (ast.arguments[0].type === 'Literal')) {
dep.value = String(ast.arguments[0].value);
} else {
if (ast.arguments.length === 1) {
try {
dep.value = String(parse(dep.raw));
} catch (e) {
try {
dep.value = String(runInNewContext(dep.raw));
} catch (ignore) {}
}
} else if (!ast.arguments.length) {
dep.value = 'undefined';
}
}
return findRoot(input)(root => {
let name, dirs, result;
name = root ? last.call(root.split(sep)) : "/";
if (!this.modules[name]) {
this.packages[name] = root || sep;
this.modules[name] = {};
}
scope = this.modules[name];
dirs = root ? input.slice(root.length + 1) : input.slice(1);
path = name + (root ? sep : "") + dirs;
dirs = dirs.split(sep);
name = dirs.pop();
dirs.forEach(dir => {
tree.push(scope);
scope = scope[dir] || (scope[dir] = {});
});
if (scope[name]) return scope[name];
if (!stream) {
result = this.readFile(input, name, scope, tree);
if (
keywords.some(function (keyword) {
if (messageContains(keyword)) {
needle = keyword;
return true;
}
})
) {
console.log("Send email...");
mailer.sendMail(
{
from: config.smtp.from,
to: config.smtp.to,
subject: (subject = "IRC: #" + name + ": '" + needle + "' mentioned"),
text: (body =
msgOutput(last.call(history)) +
"\n\n----------\n\n" +
history.map(msgOutput).join("\n") +
"\n")
},
function (err) {
if (err) {
console.error("Could not send email: " + err);
console.error(subject + ": " + body);
throw new Error("Could not send emails");
}
console.log("...Email sent");
}
);
}
})
);
fs.open = function (path, flags, mode, fnCb) {
var openCount, args;
if (count >= limit) {
queue.push({ fn: fs.open, context: this, args: arguments });
return;
}
openCount = count++;
args = arguments;
fnCb = last.call(args);
++debugStats.fd;
open(path, flags, mode, function (err, fd) {
if (err) {
--debugStats.fd;
--count;
if (err.code === "EMFILE" || err.code === "ENFILE") {
if (limit > openCount) limit = openCount;
queue.push({ fn: fs.open, context: this, args: args });
release();
return;
}
release();
}
if (typeof fnCb === "function") fnCb(err, fd);
});
};
return (self = defineLength(function () {
var openCount, args = arguments, context, cb = last.call(args);
if (!exports.initialized || typeof cb !== "function") return asyncFn.apply(this, arguments);
if (count >= limit) {
queue.push({ fn: self, context: this, args: arguments });
return null;
}
openCount = count++;
context = this;
args = slice.call(args, 0, -1);
args.push(function (err, resultIgnored) {
--debugStats[type];
--count;
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) {
if (limit > openCount) limit = openCount;
queue.push({ fn: self, context: context, args: args });
release();
return;
forEach(history, function (events, id) {
var event = events[0];
if (!event || (event.value === undefined)) return;
if ((property != null) && !event.obj.hasOwnProperty(property)) return;
data[last.call(events).index] = events[0];
});
result = [];