Skip to main content

ArkType

Helper functions having to do with getting the directory of the calling function and getting the directory of the package root.

They are based on functions from the @arktype/fs library.

Functions

dirOfCaller()

function dirOfCaller(upStackBy): string

Helper function to get the directory of a calling function.

This is re-implemented from the "@arktype/fs" package so that we can have an arbitrary upStackBy position.

Parameters

ParameterTypeDefault valueDescription
upStackBynumber1Optional. How far to look up the stack. Default is 1.

Returns

string

See

https://github.com/arktypeio/arktype/blob/main/ark/fs/fs.ts

Defined in

packages/complete-node/src/functions/arkType.ts:28


fileOfCaller()

function fileOfCaller(upStackBy): string

Helper function to get the file of a calling function.

This is re-implemented from the "@arktype/fs" package so that we can have an arbitrary upStackBy position.

We also fix a bug on Windows with an uncapitalized drive letter.

Parameters

ParameterTypeDefault valueDescription
upStackBynumber1Optional. How far to look up the stack. Default is 1.

Returns

string

See

https://github.com/arktypeio/arktype/blob/main/ark/fs/fs.ts

Defined in

packages/complete-node/src/functions/arkType.ts:44


findPackageRoot()

function findPackageRoot(fromDir?): string

Helper function to find the closest "package.json" file to the calling function.

This is re-implemented from the "@arktype/fs" package so that we can throw an error if the package root is not found.

Parameters

ParameterTypeDescription
fromDir?stringOptional. The directory to start looking for the "package.json" file. Default is the directory of the calling function.

Returns

string

See

https://github.com/arktypeio/arktype/blob/main/ark/fs/fs.ts

Defined in

packages/complete-node/src/functions/arkType.ts:66