
/**
 * Delete keys whose value is null.
 *
 */
function removeNulls (obj) {

	function getType (obj) {
		return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();
	}

	for (let [key, value] of Object.entries(obj)) {
		if (value === null) {
			delete obj[key];
		} else if (getType(value) == "object") {
			removeNulls(value);
		}
	}

	return obj;
}

module.exports = removeNulls;
