Scott H. on Nostr: If you don't want to use Lodash, you can use this trick: foo[bar]=foo[bar] || {} ...
If you don't want to use Lodash, you can use this trick:
foo[bar]=foo[bar] || {}
foo[bar][foobar]=null
This makes sure you don't clobber the branches as you build the graph.
This method isn't that far off from the design of NetworkX in Python land. I only use two functions from Lodash: setWith and get. Use lodash-cli to get a custom build.
Published at
2023-10-22 14:58:47Event JSON
{
"id": "2678e8ade1501bea60b41f98a50755ef3ef756e08b1c13770a0e238f04d34827",
"pubkey": "e32680a0c6478064701e49296a2b09d1ada5b276378f330600cfc01190afeac7",
"created_at": 1697986727,
"kind": 1,
"tags": [
[
"e",
"add12e395b792d16f5206f2520d9c38a3d0a94936a58869e3f48fc0d6f5dc9fb",
"wss://relay.mostr.pub",
"reply"
],
[
"content-warning",
"For those of you building graphs with JavaScript objects"
],
[
"proxy",
"https://fosstodon.org/users/scotth/statuses/111279258192175671",
"activitypub"
]
],
"content": "If you don't want to use Lodash, you can use this trick:\n\nfoo[bar]=foo[bar] || {}\nfoo[bar][foobar]=null\n\nThis makes sure you don't clobber the branches as you build the graph.\n\nThis method isn't that far off from the design of NetworkX in Python land. I only use two functions from Lodash: setWith and get. Use lodash-cli to get a custom build.",
"sig": "b72c00acad501ed503af4e9c7b5b128cf6663804137a8050d4120ad2daf291e72195bebfdba08a36cd120f913f6f928a853f4c503d7c8acd10ef1eaed9199c3d"
}