Rush StackShopBlogEvents
Skip to main content

Home > @rushstack/node-core-library > PackageName

PackageName class

Provides basic operations for validating and manipulating NPM package names such as my-package or @scope/my-package.

Signature:

export declare class PackageName 

Remarks

This is the default implementation of PackageNameParser, exposed as a convenient static class. If you need to configure the parsing rules, use PackageNameParser instead.

Methods

Method

Modifiers

Description

combineParts(scope, unscopedName)

static

Combines an optional package scope with an unscoped root name.

getScope(packageName)

static

The parsed NPM scope, or an empty string if there was no scope. The scope value will always include the at-sign.

getUnscopedName(packageName)

static

The parsed NPM package name without the scope.

isValidName(packageName)

static

Returns true if the specified package name is valid, or false otherwise.

parse(packageName)

static

Same as PackageName.tryParse(), except this throws an exception if the input cannot be parsed.

tryParse(packageName)

static

This attempts to parse a package name that may include a scope component. The packageName must not be an empty string.

validate(packageName)

static

Throws an exception if the specified name is not a valid package name. The packageName must not be an empty string.