UNPKG

@cookbook/dot-notation

Version:

Object readings and complex transformations using dot notation syntax.

26 lines (21 loc) 724 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _getKey = _interopRequireDefault(require("./get-key")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Create path breadcrumb * @desc parse dot notation syntax into path breadcrumbs * @param {string} path - dot notation path * @return {string[]} */ var createPathBreadcrumb = function createPathBreadcrumb(path) { return path.split(_getKey.default.regexp).filter(Boolean) // add default index for empty array notation .map(function (p) { return p === '[]' ? '[0]' : p; }); }; var _default = createPathBreadcrumb; exports.default = _default;