<?xml version="1.0" encoding="utf-8"?>

<feed xmlns="http://www.w3.org/2005/Atom">
<title>Tyler Cipriani: pages tagged javascript</title>
<link href="https://tylercipriani.com/tags/javascript/"/>
<link href="https://tylercipriani.com/tags/javascript/index.atom" rel="self" type="application/atom+xml"/>
<author>

<name>Tyler Cipriani</name>

</author>




<id>https://tylercipriani.com/tags/javascript/</id>

<subtitle type="html">Tyler Cipriani</subtitle>
<generator uri="http://ikiwiki.info/">ikiwiki</generator>
<updated>2017-07-01T00:49:09Z</updated>
<entry>
	<title>Visualizing Git&#x2019;s Merkle DAG with D3.js</title>

	<id>https://tylercipriani.com/blog/2016/03/21/Visualizing-Git-Merkle-DAG-with-D3.js/</id>

	<link href="https://tylercipriani.com/blog/2016/03/21/Visualizing-Git-Merkle-DAG-with-D3.js/"/>

	<author><name>Tyler Cipriani</name></author>


	<rights type="html" xml:lang="en">

		&lt;a href=&quot;https://creativecommons.org/licenses/by-sa/4.0/&quot;&gt;Creative Commons Attribution-ShareAlike License&lt;/a&gt;
		Copyright © 2017 Tyler Cipriani

	</rights>



	<category term="computing" />

	<category term="javascript" />

	<category term="vcs" />


	<updated>2017-07-01T00:49:09Z</updated>
	<published>2016-03-21T00:00:00Z</published>


	<content type="html" xml:lang="en">
	&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Directed_acyclic_graph&quot;&gt;Directed Acyclic Graph&lt;/a&gt; (DAG) is a concept I run into over-and-over again; which is, perhaps, somewhat ironic.&lt;/p&gt;
