Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function conditionalHandler(candidates) {
var isVersioned = false;
var isContentTyped = false;
if (!_.isArray(candidates)) {
candidates = [candidates];
}
// Assert
assert.arrayOfObject(candidates, 'candidates');
candidates = candidates.map(function map(candidate) {
// Array of handlers, convert to chain
if (_.isArray(candidate.handler)) {
var chain = new Chain();
candidate.handler.forEach(function forEach(_handler) {
assert.func(_handler);
chain.add(_handler);
});
candidate.handler = chain.run.bind(chain);
}
assert.func(candidate.handler);
if (_.isString(candidate.version)) {
candidate.version = [candidate.version];
}
function filterImagesInfo(imagesInfo, filters) {
assert.arrayOfObject(imagesInfo, 'imagesInfo');
assert.object(filters, 'filters');
var fields = Object.keys(filters);
if (fields.length === 0) {
return imagesInfo;
}
var filtered = [];
for (var j = 0; j < imagesInfo.length; j++) {
var row = rowFromImageInfo(imagesInfo[j]);
var keep = true;
for (var f = 0; f < fields.length; f++) {
var field = fields[f];
var val = filters[field];
var lookups = field.split(/\./g);
var actual = row;
function PathEnumerator(args)
{
var streamoptions, minconv, minunit;
mod_assertplus.object(args, 'args');
mod_assertplus.string(args.pattern, 'args.pattern');
mod_assertplus.object(args.timeStart, 'args.timeStart');
mod_assertplus.object(args.timeEnd, 'args.timeEnd');
mod_assertplus.optionalObject(args.streamOptions, 'args.streamOptions');
mod_assertplus.arrayOfObject(args.generator, 'args.generator');
streamoptions = mod_streamutil.streamOptions(args.streamOptions,
{ 'objectMode': true }, { 'highWaterMark': 20 });
mod_stream.Readable.call(this, streamoptions);
mod_vstream.wrapStream(this);
this.pe_pattern = args.pattern;
this.pe_generator = args.generator;
this.pe_start = new Date(args.timeStart.getTime());
this.pe_end = new Date(args.timeEnd.getTime());
this.pe_next = new Date(this.pe_start.getTime());
this.pe_minunit = null;
this.pe_ended = false;
/*
* Figure out how to increment each date to get to the next one. Note
function indexConfig(args)
{
mod_assertplus.object(args, 'args');
mod_assertplus.object(args.datasource, 'args.datasource');
mod_assertplus.arrayOfObject(args.metrics, 'args.metrics');
mod_assertplus.string(args.user, 'args.user');
mod_assertplus.object(args.mtime, 'args.mtime');
return ({
'user': args.user,
'mtime': args.mtime.toISOString(),
'datasource': args.datasource,
'metrics': args.metrics.map(
function (m) { return (metricSerialize(m, true)); })
});
}
function (subjectOrSubjects, key, issuer, issuerKey, options) {
var subjects;
if (Array.isArray(subjectOrSubjects))
subjects = subjectOrSubjects;
else
subjects = [subjectOrSubjects];
assert.arrayOfObject(subjects);
subjects.forEach(function (subject) {
utils.assertCompatible(subject, Identity, [1, 0], 'subject');
});
utils.assertCompatible(key, Key, [1, 0], 'key');
if (PrivateKey.isPrivateKey(key))
key = key.toPublic();
utils.assertCompatible(issuer, Identity, [1, 0], 'issuer');
utils.assertCompatible(issuerKey, PrivateKey, [1, 2], 'issuer key');
assert.optionalObject(options, 'options');
if (options === undefined)
options = {};
assert.optionalObject(options.validFrom, 'options.validFrom');
assert.optionalObject(options.validUntil, 'options.validUntil');
var validFrom = options.validFrom;
function Key(opts) {
assert.object(opts, 'options');
assert.arrayOfObject(opts.parts, 'options.parts');
assert.string(opts.type, 'options.type');
assert.optionalString(opts.comment, 'options.comment');
var algInfo = algs.info[opts.type];
if (typeof (algInfo) !== 'object')
throw (new InvalidAlgorithmError(opts.type));
var partLookup = {};
for (var i = 0; i < opts.parts.length; ++i) {
var part = opts.parts[i];
partLookup[part.name] = part;
}
this.type = opts.type;
this.parts = opts.parts;
this.part = partLookup;
function Signature(opts) {
assert.object(opts, 'options');
assert.arrayOfObject(opts.parts, 'options.parts');
assert.string(opts.type, 'options.type');
var partLookup = {};
for (var i = 0; i < opts.parts.length; ++i) {
var part = opts.parts[i];
partLookup[part.name] = part;
}
this.type = opts.type;
this.hashAlgorithm = opts.hashAlgo;
this.parts = opts.parts;
this.part = partLookup;
}
function vmsByRules(opts, callback) {
assert.object(opts, 'opts');
assert.object(opts.log, 'opts.log');
assert.arrayOfObject(opts.rules, 'opts.rules');
assert.object(opts.vms, 'opts.vms');
opts.log.debug({ rules: opts.rules }, 'filter.vmsByRules: entry');
var includeDisabled = true;
var rules = opts.rules;
var matchingVMs = {};
var vms = opts.vms;
if (hasKey(opts, 'includeDisabled')) {
includeDisabled = opts.includeDisabled;
}
ruleTypeWalk(rules, function _matchingVMs(rule, type, t, val) {
if (val !== undefined) {
type = 'tagValues';
function del(opts, callback) {
try {
assert.object(opts, 'opts');
assert.optionalArrayOfString(opts.rvmUUIDs, 'opts.rvmUUIDs');
assert.optionalArrayOfString(opts.uuids, 'opts.uuids');
assert.arrayOfObject(opts.vms, 'vms');
var rvmUUIDs = opts.rvmUUIDs || [];
var uuids = opts.uuids || [];
if (rvmUUIDs.length === 0 && uuids.length === 0) {
throw new Error(
'Payload must contain one of: rvmUUIDs, uuids');
}
} catch (err) {
return callback(err);
}
var log = util_log.entry(opts, 'del');
pipeline({
funcs: [
function lock(_, cb) {
mod_lock.acquireExclusiveLock(cb);