inlinable-runtime
Version:
JavaScript code inlining runtime utilities
38 lines (37 loc) • 1.39 kB
TypeScript
/** A candidate for inlining. */
export type Inlinable<V> = (ctx: InlinableContext) => V;
/** Inlining utilities. */
export interface InlinableContext {
readonly enclosing: (fp: string, opts?: EnclosingOptions) => EnclosingPackage;
readonly readTextFile: (fp: string) => string;
readonly readJsonFile: <V = any>(fp: string, opts?: ReadJsonFileOptions) => V;
}
/**
* Returns the deepest root containing the first argument, if any. A root is
* defined as a parent folder of one of the folders passed in as second argument
* (defaulting to `defaultRootFolders`).
*/
export declare function enclosingRoot(args: {
readonly path: string;
readonly separator: string;
readonly rootFolders?: ReadonlyArray<string>;
}): string | undefined;
export interface EnclosingOptions {
/** Defaults to `defaultRootFolders`. */
readonly rootFolders?: ReadonlyArray<string>;
/** Defaults to `defaultResourceFolder`. */
readonly resourceFolder?: string;
}
export declare const defaultRootFolders: ReadonlyArray<string>;
export declare const defaultResourceFolder = "resources";
export interface ReadJsonFileOptions {
readonly fields?: ReadonlyArray<string>;
}
export interface EnclosingPackage {
metadataPath(): string;
resourcePath(...comps: string[]): string;
metadata(): {
readonly name: string;
readonly version?: string;
};
}