@thi.ng/csv
Version:
Customizable, transducer-based CSV parser/object mapper and transformer
81 lines • 2.8 kB
TypeScript
import type { IObjectOf } from "@thi.ng/api";
import type { CellTransform } from "./api.js";
/**
* Cell parse value transform. Returns uppercased version of given input.
*
* @param x -
*/
export declare const upper: CellTransform;
/**
* Cell parse value transform. Returns lowercased version of given input.
*
* @param x -
*/
export declare const lower: CellTransform;
/**
* Higher-order cell parse value transform. Attempts to parse given input as
* JSON and returns it. Returns configured `defaultVal` in case of parse error.
*
* @param defaultVal
*/
export declare const json: (defaultVal?: any) => CellTransform;
/**
* Higher-order cell parse value transform. Attempts to parse cell values as
* floating point number or returns `defaultVal` if not possible.
*
* @param defaultVal -
*/
export declare const float: (defaultVal?: number) => CellTransform;
/**
* Higher-order cell parse value transform. Attempts to parse cell values as
* integer or returns `defaultVal` if not possible.
*
* @param defaultVal -
*/
export declare const int: (defaultVal?: number) => CellTransform;
/**
* Higher-order cell parse value transform. Attempts to parse cell values as
* hexadecimal integer or returns `defaultVal` if not possible.
*
* @param defaultVal -
*/
export declare const hex: (defaultVal?: number) => CellTransform;
export declare const percent: CellTransform;
/**
* Higher-order cell parse value transform. Attempts to parse cell values as
* Unix epoch/timestamp or returns `defaultVal` if not possible.
*
* @param defaultVal -
*/
export declare const epoch: (defaultVal?: number) => CellTransform;
/**
* Higher-order cell parse value transform. Attempts to parse cell values as JS
* `Date` instance or returns `defaultVal` if not possible.
*
* @param defaultVal -
*/
export declare const date: (defaultVal?: Date) => CellTransform;
/**
* Cell parse value transform. Attempts to parse cell values as JS `URL`
* instances.
*
* @param x -
*/
export declare const url: CellTransform;
/**
* Cell parse value transform. Accepts an object of mappings with original cell
* values as keys which are then mapped to arbitrary new values in an enum like
* fashion.
*
* @param mappings
* @param defaultVal
*/
export declare const oneOf: <T>(mappings: IObjectOf<T>, defaultVal: T) => CellTransform;
export declare const zeroPad: (digits: number) => (x: any, length?: number) => string;
export declare const formatFloat: (prec?: number) => (x: number) => string;
/**
* Higher order cell value formatter. Takes normalized values and formats them
* as percentage with given `precision` (number of fractional digits).
*/
export declare const formatPercent: (prec?: number) => import("@thi.ng/strings").Stringer<number>;
//# sourceMappingURL=transforms.d.ts.map