Skip to main content

Class: PieceLocation

The metadata class used for Pieces.

Constructors

constructor

โ€ข new PieceLocation(full, root)

Parameters

NameTypeDescription
fullstringThe full path to the file.
rootstringThe root directory the file was found from.

Defined in

projects/pieces/src/lib/structures/PieceLocation.ts:21

Properties

full

โ€ข Readonly full: string

The full path to the file.

Defined in

projects/pieces/src/lib/structures/PieceLocation.ts:10


root

โ€ข Readonly root: string

The root directory the file was found from.

Defined in

projects/pieces/src/lib/structures/PieceLocation.ts:15

Accessors

directories

โ€ข get directories(): string[]

The names of the directories that separate PieceLocation.root and PieceLocation.full.

example

const location = new PieceLocation(
'/usr/src/app/commands',
'/usr/src/app/commands/games/multiplayer/connect-four.js'
);

console.log(location.directories);
// โ†’ ['games', 'multiplayer']

Returns

string[]

Defined in

projects/pieces/src/lib/structures/PieceLocation.ts:56


name

โ€ข get name(): string

The name and extension of the file that was loaded, extracted from PieceLocation.full.

example

const location = new PieceLocation(
'/usr/src/app/commands',
'/usr/src/app/commands/games/multiplayer/connect-four.js'
);

console.log(location.name);
// โ†’ 'connect-four.js'

Returns

string

Defined in

projects/pieces/src/lib/structures/PieceLocation.ts:73


relative

โ€ข get relative(): string

The relative path between PieceLocation.root and PieceLocation.full.

example

const location = new PieceLocation(
'/usr/src/app/commands',
'/usr/src/app/commands/general/ping.js'
);

console.log(location.relative);
// โ†’ 'general/ping.js'

Returns

string

Defined in

projects/pieces/src/lib/structures/PieceLocation.ts:39

Methods

toJSON

โ–ธ toJSON(): PieceLocationJSON

Defines the JSON.stringify behavior of this structure.

Returns

PieceLocationJSON

Defined in

projects/pieces/src/lib/structures/PieceLocation.ts:80