UNPKG

kibana-123

Version:

Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic

26 lines (22 loc) 534 B
import _ from 'lodash'; import toPath from 'lodash/internal/toPath'; module.exports = function unset(object, rawPath) { if (!object) return; const path = toPath(rawPath); switch (path.length) { case 0: return; case 1: delete object[rawPath]; break; default: const leaf = path.pop(); const parentPath = path.slice(); const parent = _.get(object, parentPath); unset(parent, leaf); if (!_.size(parent)) { unset(object, parentPath); } break; } };