@procore/cdn

2.0.0 • Public • Published

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>
  )
}

Readme

Keywords

Package Sidebar

Install

npm i @procore/cdn

Weekly Downloads

4,124

Version

2.0.0

License

ISC

Unpacked Size

3.4 kB

Total Files

8

Last publish

Collaborators

  • max.helmetag
  • codyrobertsprocore
  • miguel.garcia-procore
  • magdyyx
  • atoaima
  • mustafa-abdelrahman
  • elewando-procore
  • aishwaryavenugopalan
  • ahmed.ghorab
  • lnspatz914
  • richard.bunn
  • omar.wagdy
  • mona.khairbek
  • allenli-procore
  • mrcola91
  • mbartlett413
  • cody_schindler_procore
  • penelopemckeefry
  • yoasyo25
  • ritchlee
  • augusto-procore
  • andersontr15
  • steven.hinkle
  • jamie-dugan-procore
  • hgouhierprocore
  • denzylbalram
  • dpetrenko
  • sarah.freitas
  • alan.bresani
  • lpremuda
  • amyprocore
  • yoyis3000
  • elijah.procore
  • mike-arndt-procore
  • jnhoang1
  • eyurtsever
  • pam-whisenhunt
  • shradha.khard
  • david-christensen-procore
  • javio-procore
  • chance.eakin.procore
  • gideon-procore
  • ihor.diachenko_procore
  • justinmwatts
  • tedyang
  • jyang-procore
  • pwhisenhunt-procore
  • fairchild
  • rodayna.ehab
  • neil1023
  • scottstern
  • brian.smith1
  • g2mitchell
  • dlameter-procore
  • icaro.oliveira-contractor
  • kylepietz
  • abhijit-procore
  • lhuang325
  • jake-pitkin
  • erikthoreson
  • simona.iancu
  • decha-sanson
  • aberkowitz
  • asamay
  • nour.adel
  • mustafa-u-abdelrahman
  • rajatmenhdiratta
  • jacksonleach-procore
  • pmfrawley
  • phunguyen-pcor
  • tatsiana.clifton
  • deiab
  • alexamoralessmyth
  • srichaitanya.peddinti
  • kenny.foisy
  • matheusprocore
  • jgreene_procore
  • pablo.soares
  • hectorthiele
  • beornborn
  • etokarev
  • daniel.ferreira-contractor
  • dmccraw-procore
  • cyrille.bai
  • greg.sparks
  • ishjot.walia
  • fabiomelo513
  • phil.custer
  • bbreyel921
  • amir-iskander
  • procore.elias.fong
  • neil.mckeeman
  • nickprocore
  • lzhou888
  • davidshure
  • stevenliprocore
  • ramysaid2
  • refaiepcn
  • jgentes
  • faraz.hanif
  • mostafaeltazy
  • agamaleldin
  • andrew.isaac
  • saranahal2
  • rodrigo.dejuana
  • kellen.stewart
  • bill-wagner
  • ezrasimeloff
  • sourabh.suri
  • jeffgiaquinto
  • gturkadze
  • sean.spearman.procore
  • kylemartinez-procore
  • roobo-romeski
  • andres-mendez-procore
  • gaurav.sharma.procore
  • tracy.otto
  • david.vandenburg
  • sarah.heredia
  • victorbendeck-pc
  • cbathgate
  • maicon.oliveira
  • davidkangpro
  • kyle.liu
  • amin.jaipuri
  • grafffffff
  • mishaelowoyemi
  • jfhbrook-at-procore
  • evan.cerwonka.procore
  • ilya.dryha-contractor
  • varomir
  • yogevfine1
  • vishalpokala
  • timofeee
  • matt.harris0223
  • ankun.yu
  • winson.chu
  • andersonbispoprocore
  • scorgiat-procore
  • alice.yu
  • james.wilton
  • ladavarga
  • dstarr
  • procore_halzy
  • garett.bynum.procore
  • enyaga
  • gerardolopezduenas-procore
  • willpankonien
  • sateesh-kadiyala-procore
  • chris.berber
  • txin1
  • safi.abdul
  • epalinprocore
  • mehrdad-panahandeh
  • tyler.wasden.procore
  • jeremy.lund
  • dineshkumar.jayak
  • roniedias-procore
  • ryanfuentesprocore
  • stajics
  • brocktillotsonprocore
  • kyle.williams
  • greg.spies
  • dtorres-procore
  • noor.ali
  • ari-procore
  • alanprocore
  • jl4ever
  • james.lawson
  • ajaykumar-procore
  • dennis.heckman
  • tara.chambers
  • lalovar-procore
  • james.cleary
  • chadryder
  • devin.cunningham.procore
  • abhijit.patwardhan
  • maxscott_pc
  • lydiahara
  • sherylnapigkit
  • changprocore
  • apcarroll_procore
  • andy.mayer
  • bob.laskowski
  • vinaya-procore
  • r-pulling
  • kahliholmes
  • amanzhula-zoolatech
  • andrew.wheeler
  • leandro-proc
  • yadhu.prakash
  • jason-kaye
  • initbar-procore
  • jesse.olsen
  • jsoncummings
  • patrick.lardin
  • brad.urani
  • ian.nguyen
  • allenanle.procore
  • ismail.hassan
  • brookyboy009
  • uddhavjoglekar
  • dancingshell
  • rysmithprocore
  • bostonaholic
  • robbiegprocore
  • jadamsss
  • jeremy.bouzigard
  • dallashall-procore
  • timdoherty
  • b.bookout
  • jalyng
  • chrisarevir
  • htael
  • espi
  • truthysystems
  • dev-account-admin
  • sseanwang
  • bhargavrnd
  • farismmk
  • dannyporrello
  • mcclayton
  • gregburger
  • danny.ou
  • messanjah
  • eyvettesou
  • jgee67
  • chriszhang
  • arthurzhuk
  • cagmz
  • mariah_delaney
  • lukenispel
  • kimhin267
  • hyogman
  • juliana.hernandez
  • evan.freymiller
  • manuphatak
  • judy-lu-pc
  • procore-it-support
  • wilfredr
  • andrewburke-pc
  • jkleintech
  • rachel.arkebauer
  • aaronme
  • procore-npm-bot
  • lincolnp
  • james.dabbs-procore
  • laurenbrandsteinprocore
  • kimtodd
  • scottbieser-procore
  • fkennedy
  • zach.mckenzie.procore
  • natalie.walia
  • kapoorlakshya-procore
  • shayonj_procore
  • heplayskeys
  • mike.south
  • thomasoboyle
  • dischorde
  • derek-carter-procore
  • dlgasser
  • moises.narvaez-procore
  • cfprocore
  • rory.forster
  • lgm_procore
  • evan.waits
  • todd-andrew-procore
  • jeremy-marcus
  • israel-pereira
  • jmejia-fsl
  • kedar.procore
  • ersgonzalo
  • stephan-procore
  • aleclarsenprocore
  • himansudesai
  • yihai.zweifel
  • jay-rajan
  • jacky-lei
  • bpross22
  • peter.jin