UNPKG

comparify

Version:

Simple criteria checking, so you can test a subset of an object's properties.

31 lines (25 loc) 652 B
/** * Get a value from an object using dotted key notation. * @param {String} key * @param {Object} object * @return Value */ exports.getKey = function(object, key) { var i; if ('undefined' !== typeof object[key]) return object[key]; key = (""+key).split('.'); for (i=0; i<key.length; i++) { object = object[key[i]]; if (typeof object === 'undefined') return; } return object; }; /** * Evaluates if an input is an object. * * @param input * @return {bool} Is input an object? */ exports.isObject = function(input) { return (null !== input) && ('object' === typeof input) && (!Array.isArray(input)); };