&lt;p&gt;A DAG is a representation of vertices (nodes) that are connected by directional edges (arcs—i.e., lines) in such a way that there are no cycles (e.g., starting at &lt;code&gt;Node A&lt;/code&gt;, you shouldn’t be able to return to &lt;code&gt;Node A&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;DAGs have lots of uses in computer science problems and in discrete mathematics. You’ll find DAGs in build-systems, network problems, and, importantly (for this blog post, if not generally) in Git.&lt;/p&gt;
&lt;p&gt;One way to think of a DAG is as a set of dependencies—each node may have a dependency on one or more other nodes. That is, in order to get to &lt;code&gt;Node B&lt;/code&gt; you must route through &lt;code&gt;Node A&lt;/code&gt;, so &lt;code&gt;Node B&lt;/code&gt; depends on &lt;code&gt;Node A&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb1&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;co&quot;&gt;// Node → [dependent nodes]&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-2&quot; title=&quot;2&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; dag &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-3&quot; title=&quot;3&quot;&gt;    &lt;span class=&quot;st&quot;&gt;&amp;#39;Node A&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; [&lt;span class=&quot;st&quot;&gt;&amp;#39;Node B&amp;#39;&lt;/span&gt;]&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-4&quot; title=&quot;4&quot;&gt;    &lt;span class=&quot;st&quot;&gt;&amp;#39;Node B&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; []&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-5&quot; title=&quot;5&quot;&gt;&lt;span class=&quot;op&quot;&gt;};&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The visualization of dependencies in a JSON object is (SURPRISE!) different from the input format needed to visualize a DAG using the &lt;a href=&quot;https://github.com/mbostock/d3/wiki/Force-Layout&quot;&gt;D3.js Force layout&lt;/a&gt;. To change the above object into Force’s expected input, I created a little helper function:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb2&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; forceFormat &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(dag) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-2&quot; title=&quot;2&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; orderedNodes &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; []&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-3&quot; title=&quot;3&quot;&gt;        nodes &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; []&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-4&quot; title=&quot;4&quot;&gt;        links &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; []&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-5&quot; title=&quot;5&quot;&gt;        usesPack &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-6&quot; title=&quot;6&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-7&quot; title=&quot;7&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// Basically a dumb Object.keys&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-8&quot; title=&quot;8&quot;&gt;    &lt;span class=&quot;cf&quot;&gt;for&lt;/span&gt; (node &lt;span class=&quot;kw&quot;&gt;in&lt;/span&gt; dag) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-9&quot; title=&quot;9&quot;&gt;        &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; ( &lt;span class=&quot;op&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;va&quot;&gt;dag&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;hasOwnProperty&lt;/span&gt;( node ) ) &lt;span class=&quot;cf&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-10&quot; title=&quot;10&quot;&gt;        &lt;span class=&quot;va&quot;&gt;orderedNodes&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;push&lt;/span&gt;(node)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-11&quot; title=&quot;11&quot;&gt;    &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-12&quot; title=&quot;12&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-13&quot; title=&quot;13&quot;&gt;    &lt;span class=&quot;va&quot;&gt;orderedNodes&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;forEach&lt;/span&gt;(&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(node) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-14&quot; title=&quot;14&quot;&gt;        &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; sources &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; dag[node]&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-15&quot; title=&quot;15&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-16&quot; title=&quot;16&quot;&gt;        &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;op&quot;&gt;!&lt;/span&gt;sources) &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-17&quot; title=&quot;17&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-18&quot; title=&quot;18&quot;&gt;        &lt;span class=&quot;va&quot;&gt;sources&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;forEach&lt;/span&gt;(&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(source) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-19&quot; title=&quot;19&quot;&gt;            &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; source &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;orderedNodes&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;indexOf&lt;/span&gt;(source)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-20&quot; title=&quot;20&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-21&quot; title=&quot;21&quot;&gt;            &lt;span class=&quot;co&quot;&gt;// If the source isn&amp;#39;t in the Git DAG, it&amp;#39;s in a packfile&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-22&quot; title=&quot;22&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (source &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;0&lt;/span&gt;) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-23&quot; title=&quot;23&quot;&gt;                &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (usesPack) &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-24&quot; title=&quot;24&quot;&gt;                source &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;orderedNodes&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-25&quot; title=&quot;25&quot;&gt;                usesPack &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-26&quot; title=&quot;26&quot;&gt;            &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-27&quot; title=&quot;27&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-28&quot; title=&quot;28&quot;&gt;            &lt;span class=&quot;va&quot;&gt;links&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;push&lt;/span&gt;(&lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-29&quot; title=&quot;29&quot;&gt;                &lt;span class=&quot;st&quot;&gt;&amp;#39;source&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; source&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-30&quot; title=&quot;30&quot;&gt;                &lt;span class=&quot;st&quot;&gt;&amp;#39;target&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;orderedNodes&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;indexOf&lt;/span&gt;(node)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-31&quot; title=&quot;31&quot;&gt;            &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-32&quot; title=&quot;32&quot;&gt;        &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-33&quot; title=&quot;33&quot;&gt;        &lt;span class=&quot;va&quot;&gt;nodes&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;push&lt;/span&gt;(&lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;st&quot;&gt;&amp;#39;name&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; node&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-34&quot; title=&quot;34&quot;&gt;    &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-35&quot; title=&quot;35&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-36&quot; title=&quot;36&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// Add pack file to end of list&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-37&quot; title=&quot;37&quot;&gt;    &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (usesPack) &lt;span class=&quot;va&quot;&gt;nodes&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;push&lt;/span&gt;(&lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;st&quot;&gt;&amp;#39;name&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;PACK&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-38&quot; title=&quot;38&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-39&quot; title=&quot;39&quot;&gt;    &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;nodes&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; nodes&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;links&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; links &lt;span class=&quot;op&quot;&gt;};&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-40&quot; title=&quot;40&quot;&gt;&lt;span class=&quot;op&quot;&gt;};&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-41&quot; title=&quot;41&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-42&quot; title=&quot;42&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; forceInput &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;at&quot;&gt;forceFormat&lt;/span&gt;(dag)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;forceFormat&lt;/code&gt; outputs a JSON object that can be used as input for the Force layout.&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb3&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-2&quot; title=&quot;2&quot;&gt;    &lt;span class=&quot;st&quot;&gt;&amp;quot;links&amp;quot;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; [&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-3&quot; title=&quot;3&quot;&gt;        &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-4&quot; title=&quot;4&quot;&gt;            &lt;span class=&quot;st&quot;&gt;&amp;quot;source&amp;quot;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;quot;Node A&amp;quot;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-5&quot; title=&quot;5&quot;&gt;            &lt;span class=&quot;st&quot;&gt;&amp;quot;target&amp;quot;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;quot;Node B&amp;quot;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-6&quot; title=&quot;6&quot;&gt;        &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-7&quot; title=&quot;7&quot;&gt;    ]&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-8&quot; title=&quot;8&quot;&gt;    &lt;span class=&quot;st&quot;&gt;&amp;quot;nodes&amp;quot;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; [&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-9&quot; title=&quot;9&quot;&gt;        &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;quot;Node A&amp;quot;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;},&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-10&quot; title=&quot;10&quot;&gt;        &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;quot;Node B&amp;quot;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-11&quot; title=&quot;11&quot;&gt;    ]&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-12&quot; title=&quot;12&quot;&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I can pass this resulting JSON object off to a function that I created after a long time staring at one of &lt;a href=&quot;https://github.com/mbostock/d3/wiki/Gallery&quot;&gt;mbostock&lt;/a&gt;’s many amazing &lt;a href=&quot;http://bl.ocks.org/mbostock/1138500&quot;&gt;examples&lt;/a&gt; to create a D3 Force graph of verticies and edges:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb4&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;co&quot;&gt;// http://bl.ocks.org/mbostock/1138500&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-2&quot; title=&quot;2&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; makeGraph  &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(target&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; graphData) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-3&quot; title=&quot;3&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; target &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d3&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;select&lt;/span&gt;(target)&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-4&quot; title=&quot;4&quot;&gt;        bounds &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;target&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;node&lt;/span&gt;().&lt;span class=&quot;at&quot;&gt;getBoundingClientRect&lt;/span&gt;()&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-5&quot; title=&quot;5&quot;&gt;        fill   &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d3&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;scale&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;category20&lt;/span&gt;()&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-6&quot; title=&quot;6&quot;&gt;        radius &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-7&quot; title=&quot;7&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-8&quot; title=&quot;8&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; svg &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;target&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;append&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;svg&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-9&quot; title=&quot;9&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;width&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;bounds&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;width&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-10&quot; title=&quot;10&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;height&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;bounds&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;height&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-11&quot; title=&quot;11&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-12&quot; title=&quot;12&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// Arrow marker for end-of-line arrow&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-13&quot; title=&quot;13&quot;&gt;    &lt;span class=&quot;va&quot;&gt;svg&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;append&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;defs&amp;#39;&lt;/span&gt;).&lt;span class=&quot;at&quot;&gt;append&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;marker&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-14&quot; title=&quot;14&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;id&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;arrowhead&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-15&quot; title=&quot;15&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;refX&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;fl&quot;&gt;17.5&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-16&quot; title=&quot;16&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;refY&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;2&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-17&quot; title=&quot;17&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;markerWidth&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;8&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-18&quot; title=&quot;18&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;markerHeight&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;4&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-19&quot; title=&quot;19&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;orient&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;auto&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-20&quot; title=&quot;20&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;fill&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;#ccc&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-21&quot; title=&quot;21&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;append&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;path&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-22&quot; title=&quot;22&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;d&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;M 0,0 V 4 L6,2 Z&amp;#39;&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-23&quot; title=&quot;23&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-24&quot; title=&quot;24&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; link &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;svg&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;selectAll&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;line&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-25&quot; title=&quot;25&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;data&lt;/span&gt;(&lt;span class=&quot;va&quot;&gt;graphData&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;links&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-26&quot; title=&quot;26&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;enter&lt;/span&gt;()&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-27&quot; title=&quot;27&quot;&gt;            .&lt;span class=&quot;at&quot;&gt;append&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;line&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-28&quot; title=&quot;28&quot;&gt;                .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;class&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;link&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-29&quot; title=&quot;29&quot;&gt;                .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;marker-end&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;url(#arrowhead)&amp;#39;&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-30&quot; title=&quot;30&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-31&quot; title=&quot;31&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// Create a group for each node&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-32&quot; title=&quot;32&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; node &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;svg&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;selectAll&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;g&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-33&quot; title=&quot;33&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;data&lt;/span&gt;(&lt;span class=&quot;va&quot;&gt;graphData&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;nodes&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-34&quot; title=&quot;34&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;enter&lt;/span&gt;()&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-35&quot; title=&quot;35&quot;&gt;            .&lt;span class=&quot;at&quot;&gt;append&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;g&amp;#39;&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-36&quot; title=&quot;36&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-37&quot; title=&quot;37&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// Color the node based on node&amp;#39;s git-type (otherwise, hot pink!)&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-38&quot; title=&quot;38&quot;&gt;    &lt;span class=&quot;va&quot;&gt;node&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;append&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;circle&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-39&quot; title=&quot;39&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;r&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; radius)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-40&quot; title=&quot;40&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;class&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;node&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-41&quot; title=&quot;41&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;fill&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(d) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-42&quot; title=&quot;42&quot;&gt;            &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; blue  &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;#1BA1E2&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-43&quot; title=&quot;43&quot;&gt;                red   &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;tomato&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-44&quot; title=&quot;44&quot;&gt;                green &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;#5BB75B&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-45&quot; title=&quot;45&quot;&gt;                pink  &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;#FE57A1&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-46&quot; title=&quot;46&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-47&quot; title=&quot;47&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;name&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;endsWith&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;.b&amp;#39;&lt;/span&gt;)) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; red&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-48&quot; title=&quot;48&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;name&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;endsWith&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;.t&amp;#39;&lt;/span&gt;)) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; blue&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-49&quot; title=&quot;49&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;name&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;endsWith&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;.c&amp;#39;&lt;/span&gt;)) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; green&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-50&quot; title=&quot;50&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; pink&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-51&quot; title=&quot;51&quot;&gt;        &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-52&quot; title=&quot;52&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-53&quot; title=&quot;53&quot;&gt;    &lt;span class=&quot;va&quot;&gt;node&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;append&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;text&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-54&quot; title=&quot;54&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;y&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; radius &lt;span class=&quot;op&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;fl&quot;&gt;1.5&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-55&quot; title=&quot;55&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;text-anchor&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;middle&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-56&quot; title=&quot;56&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;fill&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;#555&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-57&quot; title=&quot;57&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;text&lt;/span&gt;(&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(d) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-58&quot; title=&quot;58&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;name&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;10&lt;/span&gt;) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-59&quot; title=&quot;59&quot;&gt;                &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;name&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;substring&lt;/span&gt;(&lt;span class=&quot;dv&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;8&lt;/span&gt;) &lt;span class=&quot;op&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;...&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-60&quot; title=&quot;60&quot;&gt;            &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-61&quot; title=&quot;61&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-62&quot; title=&quot;62&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-63&quot; title=&quot;63&quot;&gt;         &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-64&quot; title=&quot;64&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-65&quot; title=&quot;65&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// If the node has a type: tag it&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-66&quot; title=&quot;66&quot;&gt;    &lt;span class=&quot;va&quot;&gt;node&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;append&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;text&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-67&quot; title=&quot;67&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;text-anchor&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;middle&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-68&quot; title=&quot;68&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;y&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;4&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-69&quot; title=&quot;69&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;fill&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;white&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-70&quot; title=&quot;70&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;class&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;bold-text&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-71&quot; title=&quot;71&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;text&lt;/span&gt;(&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(d) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-72&quot; title=&quot;72&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;name&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;endsWith&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;.b&amp;#39;&lt;/span&gt;)) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;BLOB&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-73&quot; title=&quot;73&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;name&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;endsWith&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;.t&amp;#39;&lt;/span&gt;)) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;TREE&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-74&quot; title=&quot;74&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;name&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;endsWith&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;.c&amp;#39;&lt;/span&gt;)) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;COMMIT&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-75&quot; title=&quot;75&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-76&quot; title=&quot;76&quot;&gt;         &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-77&quot; title=&quot;77&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-78&quot; title=&quot;78&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; charge &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;700&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;graphData&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;nodes&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-79&quot; title=&quot;79&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-80&quot; title=&quot;80&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; force &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d3&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;layout&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;force&lt;/span&gt;()&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-81&quot; title=&quot;81&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;size&lt;/span&gt;([&lt;span class=&quot;va&quot;&gt;bounds&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;bounds&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;height&lt;/span&gt;])&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-82&quot; title=&quot;82&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;nodes&lt;/span&gt;(&lt;span class=&quot;va&quot;&gt;graphData&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;nodes&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-83&quot; title=&quot;83&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;links&lt;/span&gt;(&lt;span class=&quot;va&quot;&gt;graphData&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;links&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-84&quot; title=&quot;84&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;linkDistance&lt;/span&gt;(&lt;span class=&quot;dv&quot;&gt;150&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-85&quot; title=&quot;85&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;charge&lt;/span&gt;(&lt;span class=&quot;op&quot;&gt;-&lt;/span&gt;(charge))&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-86&quot; title=&quot;86&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;gravity&lt;/span&gt;(&lt;span class=&quot;dv&quot;&gt;1&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-87&quot; title=&quot;87&quot;&gt;        .&lt;span class=&quot;at&quot;&gt;on&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;tick&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; tick)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-88&quot; title=&quot;88&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-89&quot; title=&quot;89&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// No fancy animation, tick amount varies based on number of nodes&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-90&quot; title=&quot;90&quot;&gt;    &lt;span class=&quot;va&quot;&gt;force&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;start&lt;/span&gt;()&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-91&quot; title=&quot;91&quot;&gt;    &lt;span class=&quot;cf&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; i &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;graphData&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;nodes&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;++&lt;/span&gt;i) &lt;span class=&quot;va&quot;&gt;force&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;tick&lt;/span&gt;()&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-92&quot; title=&quot;92&quot;&gt;    &lt;span class=&quot;va&quot;&gt;force&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;stop&lt;/span&gt;()&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-93&quot; title=&quot;93&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-94&quot; title=&quot;94&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;at&quot;&gt;tick&lt;/span&gt;(e) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-95&quot; title=&quot;95&quot;&gt;        &lt;span class=&quot;co&quot;&gt;// Push sources up and targets down to form a weak tree.&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-96&quot; title=&quot;96&quot;&gt;        &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; k &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;-12&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;e&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-97&quot; title=&quot;97&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-98&quot; title=&quot;98&quot;&gt;        link&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-99&quot; title=&quot;99&quot;&gt;            .&lt;span class=&quot;at&quot;&gt;each&lt;/span&gt;(&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(d) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;source&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;-=&lt;/span&gt; k&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;target&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;+=&lt;/span&gt; k&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-100&quot; title=&quot;100&quot;&gt;                .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;x2&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(d) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;source&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-101&quot; title=&quot;101&quot;&gt;                .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;y2&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(d) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;source&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-102&quot; title=&quot;102&quot;&gt;                .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;x1&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(d) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;target&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-103&quot; title=&quot;103&quot;&gt;                .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;y1&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(d) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;target&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-104&quot; title=&quot;104&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-105&quot; title=&quot;105&quot;&gt;        node&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-106&quot; title=&quot;106&quot;&gt;            .&lt;span class=&quot;at&quot;&gt;attr&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;transform&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(d) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-107&quot; title=&quot;107&quot;&gt;                &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;translate(&amp;#39;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;,&amp;#39;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;d&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;)&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-108&quot; title=&quot;108&quot;&gt;            &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-109&quot; title=&quot;109&quot;&gt;    &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-110&quot; title=&quot;110&quot;&gt;&lt;span class=&quot;op&quot;&gt;};&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-111&quot; title=&quot;111&quot;&gt;&lt;span class=&quot;at&quot;&gt;makeGraph&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;.merkle-1&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; forceInput)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;merkle-1&quot;&gt;

&lt;/div&gt;
&lt;p&gt;You’d be forgiven for thinking that is a line.&lt;/p&gt;
&lt;p&gt;This directional line &lt;em&gt;is&lt;/em&gt; a DAG—albeit a simple one. &lt;code&gt;Node B&lt;/code&gt; depends on &lt;code&gt;Node A&lt;/code&gt; and that is the whole graph. If you want to get to &lt;code&gt;Node B&lt;/code&gt; then you have to start at &lt;code&gt;Node A&lt;/code&gt;. Depending on your problem-space, &lt;code&gt;Node B&lt;/code&gt; could be many things: A place in &lt;a href=&quot;https://en.wikipedia.org/wiki/Seven_Bridges_of_K%C3%B6nigsberg&quot;&gt;Königsberg&lt;/a&gt;, a target in a Makefile (or a &lt;a href=&quot;http://martinfowler.com/articles/rake.html&quot;&gt;Rakefile&lt;/a&gt;), or (brace yourself) a &lt;em&gt;Git object&lt;/em&gt;.&lt;/p&gt;
&lt;section id=&quot;git-object-anatomy&quot; class=&quot;level2&quot;&gt;
&lt;h2&gt;Git Object Anatomy &lt;a href=&quot;https://tylercipriani.com/tags/javascript/#git-object-anatomy&quot;&gt;¶&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In order to understand how Git is a DAG, you need to understand Git “objects”:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb5&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb5-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;mkdir&lt;/span&gt; merkle&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb5-2&quot; title=&quot;2&quot;&gt;$ &lt;span class=&quot;bu&quot;&gt;cd&lt;/span&gt; merkle&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb5-3&quot; title=&quot;3&quot;&gt;$ &lt;span class=&quot;bu&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;This is the beginning&amp;#39;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; README&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb5-4&quot; title=&quot;4&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;git&lt;/span&gt; init&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb5-5&quot; title=&quot;5&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;git&lt;/span&gt; add .&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb5-6&quot; title=&quot;6&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;git&lt;/span&gt; -m &lt;span class=&quot;st&quot;&gt;&amp;#39;Initial Commit&amp;#39;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb5-7&quot; title=&quot;7&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;find&lt;/span&gt; .git/objects/ -type f&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb5-8&quot; title=&quot;8&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/1b/9f426a8407ffee551ad2993c5d7d3780296353&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb5-9&quot; title=&quot;9&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/09/8e6de29daf4e55f83406b49f5768df9bc7d624&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb5-10&quot; title=&quot;10&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/1a/06ce381ac14f7a5baa1670691c2ff8a73aa6da&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;What are Git objects? Because they look like nonsense:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb6&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb6-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;cat&lt;/span&gt; .git/objects/1b/9f426a8407ffee551ad2993c5d7d3780296353&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb6-2&quot; title=&quot;2&quot;&gt;&lt;span class=&quot;ex&quot;&gt;xKOR02&lt;/span&gt;,V¢T¤̼¼̼t.&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After a little digging through the &lt;a href=&quot;https://git-scm.com/book/en/v2/Git-Internals-Git-Objects&quot;&gt;Pro Git&lt;/a&gt; book, Git objects are a little less non-sensicle. Git objects are simply &lt;code&gt;zlib&lt;/code&gt; compressed, formatted messages:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb7&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb7-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;ex&quot;&gt;python2&lt;/span&gt; -c &lt;span class=&quot;st&quot;&gt;&amp;#39;import sys,zlib; \&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb7-2&quot; title=&quot;2&quot;&gt;&lt;span class=&quot;st&quot;&gt;  print zlib.decompress(sys.stdin.read());&amp;#39;&lt;/span&gt; \&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb7-3&quot; title=&quot;3&quot;&gt;    &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt; .git/objects/1a/06ce381ac14f7a5baa1670691c2ff8a73aa6da&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb7-4&quot; title=&quot;4&quot;&gt;&lt;span class=&quot;ex&quot;&gt;commit&lt;/span&gt; 195tree 098e6de29daf4e55f83406b49f5768df9bc7d624&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb7-5&quot; title=&quot;5&quot;&gt;&lt;span class=&quot;ex&quot;&gt;author&lt;/span&gt; Tyler Cipriani &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt;tcipriani@wikimedia.org&lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; 1458604120 -0700&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb7-6&quot; title=&quot;6&quot;&gt;&lt;span class=&quot;ex&quot;&gt;committer&lt;/span&gt; Tyler Cipriani &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt;tcipriani@wikimedia.org&lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; 1458604120 -0700&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb7-7&quot; title=&quot;7&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb7-8&quot; title=&quot;8&quot;&gt;&lt;span class=&quot;ex&quot;&gt;Initial&lt;/span&gt; Commit&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Parts of that message are obvious: &lt;code&gt;author&lt;/code&gt; and &lt;code&gt;committer&lt;/code&gt; obviously come from my &lt;code&gt;.gitconfig&lt;/code&gt;. There is a Unix epoch timestamp with a timezone offset. &lt;code&gt;commit&lt;/code&gt; is the type of object. &lt;code&gt;195&lt;/code&gt; is the byte-length of the remainder of the message.&lt;/p&gt;
&lt;p&gt;There are a few parts of that message that aren’t immediately obvious. What is &lt;code&gt;tree 098e6de29daf4e55f83406b49f5768df9bc7d624&lt;/code&gt;? And why would we store this message in &lt;code&gt;.git/objects/1a/06ce381ac14f7a5baa1670691c2ff8a73aa6da&lt;/code&gt; and not &lt;code&gt;.git/objects/commit-message&lt;/code&gt;? Is a &lt;em&gt;merkle&lt;/em&gt; what I think it is? The answer to all of these questions and many more is the same: &lt;a href=&quot;https://en.wikipedia.org/wiki/Cryptographic_hash_function&quot;&gt;Cryptographic Hash Functions&lt;/a&gt;.&lt;/p&gt;
&lt;/section&gt;
&lt;section id=&quot;hash-functions&quot; class=&quot;level2&quot;&gt;
&lt;h2&gt;Hash Functions &lt;a href=&quot;https://tylercipriani.com/tags/javascript/#hash-functions&quot;&gt;¶&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A cryptographic hash function is a function that when given an input of any length it creates a fixed-length output. Furthermore (and more importantly), the fixed-length output should be unique to a given input; any change in input will likely cause a big change in the output. Git uses a cryptographic hash function called &lt;em&gt;Secure Hash Algorithm 1&lt;/em&gt; (&lt;a href=&quot;https://en.wikipedia.org/wiki/SHA-1&quot;&gt;SHA-1&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;You can play with the SHA-1 function on the command line:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb8&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb8-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;bu&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;message&amp;#39;&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;ex&quot;&gt;sha1sum&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb8-2&quot; title=&quot;2&quot;&gt;&lt;span class=&quot;ex&quot;&gt;1133e3acf0a4cbb9d8b3bfd3f227731b8cd2650b&lt;/span&gt;  -&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb8-3&quot; title=&quot;3&quot;&gt;$ &lt;span class=&quot;bu&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;message&amp;#39;&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;ex&quot;&gt;sha1sum&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb8-4&quot; title=&quot;4&quot;&gt;&lt;span class=&quot;ex&quot;&gt;1133e3acf0a4cbb9d8b3bfd3f227731b8cd2650b&lt;/span&gt;  -&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb8-5&quot; title=&quot;5&quot;&gt;$ &lt;span class=&quot;bu&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;message1&amp;#39;&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;ex&quot;&gt;sha1sum&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb8-6&quot; title=&quot;6&quot;&gt;&lt;span class=&quot;ex&quot;&gt;c133514a60a4641b83b365d3dc7b715dc954e010&lt;/span&gt;  -&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note the big change in the output of &lt;code&gt;sha1sum&lt;/code&gt; from a tiny change in input. This is what cryptographic hash functions do.&lt;/p&gt;
&lt;/section&gt;
&lt;section id=&quot;hash-that-dag&quot; class=&quot;level2&quot;&gt;
&lt;h2&gt;Hash that DAG! &lt;a href=&quot;https://tylercipriani.com/tags/javascript/#hash-that-dag&quot;&gt;¶&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now that we have some idea of what is inside a commit object, let’s reverse-engineer the commit object from the &lt;code&gt;HEAD&lt;/code&gt; of our &lt;code&gt;merkle&lt;/code&gt; repo:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb9&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-1&quot; title=&quot;1&quot;&gt;$  &lt;span class=&quot;ex&quot;&gt;python2&lt;/span&gt; -c &lt;span class=&quot;st&quot;&gt;&amp;#39;import sys,zlib; \&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-2&quot; title=&quot;2&quot;&gt;&lt;span class=&quot;st&quot;&gt;print zlib.decompress(sys.stdin.read());&amp;#39;&lt;/span&gt; \&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-3&quot; title=&quot;3&quot;&gt;&lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt; .git/objects/1a/06ce381ac14f7a5baa1670691c2ff8a73aa6da &lt;span class=&quot;kw&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;\&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-4&quot; title=&quot;4&quot;&gt;&lt;span class=&quot;fu&quot;&gt;od&lt;/span&gt; -c&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-5&quot; title=&quot;5&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000000&lt;/span&gt;   c   o   m   m   i   t       1   9   5  \0   t   r   e   e    &lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-6&quot; title=&quot;6&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000020&lt;/span&gt;   0   9   8   e   6   d   e   2   9   d   a   f   4   e   5   5&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-7&quot; title=&quot;7&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000040&lt;/span&gt;   f   8   3   4   0   6   b   4   9   f   5   7   6   8   d   f&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-8&quot; title=&quot;8&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000060&lt;/span&gt;   9   b   c   7   d   6   2   4  \n   a   u   t   h   o   r    &lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-9&quot; title=&quot;9&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000100&lt;/span&gt;   T   y   l   e   r       C   i   p   r   i   a   n   i       &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-10&quot; title=&quot;10&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000120&lt;/span&gt;   t   c   i   p   r   i   a   n   i   @   w   i   k   i   m   e&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-11&quot; title=&quot;11&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000140&lt;/span&gt;   d   i   a   .   o   r   g   &lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt;       1   4   5   8   6   0   4&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-12&quot; title=&quot;12&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000160&lt;/span&gt;   1   2   0       -   0   7   0   0  \n   c   o   m   m   i   t&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-13&quot; title=&quot;13&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000200&lt;/span&gt;   t   e   r       T   y   l   e   r       C   i   p   r   i   a&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-14&quot; title=&quot;14&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000220&lt;/span&gt;   n   i       &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt;   t   c   i   p   r   i   a   n   i   @   w   i&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-15&quot; title=&quot;15&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000240&lt;/span&gt;   k   i   m   e   d   i   a   .   o   r   g   &lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt;       1   4   5&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-16&quot; title=&quot;16&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000260&lt;/span&gt;   8   6   0   4   1   2   0       -   0   7   0   0  \n  \n   I&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-17&quot; title=&quot;17&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000300&lt;/span&gt;   n   i   t   i   a   l       C   o   m   m   i   t  \n  \n&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb9-18&quot; title=&quot;18&quot;&gt; &lt;span class=&quot;ex&quot;&gt;0000317&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb10&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb10-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;bu&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;tree 098e6de29daf4e55f83406b49f5768df9bc7d62k4\n&amp;#39;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; commit-msg&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb10-2&quot; title=&quot;2&quot;&gt;$ &lt;span class=&quot;bu&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;author Tyler Cipriani &amp;lt;tcipriani@wikimedia.org&amp;gt; 1458604120 -0700\n&amp;#39;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; commit-msg&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb10-3&quot; title=&quot;3&quot;&gt;$ &lt;span class=&quot;bu&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;committer Tyler Cipriani &amp;lt;tcipriani@wikimedia.org&amp;gt; 1458604120 -0700\n&amp;#39;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; commit-msg&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb10-4&quot; title=&quot;4&quot;&gt;$ &lt;span class=&quot;bu&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;\nInitial Commit\n&amp;#39;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; commit-msg&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb11&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb11-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;ex&quot;&gt;sha1sum&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;fu&quot;&gt;cat&lt;/span&gt; \&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb11-2&quot; title=&quot;2&quot;&gt;    &lt;span class=&quot;op&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;bu&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;quot;commit &amp;quot;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;)&lt;/span&gt; \&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb11-3&quot; title=&quot;3&quot;&gt;    &lt;span class=&quot;op&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;fu&quot;&gt;wc&lt;/span&gt; -c &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt; commit-msg &lt;span class=&quot;kw&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;tr&lt;/span&gt; -d &lt;span class=&quot;st&quot;&gt;&amp;#39;\n&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;)&lt;/span&gt; \&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb11-4&quot; title=&quot;4&quot;&gt;    &lt;span class=&quot;op&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;bu&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;%b&amp;#39;&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;\0&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;)&lt;/span&gt; commit-msg&lt;span class=&quot;op&quot;&gt;)&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb11-5&quot; title=&quot;5&quot;&gt;&lt;span class=&quot;ex&quot;&gt;1a06ce381ac14f7a5baa1670691c2ff8a73aa6da&lt;/span&gt;  /dev/fd/63&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Hmm… that seems familiar&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb12&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb12-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;bu&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;COMMIT_HASH=$(&lt;/span&gt;&lt;span class=&quot;ex&quot;&gt;sha1sum&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;fu&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;bu&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;quot;commit &amp;quot;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;fu&quot;&gt;wc&lt;/span&gt; -c &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt; commit-msg &lt;span class=&quot;kw&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;tr&lt;/span&gt; -d &lt;span class=&quot;st&quot;&gt;&amp;#39;\n&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;bu&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;%b&amp;#39;&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;\0&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;)&lt;/span&gt; commit-msg&lt;span class=&quot;op&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;cut&lt;/span&gt; -d&lt;span class=&quot;st&quot;&gt;&amp;#39; &amp;#39;&lt;/span&gt; -f1&lt;span class=&quot;va&quot;&gt;)&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb12-2&quot; title=&quot;2&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;find&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;quot;.git/objects/&lt;/span&gt;&lt;span class=&quot;va&quot;&gt;${COMMIT_HASH:0:2}&lt;/span&gt;&lt;span class=&quot;st&quot;&gt;&amp;quot;&lt;/span&gt; -type f -name &lt;span class=&quot;st&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;va&quot;&gt;${COMMIT_HASH:&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;(-38)&lt;/span&gt;&lt;span class=&quot;va&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;st&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb12-3&quot; title=&quot;3&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/1a/06ce381ac14f7a5baa1670691c2ff8a73aa6da&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The commit object is a zlib-compressed, formatted message that is stored in a file named after the SHA-1 hash of the file’s un-&lt;code&gt;zlib&lt;/code&gt; compressed contents.&lt;/p&gt;
&lt;p&gt;(/me wipes brow)&lt;/p&gt;
&lt;p&gt;Let’s use &lt;code&gt;git-cat-file&lt;/code&gt; to see if we can explore the &lt;code&gt;tree 098e6de29daf4e55f83406b49f5768df9bc7d62k4&lt;/code&gt;-part of the commit message object:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb13&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb13-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;cat&lt;/span&gt; .git/HEAD&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb13-2&quot; title=&quot;2&quot;&gt;&lt;span class=&quot;ex&quot;&gt;ref&lt;/span&gt;: refs/heads/master&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb14&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb14-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;cat&lt;/span&gt; .git/refs/heads/master&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb14-2&quot; title=&quot;2&quot;&gt;&lt;span class=&quot;ex&quot;&gt;1a06ce381ac14f7a5baa1670691c2ff8a73aa6da&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb15&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb15-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;git&lt;/span&gt; cat-file -p 1a06ce381ac14f7a5baa1670691c2ff8a73aa6da&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb15-2&quot; title=&quot;2&quot;&gt;&lt;span class=&quot;ex&quot;&gt;tree&lt;/span&gt; 098e6de29daf4e55f83406b49f5768df9bc7d624&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb15-3&quot; title=&quot;3&quot;&gt;&lt;span class=&quot;ex&quot;&gt;author&lt;/span&gt; Tyler Cipriani &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt;tcipriani@wikimedia.org&lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; 1458604120 -0700&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb15-4&quot; title=&quot;4&quot;&gt;&lt;span class=&quot;ex&quot;&gt;committer&lt;/span&gt; Tyler Cipriani &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt;tcipriani@wikimedia.org&lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; 1458604120 -0700&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb16&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb16-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;git&lt;/span&gt; cat-file -p 098e6de29daf4e55f83406b49f5768df9bc7d624&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb16-2&quot; title=&quot;2&quot;&gt;&lt;span class=&quot;ex&quot;&gt;100644&lt;/span&gt; blob 1b9f426a8407ffee551ad2993c5d7d3780296353    README&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb17&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb17-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;git&lt;/span&gt; cat-file -p 1b9f426a8407ffee551ad2993c5d7d3780296353&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb17-2&quot; title=&quot;2&quot;&gt;&lt;span class=&quot;ex&quot;&gt;This&lt;/span&gt; is the beginning&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Hey that’s the text I put into &lt;code&gt;README&lt;/code&gt;!&lt;/p&gt;
&lt;p&gt;So &lt;code&gt;.git/HEAD&lt;/code&gt; refers to &lt;code&gt;.git/refs/heads/master&lt;/code&gt;, calling &lt;code&gt;git-cat-file&lt;/code&gt; on the object found inside that file shows that it’s the commit object we recreated. The commit object points to &lt;code&gt;098e6de29daf4e55f83406b49f5768df9bc7d624&lt;/code&gt;, which is a tree object with the contents: &lt;code&gt;100644 blob 1b9f426a8407ffee551ad2993c5d7d3780296353    README&lt;/code&gt; The &lt;code&gt;blob&lt;/code&gt; object &lt;code&gt;1b9f426a8407ffee551ad2993c5d7d3780296353&lt;/code&gt; is the contents of &lt;code&gt;README&lt;/code&gt;! So it seems each &lt;code&gt;commit&lt;/code&gt; object points to a &lt;code&gt;tree&lt;/code&gt; object that points to other objects.&lt;/p&gt;
&lt;/section&gt;
&lt;section id=&quot;what-was-i-talking-about-merkle-dags-d3.js&quot; class=&quot;level2&quot;&gt;
&lt;h2&gt;What was I talking about? Merkle DAGs? D3.js? &lt;a href=&quot;https://tylercipriani.com/tags/javascript/#what-was-i-talking-about-merkle-dags-d3.js&quot;&gt;¶&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Let’s see if we can paste together what Git is doing at a low-level when we make a new commit:&lt;/p&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;Take the contents of &lt;code&gt;README&lt;/code&gt;, hash the contents using SHA-1, and store as a &lt;code&gt;blob&lt;/code&gt; object in &lt;code&gt;.git/objects&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Create a directory listing of the git working directory, listing each file, with its directory permissions and its hash value. Hash this directory listing and store as a &lt;code&gt;tree&lt;/code&gt; in &lt;code&gt;.git/objects&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Take the commit message, along with info from &lt;code&gt;.gitconfig&lt;/code&gt; and the hash of the top-level tree. Hash this information and store it as a &lt;code&gt;commit&lt;/code&gt; object in &lt;code&gt;.git/objects&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It seems that there may be a chain of dependencies:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb18&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb18-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; gitDag &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb18-2&quot; title=&quot;2&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// blob (add .b for blob)&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb18-3&quot; title=&quot;3&quot;&gt;    &lt;span class=&quot;st&quot;&gt;&amp;#39;1b9f426a8407ffee551ad2993c5d7d3780296353.b&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; []&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb18-4&quot; title=&quot;4&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// tree (.t == tree) is a hash that includes the hash from blob&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb18-5&quot; title=&quot;5&quot;&gt;    &lt;span class=&quot;st&quot;&gt;&amp;#39;098e6de29daf4e55f83406b49f5768df9bc7d624.t&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; [&lt;span class=&quot;st&quot;&gt;&amp;#39;1b9f426a8407ffee551ad2993c5d7d3780296353.b&amp;#39;&lt;/span&gt;]&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb18-6&quot; title=&quot;6&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// commit (.c == commit) is a hash that includes the hash from tree&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb18-7&quot; title=&quot;7&quot;&gt;    &lt;span class=&quot;st&quot;&gt;&amp;#39;1a06ce381ac14f7a5baa1670691c2ff8a73aa6da.c&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; [&lt;span class=&quot;st&quot;&gt;&amp;#39;098e6de29daf4e55f83406b49f5768df9bc7d624.t&amp;#39;&lt;/span&gt;]&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb18-8&quot; title=&quot;8&quot;&gt;&lt;span class=&quot;op&quot;&gt;};&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb18-9&quot; title=&quot;9&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb18-10&quot; title=&quot;10&quot;&gt;&lt;span class=&quot;at&quot;&gt;makeGraph&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;.merkle-2&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;at&quot;&gt;forceFormat&lt;/span&gt;(gitDag))&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;merkle-2&quot;&gt;

&lt;/div&gt;
&lt;p&gt;You’d be forgiven for thinking that is a line.&lt;/p&gt;
&lt;p&gt;What’s really happening is that there is a &lt;code&gt;commit&lt;/code&gt; object (&lt;code&gt;1a06ce38&lt;/code&gt;) that depends on a &lt;code&gt;tree&lt;/code&gt; object (&lt;code&gt;098e6de2&lt;/code&gt;) that depends on a &lt;code&gt;blob&lt;/code&gt; (&lt;code&gt;1b9f426a&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Since it’s running each of these objects through a hash function and each of them contains a reference up the chain of dependencies, a minor change to either the &lt;code&gt;blob&lt;/code&gt; or the &lt;code&gt;tree&lt;/code&gt; will create a drastically different &lt;code&gt;commit&lt;/code&gt; object.&lt;/p&gt;
&lt;p&gt;Applying a cryptographic hash function on top of a graph was &lt;a href=&quot;https://en.wikipedia.org/wiki/Ralph_Merkle&quot;&gt;Ralph Merkle&lt;/a&gt;’s big idea. This scheme makes magic possible. Transferring verifiable and trusted information through an untrusted medium is toatz for realz possible with Ralph’s little scheme.&lt;/p&gt;
&lt;p&gt;The idea is that if you have the &lt;em&gt;root-node hash&lt;/em&gt;, that is, the cryptographic hash of the node that depends on all other nodes (the &lt;code&gt;commit&lt;/code&gt; object in Git), and you obtained that root-node hash from a trusted source, you can trust all sub-nodes that stem from that root node &lt;em&gt;if&lt;/em&gt; the hash of all those sub-root-nodes matches the root-node hash!&lt;/p&gt;
&lt;p&gt;This is the mechanism by which things like Git, &lt;a href=&quot;https://github.com/ipfs/specs/blob/master/protocol/README.md#1-ipfs-and-the-merkle-dag&quot;&gt;IPFS&lt;/a&gt;, &lt;a href=&quot;http://chimera.labs.oreilly.com/books/1234000001802/ch07.html#merkle_trees&quot;&gt;Bitcoin&lt;/a&gt;, and &lt;a href=&quot;http://bittorrent.org/beps/bep_0030.html&quot;&gt;BitTorrent&lt;/a&gt; are made possible: changing any one node in the graph changes all nodes that depend on that node all the way to the root-node (the &lt;code&gt;commit&lt;/code&gt; in Git).&lt;/p&gt;
&lt;/section&gt;
&lt;section id=&quot;tales-from-the-merkle-graph&quot; class=&quot;level2&quot;&gt;
&lt;h2&gt;Tales from the Merkle Graph &lt;a href=&quot;https://tylercipriani.com/tags/javascript/#tales-from-the-merkle-graph&quot;&gt;¶&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I wrote a simple NodeJS script that creates a graph that is suitable for input into the JavaScript that I’ve already written that will create a D3.js force graph with whatever it finds in &lt;code&gt;.git/objects&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb19&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;co&quot;&gt;#!/usr/bin/env nodejs&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-2&quot; title=&quot;2&quot;&gt;&lt;span class=&quot;co&quot;&gt;/* makeDag - creates a JSON dependency graph from .git/objects */&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-3&quot; title=&quot;3&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-4&quot; title=&quot;4&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; glob &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;at&quot;&gt;require&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;glob&amp;#39;&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-5&quot; title=&quot;5&quot;&gt;    fs &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;at&quot;&gt;require&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;fs&amp;#39;&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-6&quot; title=&quot;6&quot;&gt;    zlib &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;at&quot;&gt;require&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;zlib&amp;#39;&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-7&quot; title=&quot;7&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-8&quot; title=&quot;8&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; types &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; [&lt;span class=&quot;st&quot;&gt;&amp;#39;tree&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;commit&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;blob&amp;#39;&lt;/span&gt;]&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-9&quot; title=&quot;9&quot;&gt;    treeRegex &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-10&quot; title=&quot;10&quot;&gt;        &lt;span class=&quot;co&quot;&gt;// 100644 README\0[20 byte sha1]&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-11&quot; title=&quot;11&quot;&gt;        &lt;span class=&quot;dt&quot;&gt;regex&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;[0-9]+\s[^\0]+\0((&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;|\n){20})&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;/gm&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-12&quot; title=&quot;12&quot;&gt;        &lt;span class=&quot;dt&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(sha) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-13&quot; title=&quot;13&quot;&gt;            &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; buf &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;at&quot;&gt;Buffer&lt;/span&gt;(sha[&lt;span class=&quot;dv&quot;&gt;1&lt;/span&gt;]&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;binary&amp;#39;&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-14&quot; title=&quot;14&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;buf&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;toString&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;hex&amp;#39;&lt;/span&gt;) &lt;span class=&quot;op&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;.b&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-15&quot; title=&quot;15&quot;&gt;        &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-16&quot; title=&quot;16&quot;&gt;    &lt;span class=&quot;op&quot;&gt;},&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-17&quot; title=&quot;17&quot;&gt;    commitRegex &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-18&quot; title=&quot;18&quot;&gt;        &lt;span class=&quot;co&quot;&gt;// tree 098e6de29daf4e55f83406b49f5768df9bc7d624&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-19&quot; title=&quot;19&quot;&gt;        &lt;span class=&quot;dt&quot;&gt;regex&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;tree&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;parent&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;)\s([a-f0-9]{40})&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;/gm&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-20&quot; title=&quot;20&quot;&gt;        &lt;span class=&quot;dt&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(sha) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-21&quot; title=&quot;21&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (sha[&lt;span class=&quot;dv&quot;&gt;1&lt;/span&gt;] &lt;span class=&quot;op&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;tree&amp;#39;&lt;/span&gt;) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-22&quot; title=&quot;22&quot;&gt;                &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; sha[&lt;span class=&quot;dv&quot;&gt;2&lt;/span&gt;] &lt;span class=&quot;op&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;.t&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-23&quot; title=&quot;23&quot;&gt;            &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-24&quot; title=&quot;24&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; sha[&lt;span class=&quot;dv&quot;&gt;2&lt;/span&gt;] &lt;span class=&quot;op&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;.c&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-25&quot; title=&quot;25&quot;&gt;        &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-26&quot; title=&quot;26&quot;&gt;    &lt;span class=&quot;op&quot;&gt;},&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-27&quot; title=&quot;27&quot;&gt;    total &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-28&quot; title=&quot;28&quot;&gt;    final &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;{};&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-29&quot; title=&quot;29&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-30&quot; title=&quot;30&quot;&gt;&lt;span class=&quot;co&quot;&gt;// determine file type, parse out SHA1s&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-31&quot; title=&quot;31&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; handleObjects &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(objData&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; name) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-32&quot; title=&quot;32&quot;&gt;    &lt;span class=&quot;va&quot;&gt;types&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;forEach&lt;/span&gt;(&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(type) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-33&quot; title=&quot;33&quot;&gt;        &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; re&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; regex&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; match&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; key&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-34&quot; title=&quot;34&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-35&quot; title=&quot;35&quot;&gt;        &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;op&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;va&quot;&gt;objData&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;startsWith&lt;/span&gt;(type)) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-36&quot; title=&quot;36&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-37&quot; title=&quot;37&quot;&gt;        key &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; name &lt;span class=&quot;op&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;.&amp;#39;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;+&lt;/span&gt; type[&lt;span class=&quot;dv&quot;&gt;0&lt;/span&gt;]&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-38&quot; title=&quot;38&quot;&gt;        final[key] &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; []&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-39&quot; title=&quot;39&quot;&gt;        &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (type &lt;span class=&quot;op&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;tree&amp;#39;&lt;/span&gt;) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; objType &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; treeRegex&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-40&quot; title=&quot;40&quot;&gt;        &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (type &lt;span class=&quot;op&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;commit&amp;#39;&lt;/span&gt;) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; objType &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; commitRegex&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-41&quot; title=&quot;41&quot;&gt;        &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (type &lt;span class=&quot;op&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;blob&amp;#39;&lt;/span&gt;) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-42&quot; title=&quot;42&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-43&quot; title=&quot;43&quot;&gt;        &lt;span class=&quot;co&quot;&gt;// Remove the object-type and size from file&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-44&quot; title=&quot;44&quot;&gt;        objData &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;objData&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;split&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;\0&lt;/span&gt;&lt;span class=&quot;st&quot;&gt;&amp;#39;&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-45&quot; title=&quot;45&quot;&gt;        &lt;span class=&quot;va&quot;&gt;objData&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;shift&lt;/span&gt;()&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-46&quot; title=&quot;46&quot;&gt;        objData &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;objData&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;join&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;\0&lt;/span&gt;&lt;span class=&quot;st&quot;&gt;&amp;#39;&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-47&quot; title=&quot;47&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-48&quot; title=&quot;48&quot;&gt;        &lt;span class=&quot;co&quot;&gt;// Recursive regex match remainder&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-49&quot; title=&quot;49&quot;&gt;        &lt;span class=&quot;cf&quot;&gt;while&lt;/span&gt; ((match &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;objType&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;regex&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;exec&lt;/span&gt;(objData)) &lt;span class=&quot;op&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;null&lt;/span&gt;) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-50&quot; title=&quot;50&quot;&gt;            final[key].&lt;span class=&quot;at&quot;&gt;push&lt;/span&gt;(&lt;span class=&quot;va&quot;&gt;objType&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;fn&lt;/span&gt;(match))&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-51&quot; title=&quot;51&quot;&gt;        &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-52&quot; title=&quot;52&quot;&gt;    &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-53&quot; title=&quot;53&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-54&quot; title=&quot;54&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// Don&amp;#39;t output until you&amp;#39;ve got it all&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-55&quot; title=&quot;55&quot;&gt;    &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;va&quot;&gt;Object&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;keys&lt;/span&gt;(final).&lt;span class=&quot;at&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;!==&lt;/span&gt; total) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-56&quot; title=&quot;56&quot;&gt;        &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-57&quot; title=&quot;57&quot;&gt;    &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-58&quot; title=&quot;58&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-59&quot; title=&quot;59&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// Output what ya got.&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-60&quot; title=&quot;60&quot;&gt;    &lt;span class=&quot;va&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;log&lt;/span&gt;(final)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-61&quot; title=&quot;61&quot;&gt;&lt;span class=&quot;op&quot;&gt;};&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-62&quot; title=&quot;62&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-63&quot; title=&quot;63&quot;&gt;&lt;span class=&quot;co&quot;&gt;// Readable object names not file names&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-64&quot; title=&quot;64&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; getName &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(file) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-65&quot; title=&quot;65&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; fileParts &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;file&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;split&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;/&amp;#39;&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-66&quot; title=&quot;66&quot;&gt;        len &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;fileParts&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-67&quot; title=&quot;67&quot;&gt;    &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; fileParts[len &lt;span class=&quot;op&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;2&lt;/span&gt;] &lt;span class=&quot;op&quot;&gt;+&lt;/span&gt; fileParts[len &lt;span class=&quot;op&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;1&lt;/span&gt;]&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-68&quot; title=&quot;68&quot;&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-69&quot; title=&quot;69&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-70&quot; title=&quot;70&quot;&gt;&lt;span class=&quot;co&quot;&gt;// Inflate the deflated git object file&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-71&quot; title=&quot;71&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; handleFile &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(file&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; out) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-72&quot; title=&quot;72&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; name &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;at&quot;&gt;getName&lt;/span&gt;(file)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-73&quot; title=&quot;73&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-74&quot; title=&quot;74&quot;&gt;    &lt;span class=&quot;va&quot;&gt;fs&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;readFile&lt;/span&gt;(file&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(e&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; data) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-75&quot; title=&quot;75&quot;&gt;        &lt;span class=&quot;va&quot;&gt;zlib&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;inflate&lt;/span&gt;(data&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(e&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; data) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-76&quot; title=&quot;76&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (e) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;log&lt;/span&gt;(file&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; e)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-77&quot; title=&quot;77&quot;&gt;            &lt;span class=&quot;at&quot;&gt;handleObjects&lt;/span&gt;(&lt;span class=&quot;va&quot;&gt;data&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;toString&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;binary&amp;#39;&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; name)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-78&quot; title=&quot;78&quot;&gt;        &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-79&quot; title=&quot;79&quot;&gt;    &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-80&quot; title=&quot;80&quot;&gt;&lt;span class=&quot;op&quot;&gt;};&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-81&quot; title=&quot;81&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-82&quot; title=&quot;82&quot;&gt;&lt;span class=&quot;co&quot;&gt;// Sort through the gitobjects directory&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-83&quot; title=&quot;83&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; handleFiles &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(files) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-84&quot; title=&quot;84&quot;&gt;    &lt;span class=&quot;va&quot;&gt;files&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;forEach&lt;/span&gt;(&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(file) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-85&quot; title=&quot;85&quot;&gt;        &lt;span class=&quot;va&quot;&gt;fs&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;stat&lt;/span&gt;(file&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(e&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; f) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-86&quot; title=&quot;86&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (e) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-87&quot; title=&quot;87&quot;&gt;            &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;va&quot;&gt;f&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;isFile&lt;/span&gt;()) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-88&quot; title=&quot;88&quot;&gt;                &lt;span class=&quot;co&quot;&gt;// Don&amp;#39;t worry about pack files for now&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-89&quot; title=&quot;89&quot;&gt;                &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;va&quot;&gt;file&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;indexOf&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;pack&amp;#39;&lt;/span&gt;) &lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;-1&lt;/span&gt;) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-90&quot; title=&quot;90&quot;&gt;                total&lt;span class=&quot;op&quot;&gt;++;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-91&quot; title=&quot;91&quot;&gt;                &lt;span class=&quot;at&quot;&gt;handleFile&lt;/span&gt;(file)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-92&quot; title=&quot;92&quot;&gt;            &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-93&quot; title=&quot;93&quot;&gt;        &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-94&quot; title=&quot;94&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-95&quot; title=&quot;95&quot;&gt;    &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-96&quot; title=&quot;96&quot;&gt;&lt;span class=&quot;op&quot;&gt;};&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-97&quot; title=&quot;97&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-98&quot; title=&quot;98&quot;&gt;(&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;() &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-99&quot; title=&quot;99&quot;&gt;    &lt;span class=&quot;at&quot;&gt;glob&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;.git/objects/**/*&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(e&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; f) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-100&quot; title=&quot;100&quot;&gt;        &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (e) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cf&quot;&gt;throw&lt;/span&gt; e&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-101&quot; title=&quot;101&quot;&gt;        &lt;span class=&quot;at&quot;&gt;handleFiles&lt;/span&gt;(f)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-102&quot; title=&quot;102&quot;&gt;    &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb19-103&quot; title=&quot;103&quot;&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;)()&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Merkle graph transformations are often difficult to describe, but easy to see. Using this last piece of code to create and view graphs for several repositories has been illuminating. The graph visualization both illuminates and challenges my understanding of Git in ways I didn’t anticipate.&lt;/p&gt;
&lt;/section&gt;
&lt;section id=&quot;the-tale-of-commit-message-bike-shedding&quot; class=&quot;level2&quot;&gt;
&lt;h2&gt;The Tale of Commit Message Bike-shedding &lt;a href=&quot;https://tylercipriani.com/tags/javascript/#the-tale-of-commit-message-bike-shedding&quot;&gt;¶&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When you change your commit message, what happens to the graph? What depends on a commit? Where is the context for a commit?&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb20&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb20-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;git&lt;/span&gt; commit --amend -m &lt;span class=&quot;st&quot;&gt;&amp;#39;This is the commit message now&amp;#39;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb20-2&quot; title=&quot;2&quot;&gt;[&lt;span class=&quot;ex&quot;&gt;master&lt;/span&gt; 585448a] This is the commit message now&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb20-3&quot; title=&quot;3&quot;&gt; &lt;span class=&quot;ex&quot;&gt;Date&lt;/span&gt;: Mon Mar 21 16:48:40 2016 -0700&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb20-4&quot; title=&quot;4&quot;&gt;  &lt;span class=&quot;ex&quot;&gt;1&lt;/span&gt; file changed, 1 insertion(+)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb20-5&quot; title=&quot;5&quot;&gt;   &lt;span class=&quot;ex&quot;&gt;create&lt;/span&gt; mode 100644 README&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb20-6&quot; title=&quot;6&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;find&lt;/span&gt; .git/objects -type f&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb20-7&quot; title=&quot;7&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/1b/9f426a8407ffee551ad2993c5d7d3780296353&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb20-8&quot; title=&quot;8&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/09/8e6de29daf4e55f83406b49f5768df9bc7d624&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb20-9&quot; title=&quot;9&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/1a/06ce381ac14f7a5baa1670691c2ff8a73aa6da&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb20-10&quot; title=&quot;10&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/da/94af3a21ac7e0c875bbbe6162aa1d26d699c73&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now the DAG is a bit different:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb21&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb21-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; gitDag &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;098e6de29daf4e55f83406b49f5768df9bc7d624.t&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; [ &lt;span class=&quot;st&quot;&gt;&amp;#39;1b9f426a8407ffee551ad2993c5d7d3780296353.b&amp;#39;&lt;/span&gt; ]&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb21-2&quot; title=&quot;2&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;1a06ce381ac14f7a5baa1670691c2ff8a73aa6da.c&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; [ &lt;span class=&quot;st&quot;&gt;&amp;#39;098e6de29daf4e55f83406b49f5768df9bc7d624.t&amp;#39;&lt;/span&gt; ]&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb21-3&quot; title=&quot;3&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;1b9f426a8407ffee551ad2993c5d7d3780296353.b&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; []&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb21-4&quot; title=&quot;4&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;da94af3a21ac7e0c875bbbe6162aa1d26d699c73.c&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; [ &lt;span class=&quot;st&quot;&gt;&amp;#39;098e6de29daf4e55f83406b49f5768df9bc7d624.t&amp;#39;&lt;/span&gt; ] &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb21-5&quot; title=&quot;5&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb21-6&quot; title=&quot;6&quot;&gt;&lt;span class=&quot;at&quot;&gt;makeGraph&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;.merkle-3&amp;#39;&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;at&quot;&gt;forceFormat&lt;/span&gt;(gitDag))&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;merkle-3&quot;&gt;

&lt;/div&gt;
&lt;p&gt;Here we see that there are now two &lt;code&gt;commit&lt;/code&gt; objects (&lt;code&gt;1a06ce38&lt;/code&gt; and &lt;code&gt;da94af3a&lt;/code&gt;) that both depend on a single &lt;code&gt;tree&lt;/code&gt; object (&lt;code&gt;098e6de2&lt;/code&gt;) that depends on a single &lt;code&gt;blob&lt;/code&gt; (&lt;code&gt;1b9f426a&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;One of these commit objects will never be seen with &lt;code&gt;git log&lt;/code&gt;.&lt;/p&gt;
&lt;/section&gt;
&lt;section id=&quot;the-orphan-blob-that-dared-to-dream&quot; class=&quot;level2&quot;&gt;
&lt;h2&gt;The Orphan Blob That Dared to Dream &lt;a href=&quot;https://tylercipriani.com/tags/javascript/#the-orphan-blob-that-dared-to-dream&quot;&gt;¶&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;TIL: Git creates &lt;code&gt;blob&lt;/code&gt; objects as soon as a file is added to the staging area.&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb22&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb22-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;bu&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;staged&amp;#39;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; staged&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb22-2&quot; title=&quot;2&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;find&lt;/span&gt; .git/objects -type f&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb22-3&quot; title=&quot;3&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/1b/9f426a8407ffee551ad2993c5d7d3780296353&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb22-4&quot; title=&quot;4&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/09/8e6de29daf4e55f83406b49f5768df9bc7d624&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb22-5&quot; title=&quot;5&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/1a/06ce381ac14f7a5baa1670691c2ff8a73aa6da&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb22-6&quot; title=&quot;6&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/da/94af3a21ac7e0c875bbbe6162aa1d26d699c73&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Notice that nothing depends on this object just yet. It’s a lonely orphan &lt;code&gt;blob&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb23&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;git&lt;/span&gt; add staged&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-2&quot; title=&quot;2&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;find&lt;/span&gt; .git/objects -type f&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-3&quot; title=&quot;3&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/1b/9f426a8407ffee551ad2993c5d7d3780296353&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-4&quot; title=&quot;4&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/09/8e6de29daf4e55f83406b49f5768df9bc7d624&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-5&quot; title=&quot;5&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/1a/06ce381ac14f7a5baa1670691c2ff8a73aa6da&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-6&quot; title=&quot;6&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/da/94af3a21ac7e0c875bbbe6162aa1d26d699c73&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-7&quot; title=&quot;7&quot;&gt;&lt;span class=&quot;ex&quot;&gt;.git/objects/19/d9cc8584ac2c7dcf57d2680375e80f099dc481&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-8&quot; title=&quot;8&quot;&gt;$ &lt;span class=&quot;ex&quot;&gt;makeDag&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-9&quot; title=&quot;9&quot;&gt;&lt;span class=&quot;kw&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;098e6de29daf4e55f83406b49f5768df9bc7d624.t&amp;#39;&lt;/span&gt;:&lt;span class=&quot;bu&quot;&gt; [&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;1b9f426a8407ffee551ad2993c5d7d3780296353.b&amp;#39;&lt;/span&gt; ],&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-10&quot; title=&quot;10&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;19d9cc8584ac2c7dcf57d2680375e80f099dc481.b&amp;#39;&lt;/span&gt;: [],&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-11&quot; title=&quot;11&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;1a06ce381ac14f7a5baa1670691c2ff8a73aa6da.c&amp;#39;&lt;/span&gt;: [ &lt;span class=&quot;st&quot;&gt;&amp;#39;098e6de29daf4e55f83406b49f5768df9bc7d624.t&amp;#39;&lt;/span&gt; ],&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-12&quot; title=&quot;12&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;da94af3a21ac7e0c875bbbe6162aa1d26d699c73.c&amp;#39;&lt;/span&gt;: [ &lt;span class=&quot;st&quot;&gt;&amp;#39;098e6de29daf4e55f83406b49f5768df9bc7d624.t&amp;#39;&lt;/span&gt; ],&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb23-13&quot; title=&quot;13&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;1b9f426a8407ffee551ad2993c5d7d3780296353.b&amp;#39;&lt;/span&gt;: [] }&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;merkle-4&quot;&gt;

&lt;/div&gt;
&lt;p&gt;Even unstaging and deleting the file doesn’t remove the object. Orphan objects in git are only garbage collected as part of &lt;code&gt;git gc --prune&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;When this object is committed to the repo, it creates a whole new layer of the graph:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb24&quot;&gt;&lt;pre class=&quot;sourceCode bash&quot;&gt;&lt;code class=&quot;sourceCode bash&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-1&quot; title=&quot;1&quot;&gt;$ &lt;span class=&quot;fu&quot;&gt;git&lt;/span&gt; commit -m &lt;span class=&quot;st&quot;&gt;&amp;#39;Add staged file&amp;#39;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-2&quot; title=&quot;2&quot;&gt;[&lt;span class=&quot;ex&quot;&gt;master&lt;/span&gt; 4f407b3] Add staged file&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-3&quot; title=&quot;3&quot;&gt; &lt;span class=&quot;ex&quot;&gt;1&lt;/span&gt; file changed, 1 insertion(+)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-4&quot; title=&quot;4&quot;&gt; &lt;span class=&quot;ex&quot;&gt;create&lt;/span&gt; mode 100644 staged&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-5&quot; title=&quot;5&quot;&gt;$ &lt;span class=&quot;ex&quot;&gt;makeDag&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-6&quot; title=&quot;6&quot;&gt;&lt;span class=&quot;kw&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;098e6de29daf4e55f83406b49f5768df9bc7d624.t&amp;#39;&lt;/span&gt;:&lt;span class=&quot;bu&quot;&gt; [&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;1b9f426a8407ffee551ad2993c5d7d3780296353.b&amp;#39;&lt;/span&gt; ],&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-7&quot; title=&quot;7&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;19d9cc8584ac2c7dcf57d2680375e80f099dc481.b&amp;#39;&lt;/span&gt;: [],&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-8&quot; title=&quot;8&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;1a06ce381ac14f7a5baa1670691c2ff8a73aa6da.c&amp;#39;&lt;/span&gt;: [ &lt;span class=&quot;st&quot;&gt;&amp;#39;098e6de29daf4e55f83406b49f5768df9bc7d624.t&amp;#39;&lt;/span&gt; ],&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-9&quot; title=&quot;9&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;1b9f426a8407ffee551ad2993c5d7d3780296353.b&amp;#39;&lt;/span&gt;: [],&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-10&quot; title=&quot;10&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;4f407b396e6ecbb65de6cf192259c18ecd4d1e9b.c&amp;#39;&lt;/span&gt;: &lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-11&quot; title=&quot;11&quot;&gt;   [ &lt;span class=&quot;st&quot;&gt;&amp;#39;7ce38101e91de29ee0fee3aa9940cc81159e0f8d.t&amp;#39;&lt;/span&gt;,&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-12&quot; title=&quot;12&quot;&gt;     &lt;span class=&quot;st&quot;&gt;&amp;#39;da94af3a21ac7e0c875bbbe6162aa1d26d699c73.c&amp;#39;&lt;/span&gt; ],&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-13&quot; title=&quot;13&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;7ce38101e91de29ee0fee3aa9940cc81159e0f8d.t&amp;#39;&lt;/span&gt;: &lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-14&quot; title=&quot;14&quot;&gt;   [ &lt;span class=&quot;st&quot;&gt;&amp;#39;1b9f426a8407ffee551ad2993c5d7d3780296353.b&amp;#39;&lt;/span&gt;,&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-15&quot; title=&quot;15&quot;&gt;     &lt;span class=&quot;st&quot;&gt;&amp;#39;19d9cc8584ac2c7dcf57d2680375e80f099dc481.b&amp;#39;&lt;/span&gt; ],&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb24-16&quot; title=&quot;16&quot;&gt;  &lt;span class=&quot;st&quot;&gt;&amp;#39;da94af3a21ac7e0c875bbbe6162aa1d26d699c73.c&amp;#39;&lt;/span&gt;: [ &lt;span class=&quot;st&quot;&gt;&amp;#39;098e6de29daf4e55f83406b49f5768df9bc7d624.t&amp;#39;&lt;/span&gt;&lt;span class=&quot;bu&quot;&gt; ]&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;}&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;merkle-5&quot;&gt;

&lt;/div&gt;
&lt;p&gt;So we’ve created a new commit (&lt;code&gt;4f407b39&lt;/code&gt;) that is the parent of a different commit (&lt;code&gt;da94af3a&lt;/code&gt;) and a new tree (&lt;code&gt;7ce38101&lt;/code&gt;) that contains our old &lt;code&gt;README&lt;/code&gt; blob (&lt;code&gt;1b9f426a&lt;/code&gt;) and our new, previously orphaned, blob (&lt;code&gt;19d9cc85&lt;/code&gt;).&lt;/p&gt;
&lt;/section&gt;
&lt;section id=&quot;the-tale-of-powerful-software&quot; class=&quot;level2&quot;&gt;
&lt;h2&gt;The Tale of Powerful Software &lt;a href=&quot;https://tylercipriani.com/tags/javascript/#the-tale-of-powerful-software&quot;&gt;¶&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I’ve always enjoyed the idea that software (and computer science more generally) is nothing but an abstraction to manage complexity. Good software— powerful software—like Git—is a software that manages an incredible amount of complexity and hides it completely from the user.&lt;/p&gt;
&lt;p&gt;In recognition of this idea, I’ll leave you with the graph of my local copy of &lt;a href=&quot;https://github.com/thcipriani/clippy&quot;&gt;clippy&lt;/a&gt;—a small command line tool I created that is like &lt;code&gt;man(1)&lt;/code&gt; except it shows &lt;a href=&quot;https://en.wikipedia.org/wiki/Office_Assistant&quot;&gt;Clippy&lt;/a&gt; at the end of the &lt;code&gt;man&lt;/code&gt; output (yes, it’s dumb).&lt;/p&gt;
&lt;p&gt;This should give you an idea of the complexity that is abstracted by the Git merkle graph: this repo contains 5 commits!&lt;/p&gt;
&lt;div class=&quot;merkle-container&quot;&gt;
&lt;div class=&quot;merkle-6&quot;&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;/section&gt;

	</content>


	<link rel="comments" href="//tylercipriani.com/blog/2016/03/21/Visualizing-Git-Merkle-DAG-with-D3.js/#comments" type="text/html" />


	<link rel="comments" href="//tylercipriani.com/blog/2016/03/21/Visualizing-Git-Merkle-DAG-with-D3.js/comments.atom" type="application/atom+xml" />

</entry>
<entry>
	<title>Conway&#x2019;s Favicon</title>

	<id>https://tylercipriani.com/blog/2014/11/30/conways-game-of-life-favicon/</id>

	<link href="https://tylercipriani.com/blog/2014/11/30/conways-game-of-life-favicon/"/>

	<author><name>Tyler Cipriani</name></author>


	<rights type="html" xml:lang="en">

		&lt;a href=&quot;https://creativecommons.org/licenses/by-sa/4.0/&quot;&gt;Creative Commons Attribution-ShareAlike License&lt;/a&gt;
		Copyright © 2017 Tyler Cipriani

	</rights>



	<category term="computing" />

	<category term="javascript" />


	<updated>2017-07-01T00:49:09Z</updated>
	<published>2014-11-30T00:00:00Z</published>


	<content type="html" xml:lang="en">
	&lt;p&gt;I find favicons pretty useful overall. That weird little &lt;a href=&quot;https://bugs.r-project.org/bugzilla3/images/favicon.ico&quot;&gt;Earthworm-Jim-esque bug-head&lt;/a&gt; in my bookmarks bar immediately queues me in on where to click to get to bugzilla. My site hasn’t had a favicon. The only explanation I can offer is laziness mixed with a lack of inspiration. A favicon isn’t typically a glamorous undertaking—it’s just one of those things that ought to be done.&lt;/p&gt;
&lt;p&gt;My first idea for a favicon was Eric S. Raymond’s &lt;a href=&quot;http://www.catb.org/hacker-emblem/&quot;&gt;Hacker Emblem&lt;/a&gt;. The Hacker Emblem is certainly a meaningful symbol, but it’s also kind of a cop-out.&lt;/p&gt;
&lt;p&gt;I tried something with &lt;a href=&quot;https://tylercipriani.com/images/nyan-conway.png&quot;&gt;nyan cat and the hacker emblem&lt;/a&gt;, which was a solid idea, but sort of lost something at 16px×16px. Then I started to think, &lt;em&gt;why not just have Conway’s Game of Life running in the favicon&lt;/em&gt;?&lt;/p&gt;
&lt;section id=&quot;game-of-life-in-javascript&quot; class=&quot;level2&quot;&gt;
&lt;h2&gt;Game of Life in JavaScript &lt;a href=&quot;https://tylercipriani.com/tags/javascript/#game-of-life-in-javascript&quot;&gt;¶&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life&quot;&gt;Conway’s Game of Life&lt;/a&gt; is a zero player game with 4 simple rules (this is verbatim from the Wikipedia article):&lt;/p&gt;
&lt;blockquote&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;Any live cell with less than two live neighbours dies, as if caused by under-population.&lt;/li&gt;
&lt;li&gt;Any live cell with two or three live neighbours lives on to the next generation.&lt;/li&gt;
&lt;li&gt;Any live cell with more than three live neighbours dies, as if by overcrowding.&lt;/li&gt;
&lt;li&gt;Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/thcipriani/conways-favicon/blob/master/conways-favicon.js&quot;&gt;My game of life&lt;/a&gt; is heavily derived from an IBM DeveloperWorks post, &lt;a href=&quot;http://www.ibm.com/developerworks/library/wa-coffeescriptcanvas/&quot;&gt;&lt;em&gt;Conway’s Game of Life in CoffeeScript and canvas&lt;/em&gt;&lt;/a&gt;, except that I just used plain ol’ JavaScript, a much smaller grid, and I included some functionality to reset the game seed if the last two evolutions of life don’t change the grid layout.&lt;/p&gt;
&lt;/section&gt;
&lt;section id=&quot;dynamic-favicons&quot; class=&quot;level2&quot;&gt;
&lt;h2&gt;Dynamic Favicons &lt;a href=&quot;https://tylercipriani.com/tags/javascript/#dynamic-favicons&quot;&gt;¶&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;After creating the game loop in JavaScript, I had to create some code to dynamically update the favicon.&lt;/p&gt;
&lt;p&gt;First, I created the &lt;a href=&quot;https://tylercipriani.com/favicon.ico&quot;&gt;default favicon&lt;/a&gt; for this site by rendering out a glider via JavaScript and rendering the canvas as a png on the page.&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb1&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;va&quot;&gt;GameOfLife&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;prototype&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;glider&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; [&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-2&quot; title=&quot;2&quot;&gt;  &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;dt&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dt&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-3&quot; title=&quot;3&quot;&gt; &lt;span class=&quot;op&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;dt&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dt&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-4&quot; title=&quot;4&quot;&gt; &lt;span class=&quot;op&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;dt&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dt&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-5&quot; title=&quot;5&quot;&gt; &lt;span class=&quot;op&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;dt&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dt&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-6&quot; title=&quot;6&quot;&gt; &lt;span class=&quot;op&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;dt&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dt&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-7&quot; title=&quot;7&quot;&gt;]&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-8&quot; title=&quot;8&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-9&quot; title=&quot;9&quot;&gt;&lt;span class=&quot;co&quot;&gt;/* ... */&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-10&quot; title=&quot;10&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-11&quot; title=&quot;11&quot;&gt;&lt;span class=&quot;co&quot;&gt;/**&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-12&quot; title=&quot;12&quot;&gt;&lt;span class=&quot;co&quot;&gt; * Seed with default of glider&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-13&quot; title=&quot;13&quot;&gt;&lt;span class=&quot;co&quot;&gt; */&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-14&quot; title=&quot;14&quot;&gt;&lt;span class=&quot;va&quot;&gt;GameOfLife&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;prototype&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;seed&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;() &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-15&quot; title=&quot;15&quot;&gt;  &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; i&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; j&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; rowLen&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; colLen&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; row&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; col&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; gliderLen&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-16&quot; title=&quot;16&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-17&quot; title=&quot;17&quot;&gt;  &lt;span class=&quot;co&quot;&gt;// Start with all empty&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-18&quot; title=&quot;18&quot;&gt;  &lt;span class=&quot;cf&quot;&gt;for&lt;/span&gt;(i &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; row &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; rowLen &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;numberOfRows&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt; rowLen&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; row &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;++&lt;/span&gt;i) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-19&quot; title=&quot;19&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;curCellGen&lt;/span&gt;[row] &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; []&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-20&quot; title=&quot;20&quot;&gt;    &lt;span class=&quot;cf&quot;&gt;for&lt;/span&gt;(j &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; col &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; colLen &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;numberOfCols&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; j &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt; colLen&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; col &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;++&lt;/span&gt;j) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-21&quot; title=&quot;21&quot;&gt;      &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;curCellGen&lt;/span&gt;[row][col] &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;createCell&lt;/span&gt;(&lt;span class=&quot;kw&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; row&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; col)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-22&quot; title=&quot;22&quot;&gt;    &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-23&quot; title=&quot;23&quot;&gt;  &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-24&quot; title=&quot;24&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-25&quot; title=&quot;25&quot;&gt;  &lt;span class=&quot;co&quot;&gt;// Create glider&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-26&quot; title=&quot;26&quot;&gt;  &lt;span class=&quot;cf&quot;&gt;for&lt;/span&gt;(i &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dv&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; gliderLen &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;glider&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;op&quot;&gt;&amp;lt;&lt;/span&gt; gliderLen&lt;span class=&quot;op&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;op&quot;&gt;++&lt;/span&gt;) &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-27&quot; title=&quot;27&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; x&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; y&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-28&quot; title=&quot;28&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-29&quot; title=&quot;29&quot;&gt;    x &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;glider&lt;/span&gt;[i].&lt;span class=&quot;at&quot;&gt;x&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-30&quot; title=&quot;30&quot;&gt;    y &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;glider&lt;/span&gt;[i].&lt;span class=&quot;at&quot;&gt;y&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-31&quot; title=&quot;31&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-32&quot; title=&quot;32&quot;&gt;    &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;curCellGen&lt;/span&gt;[x][y] &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;createCell&lt;/span&gt;(&lt;span class=&quot;kw&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; x&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; y)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-33&quot; title=&quot;33&quot;&gt;  &lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-34&quot; title=&quot;34&quot;&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-35&quot; title=&quot;35&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-36&quot; title=&quot;36&quot;&gt;&lt;span class=&quot;va&quot;&gt;GameOfLife&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;prototype&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;drawGrid&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;() &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-37&quot; title=&quot;37&quot;&gt;  &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; img &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;createElement&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;img&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-38&quot; title=&quot;38&quot;&gt;  &lt;span class=&quot;va&quot;&gt;img&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;src&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;canvas&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;toDataURL&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;img/png&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-39&quot; title=&quot;39&quot;&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After rendering as a png in the browser, I saved the &lt;code&gt;.png&lt;/code&gt; to my computer. Then I uploaded the png to &lt;a href=&quot;http://favicon-generator.org/&quot;&gt;favicon-generator.org&lt;/a&gt; saving the resulting &lt;code&gt;.ico&lt;/code&gt; to my site’s directory root as &lt;code&gt;favicon.ico&lt;/code&gt;. &lt;code&gt;favicon.ico&lt;/code&gt; is what gets rendered in IE, since IE has found brand new ways to be non-compliant with emerging standards (le sigh).&lt;/p&gt;
&lt;p&gt;The finishing touch is to make the &lt;code&gt;GameOfLife.prototype.drawGrid&lt;/code&gt; function update my favicon’s &lt;code&gt;href&lt;/code&gt; attribute on every &lt;code&gt;tick&lt;/code&gt; function call:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb2&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;va&quot;&gt;GameOfLife&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;prototype&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;createCanvas&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;() &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-2&quot; title=&quot;2&quot;&gt;  &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;canvas&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;createElement&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;canvas&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-3&quot; title=&quot;3&quot;&gt;  &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;favicon&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;createElement&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;link&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-4&quot; title=&quot;4&quot;&gt;  &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;favicon&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;rel&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;icon&amp;#39;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-5&quot; title=&quot;5&quot;&gt;  &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;getElementsByTagName&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;head&amp;#39;&lt;/span&gt;)[&lt;span class=&quot;dv&quot;&gt;0&lt;/span&gt;].&lt;span class=&quot;at&quot;&gt;appendChild&lt;/span&gt;(link)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-6&quot; title=&quot;6&quot;&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-7&quot; title=&quot;7&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-8&quot; title=&quot;8&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-9&quot; title=&quot;9&quot;&gt;&lt;span class=&quot;va&quot;&gt;GameOfLife&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;prototype&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;drawGrid&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;() &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-10&quot; title=&quot;10&quot;&gt;  &lt;span class=&quot;co&quot;&gt;/* ... */&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-11&quot; title=&quot;11&quot;&gt;  &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;favicon&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;href&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;canvas&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;toDataURL&lt;/span&gt;(&lt;span class=&quot;st&quot;&gt;&amp;#39;img/png&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-12&quot; title=&quot;12&quot;&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The entirety of this javascript is available under the &lt;a href=&quot;https://tldrlegal.com/license/gnu-general-public-license-v3-%28gpl-3%29&quot;&gt;GPLv3 License&lt;/a&gt; on &lt;a href=&quot;https://github.com/thcipriani/conways-favicon&quot;&gt;my github&lt;/a&gt;.&lt;/p&gt;
&lt;/section&gt;

	</content>


	<link rel="comments" href="//tylercipriani.com/blog/2014/11/30/conways-game-of-life-favicon/#comments" type="text/html" />


	<link rel="comments" href="//tylercipriani.com/blog/2014/11/30/conways-game-of-life-favicon/comments.atom" type="application/atom+xml" />

</entry>
<entry>
	<title>Cross-Browser JavaScript Scrollbar Detection</title>

	<id>https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/</id>

	<link href="https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/"/>

	<author><name>Tyler Cipriani</name></author>


	<rights type="html" xml:lang="en">

		&lt;a href=&quot;https://creativecommons.org/licenses/by-sa/4.0/&quot;&gt;Creative Commons Attribution-ShareAlike License&lt;/a&gt;
		Copyright © 2017 Tyler Cipriani

	</rights>



	<category term="computing" />

	<category term="design" />

	<category term="javascript" />


	<updated>2017-02-14T15:11:05Z</updated>
	<published>2014-07-12T00:00:00Z</published>


	<content type="html" xml:lang="en">
	&lt;p&gt;I recently contributed a fix to the &lt;a href=&quot;https://github.com/twbs/bootstrap/issues/9855&quot;&gt;bootstrap framework&lt;/a&gt; that detects on-screen scrollbars to determine whether or not the body should be padded when a modal window is opened to prevent shifting of background contents. Detecting on-screen scrollbars turned out to be a bit more involved than I initially anticipated.&lt;/p&gt;
&lt;p&gt;The tl;dr, semi-näive version:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb1&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb1-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; hasScrollbar &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;innerWidth&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;documentElement&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;clientWidth&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This works for most browsers. Basically it checks to see if the width of the &lt;code&gt;window&lt;/code&gt; element (read: including scrollbars) is greater than the width of the root element of the page (read: without scrollbars). If the width of the page with scrollbars is greater than the width of a page without scrollbars it would stand to reason that the extra width &lt;em&gt;is&lt;/em&gt; a scrollbar.&lt;/p&gt;
&lt;p&gt;This solution behaves correctly when IE10+ has &lt;code&gt;@-ms-viewport { width: device-width; }&lt;/code&gt; set (as it is in the bootstrap framework), which seems to result in scrollbars being auto-hidden. This solution also works for Chrome on the Mac where the scrollbars are automagically hidden.&lt;/p&gt;
&lt;p&gt;This certainly seems to function as expected for IE9+; however, &lt;a href=&quot;http://www.paulirish.com/2011/browser-market-pollution-iex-is-the-new-ie6/&quot;&gt;IE8 is our newest anchor browser&lt;/a&gt; so IE8 should be addressed in any ostensibly “cross-browser” approaches.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;window.innerWidth&lt;/code&gt; doesn’t exist on IE8. Any workarounds you see utilizing &lt;code&gt;document.documentElement&lt;/code&gt; will not include scrollbars in the reported width, so &lt;code&gt;document.docutmentElement&lt;/code&gt; will not be an adequate substitute in &amp;lt; IE9.&lt;/p&gt;
&lt;p&gt;One thing to check is the &lt;code&gt;scrollHeight&lt;/code&gt;. If the &lt;code&gt;scrollHeight&lt;/code&gt; of the root element is greater than the &lt;code&gt;clientHeight&lt;/code&gt; of the root element, then that root element is going to need to scroll to show the overflowing content:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb2&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; hasScrollbar&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-2&quot; title=&quot;2&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-3&quot; title=&quot;3&quot;&gt;&lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kw&quot;&gt;typeof&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;innerWidth&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;number&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-4&quot; title=&quot;4&quot;&gt;  hasScrollbar &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;innerWidth&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;documentElement&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;clientWidth&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-5&quot; title=&quot;5&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-6&quot; title=&quot;6&quot;&gt;hasScrollbar &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; hasScrollbar &lt;span class=&quot;op&quot;&gt;||&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb2-7&quot; title=&quot;7&quot;&gt;  &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;documentElement&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;scrollHeight&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;documentElement&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;clientHeight&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Again, this is an oversimplification. The &lt;code&gt;overflow&lt;/code&gt; property of the root element can modify the appearance of scrollbars (to create on-screen &lt;em&gt;faux&lt;/em&gt; llbars). Of course, once again, IE and modern browsers differ about how they’ve implemented the javascript api for accessing element styles. We can account for this difference and grab the overflow property like this:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb3&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; overflowStyle&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-2&quot; title=&quot;2&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-3&quot; title=&quot;3&quot;&gt;&lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kw&quot;&gt;typeof&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;documentElement&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;currentStyle&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;undefined&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-4&quot; title=&quot;4&quot;&gt;  overflowStyle &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;documentElement&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;currentStyle&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;overflow&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-5&quot; title=&quot;5&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb3-6&quot; title=&quot;6&quot;&gt;overflowStyle &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; overflowStyle &lt;span class=&quot;op&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;getComputedStyle&lt;/span&gt;(&lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;documentElement&lt;/span&gt;&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;).&lt;span class=&quot;at&quot;&gt;overflow&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The two values of the &lt;code&gt;overflow&lt;/code&gt; or &lt;code&gt;overflow-y&lt;/code&gt; properties that will create scrollbars are &lt;code&gt;visible&lt;/code&gt; and &lt;code&gt;auto&lt;/code&gt; provided that the &lt;code&gt;scrollHeight&lt;/code&gt; is greater than the &lt;code&gt;clientHeight&lt;/code&gt;. A value of &lt;code&gt;scroll&lt;/code&gt; for the &lt;code&gt;overflow&lt;/code&gt; or &lt;code&gt;overflow-y&lt;/code&gt; properties will always cause a scrollbar.&lt;/p&gt;
&lt;p&gt;This is, once again, a bit of a simplification.&lt;/p&gt;
&lt;p&gt;In quirksmode in IE8 &lt;code&gt;document.documentElement.clientHeight&lt;/code&gt; is 0. The root element is &lt;code&gt;document.body&lt;/code&gt;. This won’t affect most people reading this, but just to be on the safe side let’s add it into our solution.&lt;/p&gt;
&lt;p&gt;The final solution looks like this:&lt;/p&gt;
&lt;div class=&quot;sourceCode&quot; id=&quot;cb4&quot;&gt;&lt;pre class=&quot;sourceCode numberSource javascript numberLines&quot;&gt;&lt;code class=&quot;sourceCode javascript&quot;&gt;&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-1&quot; title=&quot;1&quot;&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; hasScrollbar &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;() &lt;span class=&quot;op&quot;&gt;{&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-2&quot; title=&quot;2&quot;&gt;  &lt;span class=&quot;co&quot;&gt;// The Modern solution&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-3&quot; title=&quot;3&quot;&gt;  &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kw&quot;&gt;typeof&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;innerWidth&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;number&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-4&quot; title=&quot;4&quot;&gt;    &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;innerWidth&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;documentElement&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;clientWidth&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-5&quot; title=&quot;5&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-6&quot; title=&quot;6&quot;&gt;  &lt;span class=&quot;co&quot;&gt;// rootElem for quirksmode&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-7&quot; title=&quot;7&quot;&gt;  &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; rootElem &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;documentElement&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;body&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-8&quot; title=&quot;8&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-9&quot; title=&quot;9&quot;&gt;  &lt;span class=&quot;co&quot;&gt;// Check overflow style property on body for fauxscrollbars&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-10&quot; title=&quot;10&quot;&gt;  &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; overflowStyle&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-11&quot; title=&quot;11&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-12&quot; title=&quot;12&quot;&gt;  &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kw&quot;&gt;typeof&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;rootElem&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;currentStyle&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;undefined&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-13&quot; title=&quot;13&quot;&gt;    overflowStyle &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;rootElem&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;currentStyle&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;overflow&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-14&quot; title=&quot;14&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-15&quot; title=&quot;15&quot;&gt;  overflowStyle &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; overflowStyle &lt;span class=&quot;op&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;getComputedStyle&lt;/span&gt;(rootElem&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;).&lt;span class=&quot;at&quot;&gt;overflow&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-16&quot; title=&quot;16&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-17&quot; title=&quot;17&quot;&gt;    &lt;span class=&quot;co&quot;&gt;// Also need to check the Y axis overflow&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-18&quot; title=&quot;18&quot;&gt;  &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; overflowYStyle&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-19&quot; title=&quot;19&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-20&quot; title=&quot;20&quot;&gt;  &lt;span class=&quot;cf&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kw&quot;&gt;typeof&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;rootElem&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;currentStyle&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;undefined&amp;#39;&lt;/span&gt;)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-21&quot; title=&quot;21&quot;&gt;    overflowYStyle &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;rootElem&lt;/span&gt;.&lt;span class=&quot;va&quot;&gt;currentStyle&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;overflowY&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-22&quot; title=&quot;22&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-23&quot; title=&quot;23&quot;&gt;  overflowYStyle &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; overflowYStyle &lt;span class=&quot;op&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;getComputedStyle&lt;/span&gt;(rootElem&lt;span class=&quot;op&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;).&lt;span class=&quot;at&quot;&gt;overflowY&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-24&quot; title=&quot;24&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-25&quot; title=&quot;25&quot;&gt;  &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; contentOverflows &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;rootElem&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;scrollHeight&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;va&quot;&gt;rootElem&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;clientHeight&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-26&quot; title=&quot;26&quot;&gt;  &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; overflowShown    &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;^(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;)$&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;/&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;test&lt;/span&gt;(overflowStyle) &lt;span class=&quot;op&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;^(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;)$&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;/&lt;/span&gt;.&lt;span class=&quot;at&quot;&gt;test&lt;/span&gt;(overflowYStyle)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-27&quot; title=&quot;27&quot;&gt;  &lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; alwaysShowScroll &lt;span class=&quot;op&quot;&gt;=&lt;/span&gt; overflowStyle &lt;span class=&quot;op&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;scroll&amp;#39;&lt;/span&gt; &lt;span class=&quot;op&quot;&gt;||&lt;/span&gt; overflowYStyle &lt;span class=&quot;op&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;st&quot;&gt;&amp;#39;scroll&amp;#39;&lt;/span&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-28&quot; title=&quot;28&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-29&quot; title=&quot;29&quot;&gt;  &lt;span class=&quot;cf&quot;&gt;return&lt;/span&gt; (contentOverflows &lt;span class=&quot;op&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; overflowShown) &lt;span class=&quot;op&quot;&gt;||&lt;/span&gt; (alwaysShowScroll)&lt;/a&gt;
&lt;a class=&quot;sourceLine&quot; id=&quot;cb4-30&quot; title=&quot;30&quot;&gt;&lt;span class=&quot;op&quot;&gt;}&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If I missed something, or if &lt;em&gt;this&lt;/em&gt; solution is a bit of an oversimplification (le sigh), please let me know in the comments.&lt;/p&gt;

	</content>


	<link rel="comments" href="//tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/#comments" type="text/html" />


	<link rel="comments" href="//tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/comments.atom" type="application/atom+xml" />

</entry>

</feed>
