MCPcopy Create free account
hub / github.com/GCWing/BitFun / flattenKeys

Function flattenKeys

scripts/i18n-contract.test.mjs:72–80  ·  view source on GitHub ↗
(value, prefix = '')

Source from the content-addressed store, hash-verified

70}
71
72function flattenKeys(value, prefix = '') {
73 if (value == null || typeof value !== 'object' || Array.isArray(value)) {
74 return prefix ? [prefix] : [];
75 }
76
77 return Object.entries(value)
78 .flatMap(([key, child]) => flattenKeys(child, prefix ? `${prefix}.${key}` : key))
79 .sort();
80}
81
82function getValueByPath(value, dottedPath) {
83 return dottedPath.split('.').reduce((current, segment) => (

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected