UNPKG

@freeword/meta

Version:

Meta package for Freeword: exports all core types, constants, and utilities from the src/ directory.

92 lines 3.1 kB
import type { AnyBag } from '../types/index.ts'; type StringMaybe = string | undefined | null; export declare function snipjoin(arr: any[], { max, joiner, stringifier, yadayada, shave, ...rest }?: toSentenceOpts): string; export declare function briefSentence(arr: readonly any[], briefSentenceOpts?: toSentenceOpts): string; export interface toSentenceOpts { joiner?: StringMaybe; conj?: string; lastJoiner?: StringMaybe; pairJoiner?: StringMaybe; max?: number; min?: number; shave?: number; yadayada?: string; whoa?: string; empty?: string; stringifier?: (val: any) => string; } export declare function toSentence(arr: any[] | AnyBag, opts?: toSentenceOpts): string; declare const ManyAndLastKeys: readonly ["void", "solo", "pair", "many", "xnil", "xone", "xtwo", "xtra"]; type ManyAndLastFrames<VT = any> = ({ iam: 'void'; } | { iam: 'solo'; first: VT; } | { iam: 'pair'; first: VT; last: VT; } | { iam: 'many'; many: VT[]; last: VT; } | { iam: 'xnil'; } | { iam: 'xone'; first: VT; } | { iam: 'xtwo'; first: VT; last: VT; } | { iam: 'xtra'; many: VT[]; last: VT; }); export interface ManyAndLastMerged<VT = any> { iam: typeof ManyAndLastKeys[number]; many?: VT[] | undefined; first?: VT | undefined; last?: VT | undefined; } export declare function manyAndLast<VT = any>(clxn: VT[], { max, shave }?: { max?: number; shave?: number; }): ManyAndLastFrames<VT>; export interface SomeManyAndLastFrame<VT = any> extends ManyAndLastMerged<VT> { /** the shortened list (first, many, and last) with no joiners inserted; if shaved, there might be fewer than `max` */ some: VT[]; /** the body (first/many), including the last if no reduction was done */ body: VT[]; /** if reduced, an array with the 'extra' element */ tail: VT[]; /** the reduced number of elements */ postsize: number; /** true if there was a 'last' element to ellipsize */ ellipsize: boolean; } export declare function someManyAndLast<VT = any>(clxn: VT[], opts?: { max?: number; shave?: number; }): SomeManyAndLastFrame<VT>; export declare function hardcapList<VT = any>(clxn: VT[], opts?: { max?: number; shave?: number; yadayada?: string; }): VT[]; export interface shortenOpts { tail?: string; } export declare function shortenWithEllipsis(str: string, maxlen?: number): string; export declare function shorten(str: string, maxlen?: number, opts?: shortenOpts): string; export declare function smush(sep: string, ...rest: (string | undefined | null | number)[]): string; export declare function qt(val: string): string; export declare function dqt(val: string): string; export declare function qtc(val: string): string; export declare function comma(val: string): string; export declare function indent(text: string, by?: number | string): string; /** remove the leading indent from each line of the text */ export declare function dedent(text: string, by?: number): string; export {}; //# sourceMappingURL=StringUtils.d.ts.map