How to use the assert-plus.optionalObject function in assert-plus

To help you get started, we’ve selected a few assert-plus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joyent / smartos-live / src / fw / lib / fw.js View on Github external
function applyChanges(opts, log, callback) {
    log.trace(opts, 'applyChanges: entry');

    assert.object(opts, 'opts');
    assert.optionalObject(opts.allRemoteVMs, 'opts.allRemoteVMs');
    assert.optionalObject(opts.allVMs, 'opts.allVMs');
    assert.optionalObject(opts.del, 'opts.del');
    assert.optionalArrayOfObject(opts.rules, 'opts.rules');
    assert.optionalObject(opts.vms, 'opts.vms');
    assert.optionalObject(opts.save, 'opts.save');

    pipeline({
    funcs: [
        // Generate the ipf files for each VM
        function reloadPlan(res, cb) {
            prepareIPFdata({
                allVMs: opts.allVMs,
                remoteVMs: opts.allRemoteVMs,
                rules: opts.rules,
                vms: opts.vms
            }, log, cb);
        },
github joyent / smartos-live / src / fw / lib / fw.js View on Github external
function applyChanges(opts, log, callback) {
    log.trace(opts, 'applyChanges: entry');

    assert.object(opts, 'opts');
    assert.optionalObject(opts.allRemoteVMs, 'opts.allRemoteVMs');
    assert.optionalObject(opts.allVMs, 'opts.allVMs');
    assert.optionalObject(opts.del, 'opts.del');
    assert.optionalArrayOfObject(opts.rules, 'opts.rules');
    assert.optionalObject(opts.vms, 'opts.vms');
    assert.optionalObject(opts.save, 'opts.save');

    pipeline({
    funcs: [
        // Generate the ipf files for each VM
        function reloadPlan(res, cb) {
            prepareIPFdata({
                allVMs: opts.allVMs,
                remoteVMs: opts.allRemoteVMs,
                rules: opts.rules,
                vms: opts.vms
            }, log, cb);
github altanai / Ramudroid / webrobocontrol / node_modules / restify-plugins / lib / plugins / bodyParser.js View on Github external
function bodyParser(options) {
    assert.optionalObject(options, 'options');
    var opts = options || {};
    opts.bodyReader = true;

    var read = bodyReader(opts);
    var parseForm = formParser(opts);
    var parseJson = jsonParser(opts);
    var parseMultipart = multipartParser(opts);
    var parseFieldedText = fieldedTextParser(opts);

    function parseBody(req, res, next) {
        // #100 don't parse the body again if we've read it once
        if (req._parsedBody) {
            next();
            return;
        } else {
            req._parsedBody = true;
github joyent / dragnet / lib / dragnet.js View on Github external
function build(args, callback)
{
	var error, config, dsname, log, ds;
	var metrics;

	mod_assertplus.object(args, 'args');
	mod_assertplus.object(args.config, 'args.config');
	mod_assertplus.string(args.dsname, 'args.dsname');
	mod_assertplus.bool(args.dryRun, 'args.dryRun');
	mod_assertplus.string(args.interval, 'args.interval');
	mod_assertplus.optionalString(args.assetroot, 'args.assetroot');
	mod_assertplus.optionalObject(args.timeAfter, 'args.timeAfter');
	mod_assertplus.optionalObject(args.timeBefore, 'args.timeBefore');

	config = args.config;
	dsname = args.dsname;
	log = args.log;
	error = null;

	if (args.timeBefore !== null && args.timeAfter !== null &&
	    args.timeBefore.getTime() < args.timeAfter.getTime())
		error = new VError(
		    '"before" time cannot be before "after" time');

	switch (args.interval) {
	case 'hour':
	case 'day':
	case 'all':
github altanai / Ramudroid / webrobocontrol / node_modules / restify-plugins / lib / plugins / audit.js View on Github external
function auditLogger(options) {
    assert.object(options, 'options');
    assert.object(options.log, 'options.log');
    assert.optionalObject(options.server, 'options.server');
    assert.optionalObject(options.logBuffer, 'options.logBuffer');
    assert.optionalBool(options.printLog, 'options.printLog');
    //use server object to emit log data
    var server = options.server;
    //use logMetrics ringbuffer to store certain period of log records
    var logMetrics = options.logBuffer;
    //default always print log
    var printLog = options.printLog;

    if (typeof printLog === 'undefined') {
        printLog = true;
    }
    var errSerializer = bunyan.stdSerializers.err;

    if (options.log.serializers && options.log.serializers.err) {
        errSerializer = options.log.serializers.err;
    }
github sx1989827 / DOClever / Desktop / node_modules / fsevents / node_modules / sshpk / lib / private-key.js View on Github external
PrivateKey.prototype.toBuffer = function (format, options) {
	if (format === undefined)
		format = 'pkcs1';
	assert.string(format, 'format');
	assert.object(formats[format], 'formats[format]');
	assert.optionalObject(options, 'options');

	return (formats[format].write(this, options));
};
github joyent / smartos-live / src / img / node_modules / sdc-clients / lib / imgapi.js View on Github external
function removeImageAcl(uuid, acl, account, options, callback) {
    var self = this;
    assert.string(uuid, 'uuid');
    if (typeof (account) === 'function') {
        callback = account;
        options = {};
        account = undefined;
    } else if (typeof (options) === 'function') {
        callback = options;
        options = {};
    }
    assert.optionalString(account, 'account');
    assert.arrayOfString(acl, 'acl');
    assert.object(options, 'options');
    assert.optionalObject(options.headers, 'options.headers');
    assert.func(callback, 'callback');

    var path = self._path(format('/images/%s/acl', uuid), {
        channel: self.channel,
        action: 'remove',
        account: account
    });
    self._getAuthHeaders(function (hErr, headers) {
        if (hErr) {
            callback(hErr);
            return;
        }
        if (options.headers) {
            simpleMerge(headers, options.headers);
        }
        var reqOpts = {
github joyent / smartos-live / src / img / lib / sources / index.js View on Github external
function createSource(type, opts) {
    assert.string(type, 'type');
    assert.optionalObject(opts, 'opts');

    var source;
    switch (type) {
    case 'imgapi':
        source = new ImgapiSource(opts);
        break;
    case 'docker':
        source = new DockerSource(opts);
        break;
    case 'dsapi':
        source = new DsapiSource(opts);
        break;
    default:
        throw new Error(format('invalid source type: "%s"', type));
    };
github joyent / manatee / lib / adm.js View on Github external
function lagInSeconds(lag) {
    assert.optionalObject(lag);
    var seconds, unit;

    if (!lag) {
        return (null);
    }

    seconds = lag.seconds || 0;

    for (unit in lag) {
        switch (unit) {
            case 'days':
                seconds += lag[unit] * 24 * 60 * 60;
                break;
            case 'hours':
                seconds += lag[unit] * 60 * 60;
                break;
github joyent / smartos-live / src / img / lib / errors.js View on Github external
function DownloadError(cause, message) {
    if (message === undefined) {
        message = cause;
        cause = undefined;
    }
    assert.optionalObject(cause);
    assert.string(message);
    ImgadmError.call(this, {
        cause: cause,
        message: message,
        code: 'DownloadError'
    });
}
util.inherits(DownloadError, ImgadmError);