UNPKG

tm-text

Version:

Trackmania and Maniaplanet text parser and formatter

10 lines (9 loc) 394 B
import { TOKEN } from '../utils/syntax'; import { stringifyTokens, tokenize } from './tokenize'; export const humanize = (input, options) => { const tokens = typeof input === 'string' ? tokenize(input, options) : input; return stringifyTokens(tokens.filter(({ kind }) => kind === TOKEN.NEWLINE || kind === TOKEN.TAB || kind === TOKEN.WORD)); }; export default humanize;