🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@procore/cdn

Package Overview
Dependencies
Maintainers
18
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@procore/cdn

Resolve the procore CDN

2.0.0
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
18
Weekly downloads
 
Created
Source

Resolve Procore CDN

Motivation

Browsers only allow 6 current requests to the same domain. In order to overcome this restriction procore has 4 subdomains for fastly. This helper function will alternate between the subdomains in a sequence of 0-3 by default. The results are memoized, the same string will result with the same value.

Usage

cdn(numberOfDomains: number) {
  return cached(bgImg: string)
    return string
}

Example

import _cdn from '@procore/cdn';
import testImg from './test.png';
import bgImg from './bg.jpg';

const cdn = _cdn(4)

const App = () => {
  return (
    <div>
      <img src={cdn(testImg)} /> 
      /*
        https://procore-production-assets0.global.ssl.fastly.net/22028741.png
      */
      <div style={{ backgroundImage: `url(${cdn(bgImg)})`} />
      /*
        <div style="background-image: url(https://procore-production-assets1.global.ssl.fastly.net/03852981.jpg)></div>
      */
    </div>
  )
}

Keywords

cdn

FAQs

Package last updated on 29 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts