UNPKG

merge-change

Version:

Advanced library for deep merging, patching, and immutable updates of data structures. Features declarative operations for specific merging behaviors, property management, custom type merging rules, and difference tracking. Supports complex data transform

22 lines 860 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.splitPath = splitPath; /** * Splits a path into array elements, ignoring (trimming) the separator at the beginning and end of the string * @param path {string} Path to split * @param separator {string} Separator, for example, a point * @returns {(number|string)[]} */ function splitPath(path, separator = '.') { if (path.substring(0, separator.length) === separator) { path = path.substring(separator.length); } if (path.substring(path.length - separator.length) === separator) { path = path.substring(0, path.length - separator.length); } return path.split(separator).map((name) => { const index = Number(name); return !Number.isNaN(index) && index !== null ? index : name; }); } //# sourceMappingURL=index.js.map