UNPKG

@storm-stack/utilities

Version:

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

16 lines (15 loc) 408 B
import { isNumber, isSetString } from "@storm-stack/types"; export function toDeepKey(path) { return path.reduce((ret, segment) => { return addPathToDeepKey(ret, segment); }); } export function addPathToDeepKey(deepKey, path) { if (isNumber(path) || Number.isInteger(path)) { return deepKey + `[${path}]`; } if (isSetString(path)) { return deepKey + `.${path}`; } return deepKey; }