Skip to main content

ModulePath

An immutable class for operating on Node.js module IDs, names, and paths.

Implements

Index

Constructors

constructor

Methods

append

  • Append path parts to the end of the current path and return a new ModulePath instance.

hasScope

  • hasScope(): boolean
  • Return true if the module is scoped within a private namespace (starts with @).

name

  • name(withoutScope?: boolean): string
  • Return the module name without any trailing import paths, or optionally without the private scope.

path

  • path(): string
  • Return the current module path as a normalized string.

scope

  • scope(): null | string
  • Return the private scope with leading @, or null if not defined.

toJSON

  • toJSON(): string

toString

  • toString(): string

staticcreate

  • Create and return a new ModulePath instance.

staticpath

  • Convert a module path-like value to a formatted module path string.