fast-npm-meta 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +29 -0
- package/dist/index.d.cts +22 -0
- package/dist/index.d.mts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.mjs +25 -0
- package/package.json +46 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ofetch = require('ofetch');
|
|
4
|
+
|
|
5
|
+
const defaultOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* API endpoint for fetching package versions
|
|
8
|
+
*
|
|
9
|
+
* @default 'https://npm.antfu.dev/'
|
|
10
|
+
*/
|
|
11
|
+
apiEndpoint: "https://npm.antfu.dev/"
|
|
12
|
+
};
|
|
13
|
+
async function getLatestVersions(packages, options = {}) {
|
|
14
|
+
const {
|
|
15
|
+
apiEndpoint = defaultOptions.apiEndpoint
|
|
16
|
+
} = options;
|
|
17
|
+
const data = await ofetch.$fetch(apiEndpoint + packages.join("+"));
|
|
18
|
+
if (!Array.isArray(data))
|
|
19
|
+
return [data];
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
async function getLatestVersion(name, options = {}) {
|
|
23
|
+
const [data] = await getLatestVersions([name], options);
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.defaultOptions = defaultOptions;
|
|
28
|
+
exports.getLatestVersion = getLatestVersion;
|
|
29
|
+
exports.getLatestVersions = getLatestVersions;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface ResolvedPackageVersion {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string | null;
|
|
4
|
+
specifier: string;
|
|
5
|
+
lastSynced: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface ApiOptions {
|
|
9
|
+
apiEndpoint?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const defaultOptions: {
|
|
12
|
+
/**
|
|
13
|
+
* API endpoint for fetching package versions
|
|
14
|
+
*
|
|
15
|
+
* @default 'https://npm.antfu.dev/'
|
|
16
|
+
*/
|
|
17
|
+
apiEndpoint: string;
|
|
18
|
+
};
|
|
19
|
+
declare function getLatestVersions(packages: string[], options?: ApiOptions): Promise<ResolvedPackageVersion[]>;
|
|
20
|
+
declare function getLatestVersion(name: string, options?: ApiOptions): Promise<ResolvedPackageVersion>;
|
|
21
|
+
|
|
22
|
+
export { type ApiOptions, defaultOptions, getLatestVersion, getLatestVersions };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface ResolvedPackageVersion {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string | null;
|
|
4
|
+
specifier: string;
|
|
5
|
+
lastSynced: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface ApiOptions {
|
|
9
|
+
apiEndpoint?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const defaultOptions: {
|
|
12
|
+
/**
|
|
13
|
+
* API endpoint for fetching package versions
|
|
14
|
+
*
|
|
15
|
+
* @default 'https://npm.antfu.dev/'
|
|
16
|
+
*/
|
|
17
|
+
apiEndpoint: string;
|
|
18
|
+
};
|
|
19
|
+
declare function getLatestVersions(packages: string[], options?: ApiOptions): Promise<ResolvedPackageVersion[]>;
|
|
20
|
+
declare function getLatestVersion(name: string, options?: ApiOptions): Promise<ResolvedPackageVersion>;
|
|
21
|
+
|
|
22
|
+
export { type ApiOptions, defaultOptions, getLatestVersion, getLatestVersions };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface ResolvedPackageVersion {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string | null;
|
|
4
|
+
specifier: string;
|
|
5
|
+
lastSynced: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface ApiOptions {
|
|
9
|
+
apiEndpoint?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const defaultOptions: {
|
|
12
|
+
/**
|
|
13
|
+
* API endpoint for fetching package versions
|
|
14
|
+
*
|
|
15
|
+
* @default 'https://npm.antfu.dev/'
|
|
16
|
+
*/
|
|
17
|
+
apiEndpoint: string;
|
|
18
|
+
};
|
|
19
|
+
declare function getLatestVersions(packages: string[], options?: ApiOptions): Promise<ResolvedPackageVersion[]>;
|
|
20
|
+
declare function getLatestVersion(name: string, options?: ApiOptions): Promise<ResolvedPackageVersion>;
|
|
21
|
+
|
|
22
|
+
export { type ApiOptions, defaultOptions, getLatestVersion, getLatestVersions };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { $fetch } from 'ofetch';
|
|
2
|
+
|
|
3
|
+
const defaultOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* API endpoint for fetching package versions
|
|
6
|
+
*
|
|
7
|
+
* @default 'https://npm.antfu.dev/'
|
|
8
|
+
*/
|
|
9
|
+
apiEndpoint: "https://npm.antfu.dev/"
|
|
10
|
+
};
|
|
11
|
+
async function getLatestVersions(packages, options = {}) {
|
|
12
|
+
const {
|
|
13
|
+
apiEndpoint = defaultOptions.apiEndpoint
|
|
14
|
+
} = options;
|
|
15
|
+
const data = await $fetch(apiEndpoint + packages.join("+"));
|
|
16
|
+
if (!Array.isArray(data))
|
|
17
|
+
return [data];
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
async function getLatestVersion(name, options = {}) {
|
|
21
|
+
const [data] = await getLatestVersions([name], options);
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { defaultOptions, getLatestVersion, getLatestVersions };
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fast-npm-meta",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"description": "Get npm package metadata",
|
|
6
|
+
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"funding": "https://github.com/sponsors/antfu",
|
|
9
|
+
"homepage": "https://github.com/antfu/fast-npm-meta#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/antfu/fast-npm-meta.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": "https://github.com/antfu/fast-npm-meta/issues",
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.mjs",
|
|
21
|
+
"require": "./dist/index.cjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"main": "./dist/index.mjs",
|
|
25
|
+
"module": "./dist/index.mjs",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"typesVersions": {
|
|
28
|
+
"*": {
|
|
29
|
+
"*": [
|
|
30
|
+
"./dist/*",
|
|
31
|
+
"./dist/index.d.ts"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "unbuild",
|
|
40
|
+
"dev": "unbuild --stub",
|
|
41
|
+
"prepublishOnly": "nr build"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"ofetch": "^1.3.4"
|
|
45
|
+
}
|
|
46
|
+
}
|