MCPcopy Create free account
hub / github.com/breck7/scroll / toFlatObject

Method toFlatObject

external/.scrollLibs.js:15993–16005  ·  view source on GitHub ↗
(delimiter = ".")

Source from the content-addressed store, hash-verified

15991 // Flatten a particle into an object like {twitter:"pldb", "twitter.followers":123}.
15992 // Assumes you have a nested key/value list with no multiline strings.
15993 toFlatObject(delimiter = ".") {
15994 let newObject = {}
15995 const { edgeSymbolRegex } = this
15996 this.forEach((subparticle, index) => {
15997 newObject[subparticle.getAtom(0)] = subparticle.content
15998 subparticle.topDownArray.forEach(particle => {
15999 const newColumnName = particle.getCuePathRelativeTo(this).replace(edgeSymbolRegex, delimiter)
16000 const value = particle.content
16001 newObject[newColumnName] = value
16002 })
16003 })
16004 return newObject
16005 }
16006 _toObject() {
16007 const obj = {}
16008 this.forEach(particle => {

Callers

nothing calls this directly

Calls 4

forEachMethod · 0.95
replaceMethod · 0.80
getCuePathRelativeToMethod · 0.80
getAtomMethod · 0.45

Tested by

no test coverage detected