How to use the assert-plus.object 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 / manatee / lib / adm.js View on Github external
function translateHistoryNode(opts, cb) {
    assert.object(opts, 'opts');
    assert.object(opts.zkClient, 'opts.zkClient');
    assert.string(opts.zkPath, 'opts.zkPath');
    assert.string(opts.zkNode, 'opts.zkNode');

    // Old entries look like timestamp-ip-role-master-slave-zkseq from zk.
    // New Entries look like generation-zkseq
    var fNode = opts.zkNode.split('-');
    if (fNode.length > 2) {
        return (cb(null, oldHistoryToObj(fNode)));
    }

    var p = opts.zkPath + '/' + opts.zkNode;
    opts.zkClient.getData(p, function (err, data, stat) {
        if (err) {
            return (cb(err));
        }
        var time = bignum.fromBuffer(stat.ctime).toNumber();
github joyent / moray / lib / objects / common.js View on Github external
function buildWhereClause(opts, cb) {
    assert.object(opts, 'options');
    assert.object(opts.bucket, 'options.bucket');
    assert.object(opts.filter, 'options.filter');
    assert.object(opts.log, 'options.log');
    assert.object(opts.opts, 'options.opts');
    assert.func(cb, 'callback');

    var f = opts.filter;
    var log = opts.log;
    var o = opts.opts;
    var where = 'WHERE ';
    var sort = '';
    var args = [];
    var sql;

    // Query only against fields with valid indices
    var b = opts.idxBucket;

    function append(item) {
        if (item.attribute) {
            if (sort.length > 0) {
github restify / clients / lib / HttpClient.js View on Github external
var startRequestTimeout = function startRequestTimeout() {
        // the request object must already exist before we can set a timeout
        // on it.
        assert.object(req, 'req');

        if (opts.requestTimeout) {
            requestTimer = setTimeout(function requestTimeout() {
                requestTimer = null;

                var err = errors.createRequestTimeoutErr(opts, req);
                req._forcedAbortErr = err;
                req.abort();
            }, opts.requestTimeout);
        }
    };
github joyent / manatee / lib / postgresMgr.js View on Github external
}, function (res, cb) {
        assert.object(res, 'res');
        assert.func(cb, 'cb');

        /*
         * Check the data directory within the newly mounted dataset to ensure
         * that it either does not yet exist, or is a directory.
         */
        log.info('checking that data directory exists');
        fs.lstat(self._dataDir, function (err, stats) {
            if (err && err.code === 'ENOENT') {
                /*
                 * The directory does not yet exist.  Create it now.
                 */
                log.info('data directory does not exist; creating directory');
                fs.mkdir(self._dataDir, function (err_) {
                    if (err_) {
                        cb(new VE(err_, 'creating PostgreSQL data directory ' +
github joyent / sdc-docker / lib / backends / sdc / containers.js View on Github external
function renameContainer(opts, callback) {
    assert.object(opts, 'opts');
    assert.string(opts.name, 'opts.name');
    assert.optionalObject(opts.log, 'opts.log');
    assert.object(opts.account, 'opts.account');

    if (!utils.isValidDockerConatinerName(opts.name)) {
        callback(new errors.DockerError(
                'Error when allocating new name: Invalid container name ('
                + opts.name + ')'));
        return;
    }

    var log = opts.log;
    var vmapi = opts.app.vmapi;

    var renameHeaders = { headers: { 'x-request-id': opts.req_id } };
    var renameParams = {
        uuid : opts.vm.uuid,
        owner_uuid : opts.account.uuid,
        sync : true,
github joyent / smartos-live / src / fw / lib / ipf.js View on Github external
function zoneStart(uuid, log, callback) {
    assert.string(uuid, 'uuid');
    assert.object(log, 'log');
    assert.func(callback, 'callback');

    var startOpts = ['-GE', uuid];
    if (OLD) {
        startOpts = ['-E', uuid];
    }
    return ipf(startOpts, log, callback);
}
github joyent / sdc-docker / lib / endpoints / volumes.js View on Github external
function volumesSupported(req, res, next) {
        assert.object(req, 'req');
        assert.object(res, 'res');
        assert.func(next, 'next');

        var err;
        if (config.experimental_docker_nfs_shared_volumes !== true) {
            err = new Error('Volumes are not supported');
        }

        next(err);
    }
github joyent / sdc-docker / lib / backends / sdc / containers.js View on Github external
function dockerCopy(opts, callback) {
    assert.object(opts, 'opts');
    assert.object(opts.payload, 'opts.payload');
    assert.object(opts.log, 'opts.log');
    assert.string(opts.req_id, 'opts.req_id');
    assert.object(opts.account, 'opts.account');
    assert.object(opts.cnapi, 'opts.cnapi');

    var log = opts.log;
    var cnapi = opts.cnapi;
    var copyHeaders = { headers: { 'x-request-id': opts.req_id } };

    cnapi.dockerCopy(opts.vm.server_uuid, opts.vm.uuid, {
        payload: opts.payload,
        mode: 'read'
    }, copyHeaders, onCopy);

    function onCopy(copyErr, res) {
github science / openthermo / server / node_modules / restify / lib / server.js View on Github external
function Server(options) {
        assert.object(options, 'options');
        assert.object(options.log, 'options.log');
        assert.object(options.router, 'options.router');

        var self = this;

        EventEmitter.call(this);

        this.before = [];
        this.chain = [];
        this.log = options.log;
        this.name = options.name || 'restify';
        this.router = options.router;
        this.routes = {};
        this.secure = false;
        this.versions = options.versions || options.version || [];

        var fmt = mergeFormatters(options.formatters);
        this.acceptable = fmt.acceptable;
github sx1989827 / DOClever / node_modules / sshpk / lib / formats / openssh-cert.js View on Github external
function toBuffer(cert, noSig) {
	assert.object(cert.signatures.openssh, 'signature for openssh format');
	var sig = cert.signatures.openssh;

	if (sig.nonce === undefined)
		sig.nonce = crypto.randomBytes(16);
	var buf = new SSHBuffer({});
	buf.writeString(getCertType(cert.subjectKey));
	buf.writeBuffer(sig.nonce);

	var key = cert.subjectKey;
	var algInfo = algs.info[key.type];
	algInfo.parts.forEach(function (part) {
		buf.writePart(key.part[part]);
	});

	buf.writeInt64(cert.serial);