Comparing version 0.1.1 to 0.2.0
@@ -1,6 +0,13 @@ | ||
declare const providers: Record<string, (path: string) => string>; | ||
declare function cdnUrl(provider: string, path: string): string; | ||
declare function getFastestProvider(path?: string): Promise<string>; | ||
declare function getFastestCdnUrl(path?: string): Promise<(path: string) => string>; | ||
declare class UrlBuilder { | ||
providers: { | ||
[x: string]: (path: string) => string; | ||
}; | ||
provider: string; | ||
getFastestProvider(path?: string): Promise<string>; | ||
findFastestProvider(): Promise<string>; | ||
setProvider(name: string, factory: ((path: string) => string) | null): void; | ||
getFullUrl(path: string, provider?: string): string; | ||
} | ||
declare const urlBuilder: UrlBuilder; | ||
export { cdnUrl, getFastestCdnUrl, getFastestProvider, providers }; | ||
export { UrlBuilder, urlBuilder }; |
{ | ||
"name": "npm2url", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Convert an NPM package import into a CDN URL.", | ||
@@ -22,11 +22,2 @@ "repository": "gera2ld/npm2url", | ||
], | ||
"scripts": { | ||
"build": "unbuild", | ||
"dev": "vitest dev", | ||
"lint": "eslint --cache --ext .ts,.js,.mjs,.cjs . && prettier -c src test", | ||
"lint:fix": "eslint --cache --ext .ts,.js,.mjs,.cjs . --fix && prettier -c src test -w", | ||
"prepack": "pnpm run build", | ||
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags", | ||
"test": "pnpm lint && vitest run --coverage" | ||
}, | ||
"devDependencies": { | ||
@@ -42,3 +33,11 @@ "@vitest/coverage-c8": "^0.31.4", | ||
}, | ||
"packageManager": "pnpm@8.6.6" | ||
"packageManager": "pnpm@8.6.6", | ||
"scripts": { | ||
"build": "unbuild", | ||
"dev": "vitest dev", | ||
"lint": "eslint --cache --ext .ts,.js,.mjs,.cjs . && prettier -c src test", | ||
"lint:fix": "eslint --cache --ext .ts,.js,.mjs,.cjs . --fix && prettier -c src test -w", | ||
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags", | ||
"test": "pnpm lint && vitest run --coverage" | ||
} | ||
} |
@@ -21,9 +21,14 @@ # npm2url | ||
```ts | ||
import { cdnUrl, getFastestCdnUrl } from "npm2url"; | ||
import { urlBuilder } from "npm2url"; | ||
const url: string = cdnUrl('jsdelivr', 'npm2url'); | ||
const url: string = urlBuilder.getFullUrl('npm2url'); | ||
const url: string = urlBuilder.getFullUrl('npm2url', 'jsdelivr'); | ||
// Or find the fastest provider | ||
const fastestCdnUrl = await getFastestCdnUrl(); | ||
const url: string = fastestCdnUrl('npm2url'); | ||
// 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); | ||
``` | ||
@@ -30,0 +35,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
7820
7
154
51
3