How to use the jsprim.hasKey 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 / moray / lib / objects / common.js View on Github external
function _mapOp(direction) {
        var ltype, rtype, op;

        if (!jsprim.hasKey(b.index, f.attribute)) {
            throw new NotIndexedError(b.name, f.toString());
        }

        ltype = b.index[f.attribute].type;
        if (!jsprim.hasKey(TYPES, ltype)) {
            throw new InvalidQueryError(f.toString());
        }

        if (TYPES[ltype][direction] === null) {
            throw new InvalidQueryError(f.toString());
        }

        rtype = TYPES[ltype][direction].type;
        op = TYPES[ltype][direction].op;

        v = parse(f.value, f, rtype);

        args.push(v.value);

        if (TYPES[ltype].array) {
            clause += util.format('$%d::%s %s ANY(%s)',
github joyent / moray / lib / objects / common.js View on Github external
function _mapOp(direction) {
        var ltype, rtype, op;

        if (!jsprim.hasKey(b.index, f.attribute)) {
            throw new NotIndexedError(b.name, f.toString());
        }

        ltype = b.index[f.attribute].type;
        if (!jsprim.hasKey(TYPES, ltype)) {
            throw new InvalidQueryError(f.toString());
        }

        if (TYPES[ltype][direction] === null) {
            throw new InvalidQueryError(f.toString());
        }

        rtype = TYPES[ltype][direction].type;
        op = TYPES[ltype][direction].op;

        v = parse(f.value, f, rtype);
github joyent / moray / lib / objects / common.js View on Github external
function _value(schema, key, val, filter) {
    if (!jsprim.hasKey(schema, key)) {
        switch (key) {
        case '_id':
        case '_txn_snap':
        case '_mtime':
            return parse(val, filter, 'number');
        case '_etag':
        case '_key':
            return parse(val, filter, 'string');
        default:
            return {
                isArray: false,
                value: undefined
            };
        }
    }
github joyent / manatee / lib / postgresMgr.js View on Github external
try {
        tunables = JSON.parse(fs.readFileSync(this.tunablesFile, 'utf8'));
    } catch (e) {
        throw new verror.VError(e, 'failed to load %s', this.tunablesFile);
    }

    assert.ifError(mod_jsprim.validateJsonObject(TUNABLES_SCHEMA, tunables));

    function copy(source) {
        mod_jsprim.forEachKey(source, function (key, value) {
            options[key] = value;
        });
    }

    if (mod_jsprim.hasKey(tunables, 'common')) {
        copy(tunables['common']);
    }

    if (mod_jsprim.hasKey(tunables, major)) {
        copy(tunables[major]);
    }

    if (mod_jsprim.hasKey(tunables, version)) {
        copy(tunables[version]);
    }

    return (options);
};
github joyent / moray / lib / objects / common.js View on Github external
function _matchPgOnly(b, filter) {
    if (!jsprim.hasKey(b.index, filter.attribute)) {
        throw new NotIndexedError(b.name, filter.toString());
    }

    filter.matches = _matchAlwaysTrue;
}
github joyent / manatee / lib / postgresMgr.js View on Github external
throw new verror.VError(e, 'failed to load %s', this.tunablesFile);
    }

    assert.ifError(mod_jsprim.validateJsonObject(TUNABLES_SCHEMA, tunables));

    function copy(source) {
        mod_jsprim.forEachKey(source, function (key, value) {
            options[key] = value;
        });
    }

    if (mod_jsprim.hasKey(tunables, 'common')) {
        copy(tunables['common']);
    }

    if (mod_jsprim.hasKey(tunables, major)) {
        copy(tunables[major]);
    }

    if (mod_jsprim.hasKey(tunables, version)) {
        copy(tunables[version]);
    }

    return (options);
};