How to use the assert-plus.func 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 / img / node_modules / docker-registry-client / lib / index.js View on Github external
function login(opts, cb) {
    assert.object(opts, 'opts');
    assert.string(opts.username, 'opts.username');
    assert.string(opts.password, 'opts.password');
    assert.optionalString(opts.email, 'opts.email');
    assert.func(cb, 'cb');

    reg2.ping(opts, function (pingErr, body, pingRes, req) {
        if (!pingRes) {
            assert.ok(pingErr, 'no err *or* res from v2 ping');
            cb(pingErr);
            return;
        }
        if (pingRes.statusCode === 404) {
            // The index doesn't support v2, so try v1 if we can.
            if (opts.email) {
                reg1.login(opts, cb);
            } else {
                cb(pingErr);
            }
        } else {
            reg2.login(common.objMerge({
github dudemelo / sails-hook-flash / test / request.js View on Github external
it('is callable ', function () {
      assert.func(
        request.addFlash,
        'Must be a function'
      );
      assert.ok(request.addFlash('success', 'Stores a message.'));
      assert.ok(request.addFlash('success', 'Stores another message.'));
    });
github joyent / sdc-docker / test / integration / helpers.js View on Github external
function stepNapi(state, cb) {
    assert.object(state, 'state');
    assert.func(cb, 'cb');

    if (state.napi) {
        return cb();
    }
    state.napi = new sdcClients.NAPI({
        url: 'http://' + state.sdcConfig.napi_domain,
        agent: false,
        userAgent: UA,
        log: state.log
    });
    cb();
}
github joyent / manatee / lib / syncStateChecker.js View on Github external
SyncStateChecker.prototype.stop = function (delCookie, cb) {
    assert.func(cb, 'cb');

    var self = this;
    self._log.info({
        currPrimaryUrl: self._primaryUrl,
        delCookie: delCookie
    }, 'SyncStateChecker.stop: entering');

    assert.func(cb, 'cb');

    vasync.pipeline({
        funcs: [
            function stopInterval(_, _cb) {
                if (self._intervalId) {
                    clearInterval(self._intervalId);
                    self._intervalId = null;
                }
github joyent / smartos-live / src / img / node_modules / sdc-clients / lib / imgapi.js View on Github external
function createImageFromVm(data, options, account, callback) {
    var self = this;
    if (callback === undefined) {
        callback = account;
        account = undefined;
    }
    assert.object(data, 'data');
    assert.object(options, 'options');
    assert.string(options.vm_uuid, 'options.vm_uuid');
    assert.optionalBool(options.incremental, 'options.incremental');
    assert.optionalObject(options.headers, 'options.headers');
    assert.optionalString(account, 'account');
    assert.func(callback, 'callback');

    var path = self._path('/images');
    path += self._qs({
        channel: self.channel,
        action: 'create-from-vm',
        vm_uuid: options.vm_uuid,
        incremental: options.incremental,
        account: account
    });
    self._getAuthHeaders(function (hErr, headers) {
        if (hErr) {
            callback(hErr);
            return;
        }
        if (options.headers) {
            simpleMerge(headers, options.headers);
github charlielin99 / Jobalytics / node_modules / getpass / lib / index.js View on Github external
function getPass(opts, cb) {
	if (typeof (opts) === 'function' && cb === undefined) {
		cb = opts;
		opts = {};
	}
	mod_assert.object(opts, 'options');
	mod_assert.func(cb, 'callback');

	mod_assert.optionalString(opts.prompt, 'options.prompt');
	if (opts.prompt === undefined)
		opts.prompt = 'Password';

	openTTY(function (err, rfd, wfd, rtty, wtty) {
		if (err) {
			cb(err);
			return;
		}

		wtty.write(opts.prompt + ':');
		rtty.resume();
		rtty.setRawMode(true);
		rtty.resume();
		rtty.setEncoding('utf8');
github joyent / smartos-live / src / img / node_modules / sdc-clients / lib / imgapi.js View on Github external
function agentKeyFromKeyId(agent, keyId, callback) {
    assert.object(agent, 'agent');
    assert.string(keyId, 'keyId');
    assert.func(callback, 'callback');

    fingerprintFromKeyId(keyId, function (err, fingerprint) {
        if (err) {
            callback(err);
            return;
        }

        agent.requestIdentities(function (err, keys) {
            if (err) {
                callback(err);
                return;
            }

            /**
             * A key looks like this:
             *   { type: 'ssh-rsa',
github Andyliwr / FE-learning-load / task08 / lidikang / styles / node_modules / sshpk / lib / private-key.js View on Github external
PrivateKey._oldVersionDetect = function (obj) {
	assert.func(obj.toPublic);
	assert.func(obj.createSign);
	if (obj.derive)
		return ([1, 3]);
	if (obj.defaultHashAlgorithm)
		return ([1, 2]);
	if (obj.formats['auto'])
		return ([1, 1]);
	return ([1, 0]);
};
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-nfs / lib / fhdb.js View on Github external
fhdb.prototype.fhandle = function fhandle(fh, cb) {
    assert.string(fh, 'fhandle');
    assert.func(cb, 'callback');

    cb = once(cb);

    var k = sprintf(FNAME_KEY_FMT, fh);
    var log = this.log;
    var self = this;

    log.trace('fhandle(%s): entered', fh);
    self.db.get(k, function (err, fname) {
        if (err) {
            log.trace(err, 'fhandle(%s): error', fh);
            cb(err);
        } else {
            log.trace('fhandle(%s): done => %s', fh, fname);
            cb(null, fname);
        }