Preview: path-to-parts.js
Size: 701 B
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/lib/utils/flat/path-to-parts.js
/**
* @memberof module:flat
* @alias PathToPartsOptions
*/
/**
* @load ./path-to-parts.doc.md
* @param {string} propertyPath
* @param {PathToPartsOptions} options
* @returns {PathParts}
*
* @memberof module:flat
* @alias pathToParts
*/
const pathToParts = (propertyPath, options = {}) => {
let allParts = propertyPath.split('.');
if (options.skipArrayIndexes) {
// eslint-disable-next-line no-restricted-globals
allParts = allParts.filter(part => isNaN(+part));
}
return allParts.reduce((memo, part) => {
if (memo.length) {
return [...memo, [memo[memo.length - 1], part].join('.')];
}
return [part];
}, []);
};
export { pathToParts };
Directory Contents
Dirs: 0 × Files: 26