Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 3x 3x 3x 50x 16x 34x 20x 14x | import { spaceTrimNested } from './nesting/spaceTrimNested';
import { spaceTrimSimple } from './spaceTrimSimple';
/**
* Trims string from all 4 sides
*
* @see https://github.com/hejny/spacetrim#usage
*/
export function spaceTrim(content: string): string;
export function spaceTrim(
createContent: (block: (blockContent: string) => string) => string,
): string;
export async function spaceTrim(
createContent: (block: (blockContent: string) => string) => Promise<string>,
): Promise<string>;
export function spaceTrim(
contentOrcreateContent: any /* <- [0] */,
/*
Note: [0] Propper type instead of any is
| string
| ((
block: (blockContent: string) => string,
) => string | Promise<string>),
*/
): string | Promise<string> {
if (typeof contentOrcreateContent === 'string') {
return spaceTrimSimple(contentOrcreateContent);
} else if (typeof contentOrcreateContent === 'function') {
return spaceTrimNested(contentOrcreateContent);
} else {
throw new TypeError(
`spaceTrim expected string or function as first argument, but got ${typeof contentOrcreateContent}`,
);
}
}
/**
* TODO: Allow to change split char , char: RegExp = /\s/
*/
|