New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

npm2url

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm2url - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

./dist/index.cjs

17

dist/index.d.ts

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc