UNPKG

@storm-stack/utilities

Version:

This package includes various base utility class and various functions to assist in the development process.

22 lines (21 loc) 557 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addPathToDeepKey = addPathToDeepKey; exports.toDeepKey = toDeepKey; var _types = require("@storm-stack/types"); function toDeepKey(path) { return path.reduce((ret, segment) => { return addPathToDeepKey(ret, segment); }); } function addPathToDeepKey(deepKey, path) { if ((0, _types.isNumber)(path) || Number.isInteger(path)) { return deepKey + `[${path}]`; } if ((0, _types.isSetString)(path)) { return deepKey + `.${path}`; } return deepKey; }