title: How to hook up a third party library to Angular 4 for use as a service
body: <p>I'm trying to add <a href="https://github.com/ecrmnn/collect.js" rel="nofollow noreferrer">collect.js</a> to my Angular 4 application built using the Angular CLI, which has it's own typings file, but I don't understand how to import the package, and start using it.  The import below appears to get me the exports of the package, but I don't understand how to access them:</p>
  
  <pre><code>import * as Collection from 'collect.js';
  </code></pre>
  
  <p>This is the <code>collect.js</code> file being imported:</p>
  
  <pre><code>function Collection(collection) {
    this.items = collection || [];
  }
  
  Collection.prototype[Symbol.iterator] = require('./methods/symbol.iterator');
  
  Collection.prototype.all = require('./methods/all');
  // ... removed for brevity
  Collection.prototype.zip = require('./methods/zip');
  
  module.exports = collection =&gt; new Collection(collection);
  module.exports.default = collection =&gt; new Collection(collection);
  </code></pre>
  
  <p>The import Collection is a method as you'd expect from the module export, but I can't invoke it without VSCode saying it has no call signature, and I'm also not sure if the typings are automatically loaded or if I need to manually add them.  I was hoping to make a service out of it by importing it once then just mapping methods, and then providing that in the CoreModule so I can DI and use it wherever I want in the application, but I'm not sure how to access the API in order to make it a service. </p>