jointjs
Version:
JavaScript diagramming library
32 lines (28 loc) • 828 B
HTML
<pre class="docs-method-signature"><code>util.flattenObject(object, delim, stop)</code></pre>
<p>Flatten a nested <code>object</code> up until the <code>stop</code> function returns <code>true</code>. The <code>stop</code> function takes the value of the node currently traversed. <code>delim</code> is a delimiter for the combined keys in the resulting object. Example:</p>
<pre><code>joint.util.flattenObject({
a: {
a1: 1,
a2: 2,
a3: {
a31: 5,
a32: {
a321: { a3211: 5 }
}
}
},
b: 6
}, '/', function(v) { return !!v.a321; });
/*
{
"a/a1": 1,
"a/a2": 2,
"a/a3/a31": 5,
"a/a3/a32": {
"a321": {
"a3211": 5
}
},
"b": 6
}
*/</code></pre>