Skip to content

PurePath.parts property

pathlib-ts > PurePath > parts

Returns the normalized path components as an array of strings.

Signature:

get parts(): string[];

The first element is the anchor when present. Use this when you need positional access to segments without re-parsing the representation.

const p = new PurePath('/usr/bin/python3')
p.parts // ['/', 'usr', 'bin', 'python3']
const p = new PureWindowsPath('c:/Program Files/PSF')
p.parts // ['c:\\', 'Program Files', 'PSF']