unslopkit

Components / Code blocks

Coverage gutter

Source with a run count beside every line: lines that never ran are hatched and say so, half-tested branches get a note, and the header totals it up. For test reports.

src/pricing/ticket.ts 86% lines8 of 10 branches
18×export function ticketPrice(age: number, member: boolean) {
18×  if (age < 5) return 0;
15×  if (member) {
6×    return age < 16 ? 4 : 9;1 of 2 branches
  }
9×  if (age >= 65) {never true
0×    return 8;never run
  }
9×  return age < 16 ? 6 : 12;
}
  • Ran
  • Some branches
  • Never ran
Drawn in your kit, Plain.Change the look

The code

Plain HTML and CSS on your kit's variables. Put it next to tokens/variables.css from your kit's files and it draws in your look.

<div class="ukc-code-coverage-gutter">
<figure class="cv">
  <figcaption class="hd">
    <span class="fn"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H6v18h12V7z"/><path d="M14 3v4h4"/></svg><span><span class="dir">src/pricing/</span>ticket.ts</span></span>
    <span class="tot"><span class="meter" role="img" aria-label="6 of 7 lines covered"><span class="fill"></span></span><b>86%</b> lines<span class="br2">8 of 10 branches</span></span>
  </figcaption>
  <pre class="src"><code><span class="l hit"><span class="h">18×</span><span class="k">export function</span> <span class="f">ticketPrice</span>(age: <span class="k">number</span>, member: <span class="k">boolean</span>) {</span>
<span class="l hit"><span class="h">18×</span>  <span class="k">if</span> (age &lt; <span class="n">5</span>) <span class="k">return</span> <span class="n">0</span>;</span>
<span class="l hit"><span class="h">15×</span>  <span class="k">if</span> (member) {</span>
<span class="l part"><span class="h">6×</span>    <span class="k">return</span> age &lt; <span class="n">16</span> ? <span class="n">4</span> : <span class="n">9</span>;<span class="why">1 of 2 branches</span></span>
<span class="l"><span class="h"></span>  }</span>
<span class="l part"><span class="h">9×</span>  <span class="k">if</span> (age &gt;= <span class="n">65</span>) {<span class="why">never true</span></span>
<span class="l miss"><span class="h">0×</span>    <span class="k">return</span> <span class="n">8</span>;<span class="why">never run</span></span>
<span class="l"><span class="h"></span>  }</span>
<span class="l hit"><span class="h">9×</span>  <span class="k">return</span> age &lt; <span class="n">16</span> ? <span class="n">6</span> : <span class="n">12</span>;</span>
<span class="l"><span class="h"></span>}</span></code></pre>
  <ul class="key" aria-label="Legend">
    <li><span class="sw hit"></span>Ran</li>
    <li><span class="sw part"></span>Some branches</li>
    <li><span class="sw miss"></span>Never ran</li>
  </ul>
</figure>
</div>

More code blocks

All 24
  • import { Halden } from "@halden/sdk";
     
    // Reads HALDEN_KEY from your environment
    const halden = new Halden();
    const job = await halden.jobs.get("JS-2207");
    const invoice = await job.invoice();
    await invoice.send({ to: job.client });
    from halden import Halden
     
    # Reads HALDEN_KEY from your environment
    halden = Halden()
    job = halden.jobs.get("JS-2207")
    invoice = job.invoice()
    invoice.send(to=job.client)
    # The same call, straight to the API
    curl api.halden.example/v2/invoices \
      -H "Authorization: Bearer $HALDEN_KEY" \
      -d job=JS-2207 \
      -d send=true
    $ npx tsx send-invoice.ts
    ✓ Drafted INV-0418 from 22.5 h and 3 receipts
    ✓ Sent to Reyes Framing · $2,140.00
    $ 

    Snippet with terminal

  • Install with
    npm install @halden/sdkpnpm add @halden/sdkyarn add @halden/sdk

    v3.2.018 kB gzippedNode 18 and up

    Install command

  • halden sync~/crews/reyes
    $ halden sync --since monday
    Syncing 38 job sheets for Reyes Framing
    31/38
    ✓JS-2207Alder St refit22.5 h
    ✓JS-2211Garage roof, Pier Ln14.0 h
    !JS-2214Bathroom, Mill Lnno sign-off
    ✗JS-2216Back deck rebuildupload failed
     Uploading receipts, 4 of 9

    Terminal mid-run

  • src/totals.ts +4−1
    @@ -12,3 +12,5 @@ function lineTotal
     export function lineTotal(l: Line) {
    −  return l.qty * l.rate * (1 + TAX);
    +  const net = round(l.qty * l.rate);
    +  const tax = round(net * l.taxRate);
    +  return { net, tax, total: net + tax };
     }
    @@ -24,2 +26,3 @@
     export const round = (n: number) =>
    +  // To the cent, half away from zero
       Math.round(n * 100) / 100;

    Unified diff

  • .halden.yml+4−3
    Changes to .halden.yml. Version 3.1 on the left, version 3.2 on the right.
    v3.1v3.2
    1invoices:1invoices:
    2 prefix: INV2 prefix: INV
    3− due_days: 143+ due_days: 30
    4 rounding: line4 rounding: line
    5− tax: 0.08255+ tax:
    6+ rate: 0.0825
    7+ labor: false
    6− legacy_pdf: true
    7 reminders: on8 reminders: on

    Side-by-side diff

  • export default {
      crew: "reyes-framing",
      currency: "USD",
      rounding: "line",
      reminders: [7, 14, 30],
      // Sync offline sheets
      sync: { every: "15m" },
    };

    TypeScriptLn 5, Col 25

    File tree and editor