UNPKG

@runtimeverificationinc/tsk

Version:

TypeScript/JavaScript library for K Framework functionality

78 lines (77 loc) 3.88 kB
export type Hashable = any; export type FrozenRecord<T = any> = Readonly<Record<string, T>>; export declare function frozenRecord<T>(obj: Record<string, T>): FrozenRecord<T>; export declare function createFrozenRecord<T>(entries: Iterable<[string, T]>): FrozenRecord<T>; export declare function isFrozenRecord(obj: any): obj is FrozenRecord; export declare function checkType<T>(x: any, typ: new (...args: any[]) => T): T; export declare function raised(f: (...args: any[]) => any, ...args: any[]): Error | null; export declare function mergeWith<V>(f: (v1: V, v2: V) => V, d1: Record<string, V>, d2: Record<string, V>): Record<string, V>; export declare function notNone<T>(x: T | null | undefined): T; export declare function filterNone<V>(mapping: Record<string, V | null | undefined>): Record<string, V>; export declare class Chainable<P, R> { private _f; constructor(f: (p: P) => R); call(p: P): R; then<Q>(other: (r: R) => Q): Chainable<P, Q>; } export declare const chain: Chainable<any, any>; export declare function maybe<P, R>(f: (p: P) => R): (p: P | null | undefined) => R | null; export declare function findCommonItems<T>(l1: Iterable<T>, l2: Iterable<T>): [T[], T[], T[]]; export declare function intersperse<T>(iterable: Iterable<T>, delimiter: T): Generator<T>; export declare function unique<T>(iterable: Iterable<T>): Generator<T>; export declare function single<T>(iterable: Iterable<T>): T; export declare function some<T>(iterable: Iterable<T>): T | undefined; export declare function partition<T>(iterable: Iterable<T>, pred: (x: T, y: T) => boolean): T[][]; export declare function nonemptyStr(x: any): string; export declare function addIndent(indent: string, lines: Iterable<string>): string[]; export declare function isHexstring(x: string): boolean; export declare function hashStr(x: any): string; export declare function hashFile(filePath: string, chunkSize?: number): string; export declare function isHash(x: any): boolean; export declare function shortenHash(h: string, leftChars?: number, rightChars?: number): string; export declare function shortenHashes(value: any, leftChars?: number, rightChars?: number): any; export declare function deconstructShortHash(h: string): [string, string]; export declare function compareShortHashes(lhs: string, rhs: string): boolean; export declare function checkDirPath(dirPath: string): void; export declare function checkFilePath(filePath: string): void; export declare function ensureDirPath(dirPath: string): string; export declare function absOrRelTo(targetPath: string, basePath: string): string; export interface RunProcessOptions { check?: boolean; input?: string; pipeStdout?: boolean; pipeStderr?: boolean; cwd?: string; env?: Record<string, string>; execProcess?: boolean; } export interface CompletedProcess { args: string[]; returncode: number; stdout: string; stderr: string; } export declare function exitWithProcessError(error: { returncode: number; cmd: string[]; }): never; export declare function genFileTimestamp(comment?: string): string; export declare function checkAbsolutePath(filePath: string): void; export declare function checkRelativePath(filePath: string): void; export declare function tupleOf<T extends readonly unknown[]>(...funcs: { [K in keyof T]: (arg: any) => T[K]; }): (tuple: readonly unknown[]) => T; export declare function caseFunction<P, R>(cases: Array<[(p: P) => boolean, (p: P) => R]>, defaultCase?: (p: P) => R): (p: P) => R; export declare function none(_: any): void; /** * Recursively convert nested arrays and objects. * @param obj Object to convert * @returns Converted object */ export declare function deepConvert(obj: any): any; /** * Map an object to a Python-like string representation. * @param obj * @returns */ export declare function toPythonLikeString(obj: any): any;