How to use the jsprim.forEachKey function in jsprim

To help you get started, we’ve selected a few jsprim 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 / dragnet / lib / config-common.js View on Github external
DragnetConfig.prototype.datasourceList = function (func)
{
	mod_jsprim.forEachKey(this.dc_datasources, func);
};
github joyent / manatee / lib / postgresMgr.js View on Github external
function copy(source) {
        mod_jsprim.forEachKey(source, function (key, value) {
            options[key] = value;
        });
    }
github joyent / dragnet / lib / index-sink.js View on Github external
IndexSink.prototype.doCreateTable = function (tablename, columns, callback)
{
	var sql = '';
	var collines;

	sql  = 'CREATE TABLE ' + tablename + '(\n';
	collines = [];
	mod_jsprim.forEachKey(columns, function (key, value) {
		collines.push('    ' + key + ' ' + value);
	});
	sql += collines.join(',\n');
	sql += '\n);';

	this.is_log.debug({
	    'table': tablename,
	    'columns': Object.keys(columns)
	}, 'create table');
	this.is_db.exec(sql, callback);
};
github joyent / dragnet / lib / config-common.js View on Github external
DragnetConfig.prototype.datasourceListMetrics = function (dsname, func)
{
	mod_assertplus.ok(this.dc_datasources.hasOwnProperty(dsname));
	if (!this.dc_metrics.hasOwnProperty(dsname))
		return;
	mod_jsprim.forEachKey(this.dc_metrics[dsname], func);
};
github joyent / manatee-state-machine / lib / stream-bunyan-prettyprint.js View on Github external
var stream = this;
	var level;

	switch (chunk.level) {
	case mod_bunyan.TRACE:		level = 'TRACE'; break;
	case mod_bunyan.DEBUG:		level = 'DEBUG'; break;
	case mod_bunyan.INFO:		level = 'INFO';  break;
	case mod_bunyan.WARN:		level = 'WARN';  break;
	case mod_bunyan.ERROR:		level = 'ERROR'; break;
	case mod_bunyan.FATAL:		level = 'FATAL'; break;
	default:			level = '?????'; break;
	}

	this.push(sprintf('[%5s] %s: %s\n', level, component, message));

	mod_jsprim.forEachKey(chunk, function (key, value) {
		if (bunyanStdKeys.hasOwnProperty(key))
			return;
		stream.push(sprintf('  %10s: %j\n', key, value));
	});

	callback();
};
github joyent / dragnet / lib / dragnet-impl.js View on Github external
'm_breakdowns': metconfig.breakdowns.map(function (b) {
		var rv = {};
		mod_jsprim.forEachKey(b, function (k, v) {
			rv['b_' + k] = v;
		});
		return (rv);
	    })
	});
github joyent / manatee / lib / common.js View on Github external
function zfsCreate(opts, callback) {
    mod_assert.object(opts, 'opts');
    mod_assert.object(opts.log, 'opts.log');
    mod_assert.string(opts.dataset, 'opts.dataset');
    mod_assert.optionalObject(opts.props, 'opts.props');
    mod_assert.func(callback, 'callback');

    var args = [ 'create' ];
    if (opts.props) {
        mod_jsprim.forEachKey(opts.props, function (prop, val) {
            args.push('-o', prop + '=' + val);
        });
    }
    args.push(opts.dataset);

    opts.log.info('create ZFS dataset "%s"', opts.dataset);

    zfsExecCommon(opts.log, args, function (err, info) {
        if (err) {
            callback(new VE(err, 'create dataset "%s"', opts.dataset));
            return;
        }

        callback();
    });
}
github joyent / node-krill / lib / krill.js View on Github external
function createPredicate(pred, types)
{
	krillPrimValidateSyntax(pred);

	if (arguments.length >= 2 && types !== null) {
		mod_jsprim.forEachKey(types, function (k, v) {
			if (v !== 'string' && v !== 'number' && v !== 'boolean')
				throw (new VError(
				    'field "%s": unknown type "%s"', k, v));
		});

		krillPrimValidateTypes(types, pred);
	}

	return (new Predicate(mod_jsprim.deepCopy(pred), types));
}