fast-npm-meta 0.0.0 → 0.0.1
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 +35 -4
- package/dist/index.d.cts +13 -2
- package/dist/index.d.mts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.mjs +33 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10,20 +10,51 @@ const defaultOptions = {
|
|
|
10
10
|
*/
|
|
11
11
|
apiEndpoint: "https://npm.antfu.dev/"
|
|
12
12
|
};
|
|
13
|
-
async function
|
|
13
|
+
async function getLatestVersionBatch(packages, options = {}) {
|
|
14
14
|
const {
|
|
15
15
|
apiEndpoint = defaultOptions.apiEndpoint
|
|
16
16
|
} = options;
|
|
17
|
-
const data = await ofetch.$fetch(
|
|
17
|
+
const data = await ofetch.$fetch(
|
|
18
|
+
packages.join("+"),
|
|
19
|
+
{
|
|
20
|
+
baseURL: apiEndpoint,
|
|
21
|
+
query: {
|
|
22
|
+
force: options.force ? true : void 0
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
);
|
|
18
26
|
if (!Array.isArray(data))
|
|
19
27
|
return [data];
|
|
20
28
|
return data;
|
|
21
29
|
}
|
|
22
30
|
async function getLatestVersion(name, options = {}) {
|
|
23
|
-
const [data] = await
|
|
31
|
+
const [data] = await getLatestVersionBatch([name], options);
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
async function getVersionsBatch(packages, options = {}) {
|
|
35
|
+
const {
|
|
36
|
+
apiEndpoint = defaultOptions.apiEndpoint
|
|
37
|
+
} = options;
|
|
38
|
+
const data = await ofetch.$fetch(
|
|
39
|
+
`/versions/${packages.join("+")}`,
|
|
40
|
+
{
|
|
41
|
+
baseURL: apiEndpoint,
|
|
42
|
+
query: {
|
|
43
|
+
force: options.force ? true : void 0
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
if (!Array.isArray(data))
|
|
48
|
+
return [data];
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
async function getVersions(name, options = {}) {
|
|
52
|
+
const [data] = await getVersionsBatch([name], options);
|
|
24
53
|
return data;
|
|
25
54
|
}
|
|
26
55
|
|
|
27
56
|
exports.defaultOptions = defaultOptions;
|
|
28
57
|
exports.getLatestVersion = getLatestVersion;
|
|
29
|
-
exports.
|
|
58
|
+
exports.getLatestVersionBatch = getLatestVersionBatch;
|
|
59
|
+
exports.getVersions = getVersions;
|
|
60
|
+
exports.getVersionsBatch = getVersionsBatch;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
interface PackageManifest {
|
|
2
|
+
name: string;
|
|
3
|
+
distTags: Record<string, string> & {
|
|
4
|
+
latest: string;
|
|
5
|
+
};
|
|
6
|
+
versions: string[];
|
|
7
|
+
lastSynced: number;
|
|
8
|
+
}
|
|
1
9
|
interface ResolvedPackageVersion {
|
|
2
10
|
name: string;
|
|
3
11
|
version: string | null;
|
|
@@ -6,6 +14,7 @@ interface ResolvedPackageVersion {
|
|
|
6
14
|
}
|
|
7
15
|
|
|
8
16
|
interface ApiOptions {
|
|
17
|
+
force?: boolean;
|
|
9
18
|
apiEndpoint?: string;
|
|
10
19
|
}
|
|
11
20
|
declare const defaultOptions: {
|
|
@@ -16,7 +25,9 @@ declare const defaultOptions: {
|
|
|
16
25
|
*/
|
|
17
26
|
apiEndpoint: string;
|
|
18
27
|
};
|
|
19
|
-
declare function
|
|
28
|
+
declare function getLatestVersionBatch(packages: string[], options?: ApiOptions): Promise<ResolvedPackageVersion[]>;
|
|
20
29
|
declare function getLatestVersion(name: string, options?: ApiOptions): Promise<ResolvedPackageVersion>;
|
|
30
|
+
declare function getVersionsBatch(packages: string[], options?: ApiOptions): Promise<PackageManifest[]>;
|
|
31
|
+
declare function getVersions(name: string, options?: ApiOptions): Promise<PackageManifest>;
|
|
21
32
|
|
|
22
|
-
export { type ApiOptions, defaultOptions, getLatestVersion,
|
|
33
|
+
export { type ApiOptions, type PackageManifest, type ResolvedPackageVersion, defaultOptions, getLatestVersion, getLatestVersionBatch, getVersions, getVersionsBatch };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
interface PackageManifest {
|
|
2
|
+
name: string;
|
|
3
|
+
distTags: Record<string, string> & {
|
|
4
|
+
latest: string;
|
|
5
|
+
};
|
|
6
|
+
versions: string[];
|
|
7
|
+
lastSynced: number;
|
|
8
|
+
}
|
|
1
9
|
interface ResolvedPackageVersion {
|
|
2
10
|
name: string;
|
|
3
11
|
version: string | null;
|
|
@@ -6,6 +14,7 @@ interface ResolvedPackageVersion {
|
|
|
6
14
|
}
|
|
7
15
|
|
|
8
16
|
interface ApiOptions {
|
|
17
|
+
force?: boolean;
|
|
9
18
|
apiEndpoint?: string;
|
|
10
19
|
}
|
|
11
20
|
declare const defaultOptions: {
|
|
@@ -16,7 +25,9 @@ declare const defaultOptions: {
|
|
|
16
25
|
*/
|
|
17
26
|
apiEndpoint: string;
|
|
18
27
|
};
|
|
19
|
-
declare function
|
|
28
|
+
declare function getLatestVersionBatch(packages: string[], options?: ApiOptions): Promise<ResolvedPackageVersion[]>;
|
|
20
29
|
declare function getLatestVersion(name: string, options?: ApiOptions): Promise<ResolvedPackageVersion>;
|
|
30
|
+
declare function getVersionsBatch(packages: string[], options?: ApiOptions): Promise<PackageManifest[]>;
|
|
31
|
+
declare function getVersions(name: string, options?: ApiOptions): Promise<PackageManifest>;
|
|
21
32
|
|
|
22
|
-
export { type ApiOptions, defaultOptions, getLatestVersion,
|
|
33
|
+
export { type ApiOptions, type PackageManifest, type ResolvedPackageVersion, defaultOptions, getLatestVersion, getLatestVersionBatch, getVersions, getVersionsBatch };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
interface PackageManifest {
|
|
2
|
+
name: string;
|
|
3
|
+
distTags: Record<string, string> & {
|
|
4
|
+
latest: string;
|
|
5
|
+
};
|
|
6
|
+
versions: string[];
|
|
7
|
+
lastSynced: number;
|
|
8
|
+
}
|
|
1
9
|
interface ResolvedPackageVersion {
|
|
2
10
|
name: string;
|
|
3
11
|
version: string | null;
|
|
@@ -6,6 +14,7 @@ interface ResolvedPackageVersion {
|
|
|
6
14
|
}
|
|
7
15
|
|
|
8
16
|
interface ApiOptions {
|
|
17
|
+
force?: boolean;
|
|
9
18
|
apiEndpoint?: string;
|
|
10
19
|
}
|
|
11
20
|
declare const defaultOptions: {
|
|
@@ -16,7 +25,9 @@ declare const defaultOptions: {
|
|
|
16
25
|
*/
|
|
17
26
|
apiEndpoint: string;
|
|
18
27
|
};
|
|
19
|
-
declare function
|
|
28
|
+
declare function getLatestVersionBatch(packages: string[], options?: ApiOptions): Promise<ResolvedPackageVersion[]>;
|
|
20
29
|
declare function getLatestVersion(name: string, options?: ApiOptions): Promise<ResolvedPackageVersion>;
|
|
30
|
+
declare function getVersionsBatch(packages: string[], options?: ApiOptions): Promise<PackageManifest[]>;
|
|
31
|
+
declare function getVersions(name: string, options?: ApiOptions): Promise<PackageManifest>;
|
|
21
32
|
|
|
22
|
-
export { type ApiOptions, defaultOptions, getLatestVersion,
|
|
33
|
+
export { type ApiOptions, type PackageManifest, type ResolvedPackageVersion, defaultOptions, getLatestVersion, getLatestVersionBatch, getVersions, getVersionsBatch };
|
package/dist/index.mjs
CHANGED
|
@@ -8,18 +8,47 @@ const defaultOptions = {
|
|
|
8
8
|
*/
|
|
9
9
|
apiEndpoint: "https://npm.antfu.dev/"
|
|
10
10
|
};
|
|
11
|
-
async function
|
|
11
|
+
async function getLatestVersionBatch(packages, options = {}) {
|
|
12
12
|
const {
|
|
13
13
|
apiEndpoint = defaultOptions.apiEndpoint
|
|
14
14
|
} = options;
|
|
15
|
-
const data = await $fetch(
|
|
15
|
+
const data = await $fetch(
|
|
16
|
+
packages.join("+"),
|
|
17
|
+
{
|
|
18
|
+
baseURL: apiEndpoint,
|
|
19
|
+
query: {
|
|
20
|
+
force: options.force ? true : void 0
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
);
|
|
16
24
|
if (!Array.isArray(data))
|
|
17
25
|
return [data];
|
|
18
26
|
return data;
|
|
19
27
|
}
|
|
20
28
|
async function getLatestVersion(name, options = {}) {
|
|
21
|
-
const [data] = await
|
|
29
|
+
const [data] = await getLatestVersionBatch([name], options);
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
async function getVersionsBatch(packages, options = {}) {
|
|
33
|
+
const {
|
|
34
|
+
apiEndpoint = defaultOptions.apiEndpoint
|
|
35
|
+
} = options;
|
|
36
|
+
const data = await $fetch(
|
|
37
|
+
`/versions/${packages.join("+")}`,
|
|
38
|
+
{
|
|
39
|
+
baseURL: apiEndpoint,
|
|
40
|
+
query: {
|
|
41
|
+
force: options.force ? true : void 0
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
if (!Array.isArray(data))
|
|
46
|
+
return [data];
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
async function getVersions(name, options = {}) {
|
|
50
|
+
const [data] = await getVersionsBatch([name], options);
|
|
22
51
|
return data;
|
|
23
52
|
}
|
|
24
53
|
|
|
25
|
-
export { defaultOptions, getLatestVersion,
|
|
54
|
+
export { defaultOptions, getLatestVersion, getLatestVersionBatch, getVersions, getVersionsBatch };
|