Skip to main content
Module

x/cliffy/table/consume_words.ts>consumeChars

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Extremely Popular
Latest
function consumeChars
import { consumeChars } from "https://deno.land/x/cliffy@v1.0.0-rc.4/table/consume_words.ts";

Consumes the maximum amount of chars from a string which is not longer than given length, ignoring ANSI codes when calculating the length. This function returns at least one char.

import { consumeChars } from "./consume_words.ts";

const str = consumeChars(9, "\x1b[31mThis is an example."); // returns: "\x1b[31mThis is a"

Parameters

length: number

The maximum length of the returned string.

content: string

The content from which the string should be consumed.

Returns

string