arrays, count characters, that sort of thing.</p></td><tdclass="code"><divclass="highlight"><pre></pre></div></td></tr><trid="section-2"><tdclass="docs"><divclass="pilwrap"><aclass="pilcrow"href="#section-2">¶</a></div><p>Peek at the beginning of a given string to see if it matches a sequence.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">exports.starts = </span><spanclass="nf">(string, literal, start) -></span>
<spanclass="nx">literal</span><spanclass="o">is</span><spanclass="nx">string</span><spanclass="p">.</span><spanclass="nx">substr</span><spanclass="nx">start</span><spanclass="p">,</span><spanclass="nx">literal</span><spanclass="p">.</span><spanclass="nx">length</span></pre></div></td></tr><trid="section-3"><tdclass="docs"><divclass="pilwrap"><aclass="pilcrow"href="#section-3">¶</a></div><p>Peek at the end of a given string to see if it matches a sequence.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">exports.ends = </span><spanclass="nf">(string, literal, back) -></span>
<spanclass="nx">literal</span><spanclass="o">is</span><spanclass="nx">string</span><spanclass="p">.</span><spanclass="nx">substr</span><spanclass="nx">string</span><spanclass="p">.</span><spanclass="nx">length</span><spanclass="o">-</span><spanclass="nx">len</span><spanclass="o">-</span><spanclass="p">(</span><spanclass="nx">back</span><spanclass="o">or</span><spanclass="mi">0</span><spanclass="p">),</span><spanclass="nx">len</span></pre></div></td></tr><trid="section-4"><tdclass="docs"><divclass="pilwrap"><aclass="pilcrow"href="#section-4">¶</a></div><p>Trim out all falsy values from an array.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">exports.compact = </span><spanclass="nf">(array) -></span>
<spanclass="nx">item</span><spanclass="k">for</span><spanclass="nx">item</span><spanclass="k">in</span><spanclass="nx">array</span><spanclass="k">when</span><spanclass="nx">item</span></pre></div></td></tr><trid="section-5"><tdclass="docs"><divclass="pilwrap"><aclass="pilcrow"href="#section-5">¶</a></div><p>Count the number of occurrences of a string in a string.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">exports.count = </span><spanclass="nf">(string, substr) -></span>
<spanclass="nx">num</span></pre></div></td></tr><trid="section-6"><tdclass="docs"><divclass="pilwrap"><aclass="pilcrow"href="#section-6">¶</a></div><p>Merge objects, returning a fresh copy with attributes from both sides.
Used every time <code>Base#compile</code> is called, to allow properties in the
options hash to propagate down the tree without polluting other branches.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">exports.merge = </span><spanclass="nf">(options, overrides) -></span>
<spanclass="nx">extend</span><spanclass="p">(</span><spanclass="nx">extend</span><spanclass="p">{},</span><spanclass="nx">options</span><spanclass="p">),</span><spanclass="nx">overrides</span></pre></div></td></tr><trid="section-7"><tdclass="docs"><divclass="pilwrap"><aclass="pilcrow"href="#section-7">¶</a></div><p>Extend a source object with the properties of another object (shallow copy).</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">extend = exports.extend = </span><spanclass="nf">(object, properties) -></span>
<spanclass="nx">object</span></pre></div></td></tr><trid="section-8"><tdclass="docs"><divclass="pilwrap"><aclass="pilcrow"href="#section-8">¶</a></div><p>Return a flattened version of an array.
Handy for getting a list of <code>children</code> from the nodes.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">exports.flatten = flatten = </span><spanclass="nf">(array) -></span>
<spanclass="nx">flattened</span></pre></div></td></tr><trid="section-9"><tdclass="docs"><divclass="pilwrap"><aclass="pilcrow"href="#section-9">¶</a></div><p>Delete a key from an object, returning the value. Useful when a node is
looking for a particular method in an options hash.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">exports.del = </span><spanclass="nf">(obj, key) -></span>
<spanclass="nx">val</span></pre></div></td></tr><trid="section-10"><tdclass="docs"><divclass="pilwrap"><aclass="pilcrow"href="#section-10">¶</a></div><p>Gets the last item of an array(-like) object.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">exports.last = </span><spanclass="nf">(array, back) -></span><spanclass="nx">array</span><spanclass="p">[</span><spanclass="nx">array</span><spanclass="p">.</span><spanclass="nx">length</span><spanclass="o">-</span><spanclass="p">(</span><spanclass="nx">back</span><spanclass="o">or</span><spanclass="mi">0</span><spanclass="p">)</span><spanclass="o">-</span><spanclass="mi">1</span><spanclass="p">]</span></pre></div></td></tr><trid="section-11"><tdclass="docs"><divclass="pilwrap"><aclass="pilcrow"href="#section-11">¶</a></div><p>Typical Array::some</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">exports.some = </span><spanclass="nb">Array</span><spanclass="o">::</span><spanclass="nx">some</span><spanclass="o">?</span><spanclass="nf">(fn) -></span>