IDirectory Interface

Packages > @fluidframework/map > IDirectory

Interface describing actions on a directory.

Signature:

export interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryEvents> 

Extends: Map<string, any>, IEventProvider<IDirectoryEvents>

Remarks

When used as a Map, operates on its keys.

Properties

List of properties of this interface
Property Type Description
absolutePath string The absolute path of the directory.

Methods

List of methods of this class
Method Description
createSubDirectory(subdirName) Creates an IDirectory child of this IDirectory, or retrieves the existing IDirectory child if one with the same name already exists.
deleteSubDirectory(subdirName) Deletes an IDirectory child of this IDirectory, if it exists, along with all descendent keys and directories.
get(key) Retrieves the value stored at the given key from the directory.
getSubDirectory(subdirName) Gets an IDirectory child of this IDirectory, if it exists.
getWorkingDirectory(relativePath) Get an IDirectory within the directory, in order to use relative paths from that location.
hasSubDirectory(subdirName) Checks whether this directory has a child directory with the given name.
set(key, value) Sets the value stored at key to the provided value.
subdirectories() Gets an iterator over the IDirectory children of this IDirectory.
wait(key) A form of get except it will only resolve the promise once the key exists in the directory.

Events

absolutePath

The absolute path of the directory.

Signature:

readonly absolutePath: string;

Methods

createSubDirectory

Creates an IDirectory child of this IDirectory, or retrieves the existing IDirectory child if one with the same name already exists.

Signature:

createSubDirectory(subdirName: string): IDirectory;

Parameters

List of parameters
Parameter Type Description
subdirName string Name of the new child directory to create

Returns:

IDirectory

The IDirectory child that was created or retrieved

deleteSubDirectory

Deletes an IDirectory child of this IDirectory, if it exists, along with all descendent keys and directories.

Signature:

deleteSubDirectory(subdirName: string): boolean;

Parameters

List of parameters
Parameter Type Description
subdirName string Name of the child directory to delete

Returns:

boolean

True if the IDirectory existed and was deleted, false if it did not exist

get

Retrieves the value stored at the given key from the directory.

Signature:

get<T = any>(key: string): T | undefined;

Parameters

List of parameters
Parameter Type Description
key string Key to retrieve from

Returns:

T | undefined

The stored value, or undefined if the key is not set

getSubDirectory

Gets an IDirectory child of this IDirectory, if it exists.

Signature:

getSubDirectory(subdirName: string): IDirectory | undefined;

Parameters

List of parameters
Parameter Type Description
subdirName string Name of the child directory to get

Returns:

IDirectory | undefined

The requested IDirectory

getWorkingDirectory

Get an IDirectory within the directory, in order to use relative paths from that location.

Signature:

getWorkingDirectory(relativePath: string): IDirectory | undefined;

Parameters

List of parameters
Parameter Type Description
relativePath string Path of the IDirectory to get, relative to this IDirectory

Returns:

IDirectory | undefined

The requested IDirectory

hasSubDirectory

Checks whether this directory has a child directory with the given name.

Signature:

hasSubDirectory(subdirName: string): boolean;

Parameters

List of parameters
Parameter Type Description
subdirName string Name of the child directory to check

Returns:

boolean

True if it exists, false otherwise

set

Sets the value stored at key to the provided value.

Signature:

set<T = any>(key: string, value: T): this;

Parameters

List of parameters
Parameter Type Description
key string Key to set at
value T Value to set

Returns:

this

The IDirectory itself

subdirectories

Gets an iterator over the IDirectory children of this IDirectory.

Signature:

subdirectories(): IterableIterator<[string, IDirectory]>;

Returns:

IterableIterator<[string, IDirectory]>

The IDirectory iterator

wait

A form of get except it will only resolve the promise once the key exists in the directory.

Signature:

wait<T = any>(key: string): Promise<T>;

Parameters

List of parameters
Parameter Type Description
key string Key to retrieve from

Returns:

Promise<T>

The stored value once available