UNPKG

jointjs

Version:

JavaScript diagramming library

32 lines (28 loc) 828 B
<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; }); /* { &quot;a/a1&quot;: 1, &quot;a/a2&quot;: 2, &quot;a/a3/a31&quot;: 5, &quot;a/a3/a32&quot;: { &quot;a321&quot;: { &quot;a3211&quot;: 5 } }, &quot;b&quot;: 6 } */</code></pre>