Skip to content

PurePath.withStem() method

pathlib-ts > PurePath > withStem

Returns a new path with the stem component changed.

Signature:

withStem(stem: string): PurePath;

Parameter

Type

Description

stem

string

New stem string.

Returns:

PurePath

A new path where the last component has the provided stem.

The Error class If the path has a suffix and stem is empty.

The current suffix is preserved. Passing an empty stem is only allowed when the path has no suffix, matching CPython behaviour.