How to use the typical.isObject function in typical

To help you get started, we’ve selected a few typical 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 75lb / array-tools / dist / array-tools.js View on Github external
return negate(a.exists(propertyValue, queryValue), isNegated);

        /* query value is a regex */
        } else if (queryValue instanceof RegExp){
            if ([ "boolean", "string", "number" ].indexOf(typeof propertyValue)  === -1){
                return isNegated;
            } else {
                return negate(queryValue.test(propertyValue), isNegated);
            }

        /* query value is a function */
        } else if (typeof queryValue === "function"){
            return negate(queryValue(propertyValue), isNegated);

        /* query and property value are objects */
        } else if (t.isObject(propertyValue) && t.isObject(queryValue)){
            return negate(exists(propertyValue, queryValue), isNegated);

        /* query value is a primitive */
        } else {
            return negate(queryValue === propertyValue, isNegated);
        }
    });
}
github 75lb / array-tools / dist / array-tools.js View on Github external
} else if (queryValue instanceof RegExp){
            if (!(typeof objectValue === "boolean" || typeof objectValue === "string" || typeof objectValue === "number")){
                found = isNegated;
            } else {
                found = isNegated
                    ? !queryValue.test(objectValue)
                    : queryValue.test(objectValue);
            }
            
        } else if (typeof queryValue === "function"){
            found = isNegated
                ? !queryValue(objectValue)
                : queryValue(objectValue);

        } else if (t.isObject(objectValue) && t.isObject(queryValue)){
            found = exists(objectValue, queryValue);
            
        } else {
            found = isNegated
                ? queryValue !== objectValue
                : queryValue === objectValue;
        }
        if (!found) break;
    }
    return found;
}
github 75lb / array-tools / dist / array-tools.js View on Github external
function exists(object, query){
    if (arguments.length !== 2) throw Error("expecting two args");
    if (!t.isObject(object)) throw Error("input object must be an object: " + object);
    if (!t.isObject(query)) throw Error("query must be an object: " + query);

    return Object.keys(query).every(function(prop){
        var queryValue = query[prop];
        var isNegated = false;
        var isContains = false;

        if (prop.charAt(0) === "!"){
            isNegated = true;
        } else if (prop.charAt(0) === "+") {
            isContains = true;
        }
        var propertyValue = object[(isNegated || isContains) ? prop.slice(1) : prop];
        if (isContains){
            queryValue = a.arrayify(queryValue);
            propertyValue = a.arrayify(propertyValue);
github 75lb / array-tools / dist / array-tools.js View on Github external
function exists(object, query){
    if (arguments.length !== 2) throw Error("expecting two args");
    if (!t.isObject(object)) throw Error("input object must be an object: " + object);
    if (!t.isObject(query)) throw Error("query must be an object: " + query);

    return Object.keys(query).every(function(prop){
        var queryValue = query[prop];
        var isNegated = false;
        var isContains = false;

        if (prop.charAt(0) === "!"){
            isNegated = true;
        } else if (prop.charAt(0) === "+") {
            isContains = true;
        }
        var propertyValue = object[(isNegated || isContains) ? prop.slice(1) : prop];
        if (isContains){
            queryValue = a.arrayify(queryValue);
            propertyValue = a.arrayify(propertyValue);
        }
github 75lb / array-tools / dist / array-tools.js View on Github external
function exists(object, query){
    if (arguments.length !== 2) throw Error("expecting two args");
    if (!t.isObject(object)) throw Error("input object must be an object: " + object);
    if (!t.isObject(query)) throw Error("query must be an object: " + query);

    return Object.keys(query).every(function(prop){
        var queryValue = query[prop];
        var isNegated = false;
        var isContains = false;

        if (prop.charAt(0) === "!"){
            isNegated = true;
        } else if (prop.charAt(0) === "+") {
            isContains = true;
        }
        var propertyValue = object[(isNegated || isContains) ? prop.slice(1) : prop];
        if (isContains){
            queryValue = a.arrayify(queryValue);
            propertyValue = a.arrayify(propertyValue);
        }
github 75lb / array-tools / dist / array-tools.js View on Github external
return args.reduce(function(prev, curr){
        if (typeof curr !== "object") return prev;
        for (var prop in curr){
            var value = curr[prop];
            if (t.isObject(value) && !Array.isArray(value) && depth < 10){
                if (!prev[prop]) prev[prop] = {};
                prev[prop] = extend(prev[prop], value, { __depth: ++depth });
            } else {
                prev[prop] = value;
            }
        }
        return prev;
    }, {});
}
github lwsjs / local-web-server / lib / cli-view.js View on Github external
const data = Object.keys(object).map(key => {
    if (t.isObject(object[key])) {
      return { key: ansi.format(key, 'bold'), value: objectToTable(object[key]) }
    } else {
      return { key: ansi.format(key, 'bold'), value: object[key] }
    }
  })
  return tableLayout(data, {

typical

Isomorphic, functional type-checking for Javascript

MIT
Latest version published 2 months ago

Package Health Score

74 / 100
Full package analysis