@justlep/camo
Version:
A class-based Object-Document Mapper (ODM) for NeDB
22 lines (17 loc) • 579 B
JavaScript
import depd from 'depd';
export const deprecate = depd('camo');
export const deepTraverse = function(obj, func) {
for (let i in obj) {
func.apply(this, [i, obj[i], obj]);
if (obj[i] && typeof obj[i] === 'object') {
deepTraverse(obj[i], func);
}
}
};
const _hasOwnProperty = Object.prototype.hasOwnProperty;
/**
* @param {*} obj - anything truthy; ignoring 0 or '' here is good enough
* @param {string|symbol} prop
* @return {boolean}
*/
export const hasOwnProp = (obj, prop) => obj ? _hasOwnProperty.call(obj, prop) : false;