src/index.js
function createCoincap () {
  const socket = io(baseUrl, { autoConnect: false })

  const api = {}

  // Add JSON API supported endpoints
  ;[
    {
      method: 'coins',
      url: () => '/coins'
    },
    {
      method: 'map',
      url: () => '/map'
    },
    {
      method: 'front',
      url: () => '/front'
    },
    {
      method: 'global',
      url: () => '/global'
    },
    {
      method: 'coin',
      url: coin => `/page/${coin}`
    },
    {
      method: 'coinHistory',
      url: (coin, days) => `/history/${days ? `${days}day/` : ''}${coin}`
    }
  ].forEach(function ({ method, url }) {
    api[method] = (...args) => fetch(url(...args))
  })

  // Add Socket.IO methods
  ;[
    'open',
    'close',
    'on',
    'off'
  ].forEach(function (method) {
    api[method] = socket[method].bind(socket)
  })

  return api
}
function createCoincap () {
  const socket = io(baseUrl, { autoConnect: false })

  const api = {}

  // Add JSON API supported endpoints
  ;[
    {
      method: 'coins',
      url: () => '/coins'
    },
    {
      method: 'map',
      url: () => '/map'
    },
    {
      method: 'front',
      url: () => '/front'
    },
    {
      method: 'global',
      url: () => '/global'
    },
    {
      method: 'coin',
      url: coin => `/page/${coin}`
    },
    {
      method: 'coinHistory',
      url: (coin, days) => `/history/${days ? `${days}day/` : ''}${coin}`
    }
  ].forEach(function ({ method, url }) {
    api[method] = (...args) => fetch(url(...args))
  })

  // Add Socket.IO methods
  ;[
    'open',
    'close',
    'on',
    'off'
  ].forEach(function (method) {
    api[method] = socket[method].bind(socket)
  })

  return api
}
function createCoincap ( ) { const socket = io ( baseUrl , { autoConnect : false } ) const api = { } // Add JSON API supported endpoints ; [ { method : 'coins' , url : ( ) => '/coins' } , { method : 'map' , url : ( ) => '/map' } , { method : 'front' , url : ( ) => '/front' } , { method : 'global' , url : ( ) => '/global' } , { method : 'coin' , url : coin => ` ${ coin } ` } , { method : 'coinHistory' , url : ( coin , days ) => ` ${ days ? ` ${ days } ` : '' } ${ coin } ` } ] . forEach ( function ( { method , url } ) { api [ method ] = ( ... args ) => fetch ( url ( ... args ) ) } ) // Add Socket.IO methods ; [ 'open' , 'close' , 'on' , 'off' ] . forEach ( function ( method ) { api [ method ] = socket [ method ] . bind ( socket ) } ) return api }
Constructs the CoinCap API object.

@return {Object}
Constructs the CoinCap API object .