title: Export a Monkey Patch library and Import it into a separate file in Javascript
body: <p>I'm working in <strong>WebDriverIO</strong> w/<strong>Mocha</strong>, and there's some <strong>monkey patches</strong> I've written to make my code easier to read. Things like:</p>
  <ul>
  <li><strong><code>Object.prototype.findEntries(...arr)</code></strong> for getting a subset of Object.entries(),</li>
  <li><strong><code>String.prototype.padding(int)</code></strong>, adding spacing to the right of a string,</li>
  <li><strong><code>Array.prototype.sortByKey(key)</code></strong> to sort an array of similar objects by the value of a common key, and</li>
  <li><strong><code>Array.prototype.last()</code></strong>, the classic.</li>
  </ul>
  <p>Since I have <em>many</em> spec files with even more tests, I'd like to have a MonkeyPatchLib.js in my project that I can import into my spec files, so I can call these custom functions when needed:</p>
  <p><em><strong>myTest.js</strong></em>:</p>
  <pre class="lang-js prettyprint-override"><code>import { all } from './MonkeyPatchLib.js' // &lt;- line in question
  
  describe('My First Spec File', async() =&gt; {
      it('First Test', async() =&gt; {
          let myArr=[1,2,3]
          console.log(myArr.last())
      })
  })
  </code></pre>
  <p>I've screwed around with <code>module.exports=[func1(){...},func2(){...}]</code> to no avail. I'm aware that I can simply create custom classes (a la <a href="https://stackoverflow.com/questions/49063413/how-to-access-object-prototype-methods-from-another-file-using-module-exports">the solution to this question</a>) and export those, but that would require an annoying refactor of my codebase. How should I format the library, and how would one import said library?</p>