title: Implementation of the PackBits algorithm
body: <p>I want to implement the PackBits algorithm.</p>
  <p>The background is that I am writing some code for an <a href="https://en.wikipedia.org/wiki/ONVIF" rel="nofollow noreferrer">ONVIF</a> camera. I want to compress a pattern/string of 1's and 0's with PackBits, and I also want to decode an existing packed string.</p>
  <p>JavaScript has my preference, but C, PHP or similar will do too.</p>
  <p>I have been looking for some examples, but couldn't find any.</p>
  <p>How can I implement the PackBits algorithm?</p>