UNPKG

@e-group/utils

Version:

eGroup team utils that share across projects.

32 lines (25 loc) 714 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; /** * To solve index path bug please read this for more detail. * https://stackoverflow.com/questions/6393943/convert-javascript-string-in-dot-notation-into-an-object-reference */ const findDeepValue = (obj, path = '') => { var _path$match; const matchArray = (_path$match = path.match(/[^\]\\[.]+/g)) !== null && _path$match !== void 0 ? _path$match : []; const result = matchArray.reduce((o, i) => { if (o) { return o[i]; } return undefined; }, obj); if (!result) { return undefined; } return result; }; var _default = findDeepValue; exports.default = _default;