# @procore/cdn

> Resolve the procore CDN

Latest version **2.0.0** (published 2018-08-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install @procore/cdn
pnpm add @procore/cdn
yarn add @procore/cdn
bun add @procore/cdn
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-08-29 |
| First published | 2017-10-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | bates550, chrisarevir, dallashall-procore, dancingshell, dannyphillips, dev-account-admin, espi, farismmk, jadamsss, justinmwatts, m.mohammad, mboprtr, naulpispel, remyyounes, robbiegprocore, thewillhuang, timdoherty, truthysystems |
| Keywords | cdn, procore |

## Links

- npm: https://www.npmjs.com/package/@procore/cdn
- Repository: https://github.com/procore/resolve-cdn
- Homepage: https://github.com/procore/resolve-cdn#readme
- Issues: https://github.com/procore/resolve-cdn/issues
- npm.io page: https://npm.io/package/@procore/cdn

## Recent versions

- 2.0.0 (latest) — 2018-08-29
- 1.0.2 — 2018-03-28
- 1.0.1 — 2017-11-03
- 1.0.0 — 2017-10-12
- 0.0.1 — 2017-10-12

## README

# 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

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

## Example

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

---
_Source: https://npm.io/package/@procore/cdn · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
