@backtrace/sourcemap-tools
Version:
Backtrace-JavaScript sourcemap tools
24 lines (23 loc) • 2.02 kB
TypeScript
import fs from 'fs';
import { Readable, Writable } from 'stream';
import { LogLevel, Logger } from '../Logger';
import { Result, ResultPromise } from '../models/Result';
export type ContentFile = readonly [content: string, path: string];
export type StreamFile = readonly [stream: Readable, path: string];
export declare function readFile(file: string): ResultPromise<string, string>;
export declare function writeFile(path: string): (content: string) => Promise<import("../models/Result").ResultOk<string> | import("../models/Result").ResultErr<string>>;
export declare function statFile(path: string): Promise<import("../models/Result").ResultErr<string> | import("../models/Result").ResultOk<fs.Stats>>;
export declare function createWriteStream(path: string): import("../models/Result").ResultErr<string> | import("../models/Result").ResultOk<fs.WriteStream>;
export declare function pipeStream(readable: Pick<Readable, 'pipe'>): (writable: Writable) => Writable;
export declare function writeStream(file: StreamFile): Promise<import("../models/Result").ResultErr<string> | import("../models/Result").ResultOk<StreamFile>>;
export declare function parseJSON<T>(content: string): Result<T, string>;
export declare function pass<T>(t: T): T;
export declare function failIfEmpty<E>(error: E): <T>(t: T[]) => Result<T[], E>;
export declare function map<T, B>(fn: (t: T) => B): (t: T[]) => B[];
export declare function flatMap<T, B>(fn: (t: T) => B[]): (t: T[]) => B[];
export declare function mapAsync<T, B>(fn: (t: T) => B | Promise<B>): (t: T[]) => Promise<(Awaited<B> | Awaited<B>)[]>;
export declare function filter<T>(fn: (t: T) => boolean): (t: T[]) => T[];
export declare function filterAsync<T>(fn: (t: T) => boolean | Promise<boolean>): (t: T[]) => Promise<T[]>;
export declare function log(logger: Logger, level: LogLevel): <T>(message: string | ((t: T) => string)) => (t: T) => T;
export declare function inspect<T>(fn: (t: T) => unknown): (t: T) => T;
export declare function not(value: boolean): boolean;