npm2url
Version:
Convert an NPM package import into a CDN URL.
51 lines (35 loc) • 1.48 kB
Markdown
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![JSDocs][jsdocs-src]][jsdocs-href]
Convert an NPM package import into a CDN URL.
Install package:
```sh
pnpm install npm2url
```
Import:
```ts
import { urlBuilder } from "npm2url";
const url: string = urlBuilder.getFullUrl('npm2url');
const url: string = urlBuilder.getFullUrl('npm2url', 'jsdelivr');
// find the fastest provider
await urlBuilder.findFastestProvider();
const fastestUrl = urlBuilder.getFullUrl('npm2url');
// find the fastest provider temporarily
const fastest = await urlBuilder.getFastestProvider();
const fastestUrl = urlBuilder.getFullUrl('npm2url', fastest);
```
Made with 💛
Published under [MIT License](./LICENSE).
<!-- Badges -->
[]: https://img.shields.io/npm/v/npm2url?style=flat&colorA=18181B&colorB=F0DB4F
[]: https://npmjs.com/package/npm2url
[]: https://img.shields.io/npm/dm/npm2url?style=flat&colorA=18181B&colorB=F0DB4F
[]: https://npmjs.com/package/npm2url
[]: https://img.shields.io/bundlephobia/minzip/npm2url?style=flat&colorA=18181B&colorB=F0DB4F
[]: https://bundlephobia.com/result?p=npm2url
[]: https://img.shields.io/badge/jsDocs.io-reference-18181B?style=flat&colorA=18181B&colorB=F0DB4F
[]: https://www.jsdocs.io/package/npm2url