Skip to main content

Class: PieceLocation

The metadata class used for Pieces.

Constructors

new PieceLocation()

new PieceLocation(full: string, root: string): PieceLocation

Parameters

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

Returns

PieceLocation

Source

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

Properties

full

readonly full: string

The full path to the file.

Source

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


root

readonly root: string

The root directory the file was found from.

Source

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

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[]

Source

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


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

Source

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


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

Source

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


virtual

get virtual(): boolean

Whether the file is virtual or not.

Returns

boolean

Source

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

Methods

toJSON()

toJSON(): PieceLocationJSON

Defines the JSON.stringify behavior of this structure.

Returns

PieceLocationJSON

Source

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