Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

package-json

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

package-json - npm Package Compare versions

Comparing version 6.2.0 to 6.3.0

320

index.d.ts

@@ -0,165 +1,199 @@

/// <reference types="node"/>
import {Agent as HttpAgent} from 'http';
import {Agent as HttpsAgent} from 'https';
export interface Agents {
http?: HttpAgent;
https?: HttpsAgent;
declare class VersionNotFoundErrorClass extends Error {
readonly name: 'VersionNotFoundError';
constructor(packageName: string, version: string);
}
export interface Options {
/**
* Package version such as `1.0.0` or a [dist tag](https://docs.npmjs.com/cli/dist-tag) such as `latest`.
*
* The version can also be in any format supported by the [semver](https://github.com/npm/node-semver) module. For example:
* - `1` - Get the latest `1.x.x`
* - `1.2` - Get the latest `1.2.x`
* - `^1.2.3` - Get the latest `1.x.x` but at least `1.2.3`
* - `~1.2.3` - Get the latest `1.2.x` but at least `1.2.3`
*
* @default 'latest'
*/
readonly version?: string;
declare class PackageNotFoundErrorClass extends Error {
readonly name: 'PackageNotFoundError';
/**
* By default, only an abbreviated metadata object is returned for performance reasons. [Read more.](https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md)
*
* @default false
*/
readonly fullMetadata?: boolean;
constructor(packageName: string);
}
/**
* Return the [main entry](https://registry.npmjs.org/ava) containing all versions.
*
* @default false
*/
readonly allVersions?: boolean;
declare namespace packageJson {
interface Agents {
http?: HttpAgent;
https?: HttpsAgent;
}
/**
* The registry URL is by default inferred from the npm defaults and `.npmrc`. This is beneficial as `package-json` and any project using it will work just like npm. This option is **only** intended for internal tools. You should **not** use this option in reusable packages. Prefer just using `.npmrc` whenever possible.
*/
readonly registryUrl?: string;
interface Options {
/**
Package version such as `1.0.0` or a [dist tag](https://docs.npmjs.com/cli/dist-tag) such as `latest`.
/**
* Overwrite the `agent` option that is passed down to [`got`](https://github.com/sindresorhus/got#agent). This might be useful to add [proxy support](https://github.com/sindresorhus/got#proxies).
*/
readonly agent?: HttpAgent | HttpsAgent | Agents | false;
}
The version can also be in any format supported by the [semver](https://github.com/npm/node-semver) module. For example:
- `1` - Get the latest `1.x.x`
- `1.2` - Get the latest `1.2.x`
- `^1.2.3` - Get the latest `1.x.x` but at least `1.2.3`
- `~1.2.3` - Get the latest `1.2.x` but at least `1.2.3`
export interface FullMetadataOptions extends Options {
/**
* By default, only an abbreviated metadata object is returned for performance reasons. [Read more.](https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md)
*
* @default false
*/
readonly fullMetadata: true;
}
@default 'latest'
*/
readonly version?: string;
export interface DistTags {
readonly latest: string;
readonly [tagName: string]: string;
}
/**
By default, only an abbreviated metadata object is returned for performance reasons. [Read more.](https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md)
export interface AbbreviatedMetadata {
readonly 'dist-tags': DistTags;
readonly modified: string;
readonly name: string;
readonly versions: {readonly [version: string]: AbbreviatedVersion};
readonly [key: string]: unknown;
}
@default false
*/
readonly fullMetadata?: boolean;
export interface AbbreviatedVersion {
readonly name: string;
readonly version: string;
readonly dist: {
readonly shasum: string;
readonly tarball: string;
readonly integrity?: string;
};
readonly deprecated?: string;
readonly dependencies?: {readonly [name: string]: string};
readonly optionalDependencies?: {readonly [name: string]: string};
readonly devDependencies?: {readonly [name: string]: string};
readonly bundleDependencies?: {readonly [name: string]: string};
readonly peerDependencies?: {readonly [name: string]: string};
readonly bin?: {readonly [key: string]: string};
readonly directories?: ReadonlyArray<string>;
readonly engines?: {readonly [type: string]: string};
readonly _hasShrinkwrap?: boolean;
readonly [key: string]: unknown;
}
/**
Return the [main entry](https://registry.npmjs.org/ava) containing all versions.
export interface Person {
readonly name?: string;
readonly email?: string;
readonly url?: string;
}
@default false
*/
readonly allVersions?: boolean;
export interface HoistedData {
readonly author?: Person;
readonly bugs?:
| {readonly url: string; readonly email?: string}
| {readonly url?: string; readonly email: string};
readonly contributors?: ReadonlyArray<Person>;
readonly description?: string;
readonly homepage?: string;
readonly keywords?: ReadonlyArray<string>;
readonly license?: string;
readonly maintainers?: ReadonlyArray<Person>;
readonly readme?: string;
readonly readmeFilename?: string;
readonly repository?: {readonly type: string; readonly url: string};
}
/**
The registry URL is by default inferred from the npm defaults and `.npmrc`. This is beneficial as `package-json` and any project using it will work just like npm. This option is*only** intended for internal tools. You should*not** use this option in reusable packages. Prefer just using `.npmrc` whenever possible.
*/
readonly registryUrl?: string;
export interface FullMetadata extends AbbreviatedMetadata, HoistedData {
readonly _id: string;
readonly _rev: string;
readonly time: {
readonly created: string;
/**
Overwrite the `agent` option that is passed down to [`got`](https://github.com/sindresorhus/got#agent). This might be useful to add [proxy support](https://github.com/sindresorhus/got#proxies).
*/
readonly agent?: HttpAgent | HttpsAgent | Agents | false;
}
interface FullMetadataOptions extends Options {
/**
By default, only an abbreviated metadata object is returned for performance reasons. [Read more.](https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md)
@default false
*/
readonly fullMetadata: true;
}
interface DistTags {
readonly latest: string;
readonly [tagName: string]: string;
}
interface AbbreviatedMetadata {
readonly 'dist-tags': DistTags;
readonly modified: string;
readonly [version: string]: string;
};
readonly users?: {readonly [user: string]: boolean};
readonly versions: {readonly [version: string]: FullVersion};
readonly [key: string]: unknown;
}
readonly name: string;
readonly versions: {readonly [version: string]: AbbreviatedVersion};
readonly [key: string]: unknown;
}
export interface FullVersion extends AbbreviatedVersion, HoistedData {
readonly _id: string;
readonly _nodeVersion: string;
readonly _npmUser: string;
readonly _npmVersion: string;
readonly main?: string;
readonly files?: ReadonlyArray<string>;
readonly man?: ReadonlyArray<string>;
readonly scripts?: {readonly [scriptName: string]: string};
readonly gitHead?: string;
readonly types?: string;
readonly typings?: string;
readonly [key: string]: unknown;
}
interface AbbreviatedVersion {
readonly name: string;
readonly version: string;
readonly dist: {
readonly shasum: string;
readonly tarball: string;
readonly integrity?: string;
};
readonly deprecated?: string;
readonly dependencies?: {readonly [name: string]: string};
readonly optionalDependencies?: {readonly [name: string]: string};
readonly devDependencies?: {readonly [name: string]: string};
readonly bundleDependencies?: {readonly [name: string]: string};
readonly peerDependencies?: {readonly [name: string]: string};
readonly bin?: {readonly [key: string]: string};
readonly directories?: ReadonlyArray<string>;
readonly engines?: {readonly [type: string]: string};
readonly _hasShrinkwrap?: boolean;
readonly [key: string]: unknown;
}
/**
* Get metadata of a package from the npm registry.
*/
export default function packageJson(
packageName: string,
options: FullMetadataOptions
): Promise<FullMetadata>;
export default function packageJson(
packageName: string,
options?: Options
): Promise<AbbreviatedMetadata>;
interface Person {
readonly name?: string;
readonly email?: string;
readonly url?: string;
}
/**
* The error thrown when the given package name cannot be found.
*/
export class PackageNotFoundError extends Error {
readonly name: 'PackageNotFoundError'
interface HoistedData {
readonly author?: Person;
readonly bugs?:
| {readonly url: string; readonly email?: string}
| {readonly url?: string; readonly email: string};
readonly contributors?: ReadonlyArray<Person>;
readonly description?: string;
readonly homepage?: string;
readonly keywords?: ReadonlyArray<string>;
readonly license?: string;
readonly maintainers?: ReadonlyArray<Person>;
readonly readme?: string;
readonly readmeFilename?: string;
readonly repository?: {readonly type: string; readonly url: string};
}
interface FullMetadata extends AbbreviatedMetadata, HoistedData {
readonly _id: string;
readonly _rev: string;
readonly time: {
readonly created: string;
readonly modified: string;
readonly [version: string]: string;
};
readonly users?: {readonly [user: string]: boolean};
readonly versions: {readonly [version: string]: FullVersion};
readonly [key: string]: unknown;
}
interface FullVersion extends AbbreviatedVersion, HoistedData {
readonly _id: string;
readonly _nodeVersion: string;
readonly _npmUser: string;
readonly _npmVersion: string;
readonly main?: string;
readonly files?: ReadonlyArray<string>;
readonly man?: ReadonlyArray<string>;
readonly scripts?: {readonly [scriptName: string]: string};
readonly gitHead?: string;
readonly types?: string;
readonly typings?: string;
readonly [key: string]: unknown;
}
type VersionNotFoundError = VersionNotFoundErrorClass;
type PackageNotFoundError = PackageNotFoundErrorClass;
}
/**
* The error thrown when the given package version cannot be found.
*/
export class VersionNotFoundError extends Error {
readonly name: 'VersionNotFoundError'
}
declare const packageJson: {
/**
Get metadata of a package from the npm registry.
@param packageName - Name of the package.
@example
```
import packageJson = require('package-json');
(async () => {
console.log(await packageJson('ava'));
//=> {name: 'ava', ...}
// Also works with scoped packages
console.log(await packageJson('@sindresorhus/df'));
})();
```
*/
(packageName: string, options: packageJson.FullMetadataOptions): Promise<
packageJson.FullMetadata
>;
(packageName: string, options?: packageJson.Options): Promise<
packageJson.AbbreviatedMetadata
>;
/**
The error thrown when the given package version cannot be found.
*/
VersionNotFoundError: typeof VersionNotFoundErrorClass;
/**
The error thrown when the given package name cannot be found.
*/
PackageNotFoundError: typeof PackageNotFoundErrorClass;
// TODO: remove this in the next major version
default: typeof packageJson;
};
export = packageJson;

@@ -112,4 +112,5 @@ 'use strict';

module.exports = packageJson;
// TODO: remove this in the next major version
module.exports.default = packageJson;
module.exports.PackageNotFoundError = PackageNotFoundError;
module.exports.VersionNotFoundError = VersionNotFoundError;
{
"name": "package-json",
"version": "6.2.0",
"version": "6.3.0",
"description": "Get metadata of a package from the npm registry",

@@ -16,3 +16,3 @@ "license": "MIT",

"scripts": {
"test": "xo && ava && tsd-check"
"test": "xo && ava && tsd"
},

@@ -36,3 +36,3 @@ "files": [

"got": "^9.6.0",
"registry-auth-token": "^3.3.2",
"registry-auth-token": "^3.4.0",
"registry-url": "^5.0.0",

@@ -42,7 +42,8 @@ "semver": "^5.6.0"

"devDependencies": {
"ava": "^1.3.1",
"@types/node": "^11.12.2",
"ava": "^1.4.1",
"mock-private-registry": "^1.1.2",
"tsd-check": "^0.3.0",
"tsd": "^0.7.1",
"xo": "^0.24.0"
}
}
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