diff --git a/wrap-ansi/wrap-ansi-tests.ts b/wrap-ansi/wrap-ansi-tests.ts new file mode 100644 index 0000000000..8fb08dfd8b --- /dev/null +++ b/wrap-ansi/wrap-ansi-tests.ts @@ -0,0 +1,8 @@ +/// + +import wrapAnsi = require("wrap-ansi"); + +wrapAnsi("input", 80) === "output"; +wrapAnsi("input", 80, {}) === "output"; +wrapAnsi("input", 80, { hard: true }) === "output"; +wrapAnsi("input", 80, { hard: false }) === "output"; diff --git a/wrap-ansi/wrap-ansi.d.ts b/wrap-ansi/wrap-ansi.d.ts new file mode 100644 index 0000000000..79a63abc78 --- /dev/null +++ b/wrap-ansi/wrap-ansi.d.ts @@ -0,0 +1,20 @@ +// Type definitions for wrap-ansi v2.0.0 +// Project: https://www.npmjs.com/package/wrap-ansi +// Definitions by: Klaus Reimer +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "wrap-ansi" { + /** + * Wrap words to the specified column width. + * + * @param input String with ANSI escape codes. Like one styled by chalk. + * @param columns Number of columns to wrap the text to. + * @param options By default the wrap is soft, meaning long words may extend past the column width. Setting + * this to true will make it hard wrap at the column width. + */ + function wrapAnsi(input: string, columns: number, options?: { hard?: boolean }): string; + + namespace wrapAnsi {} + + export = wrapAnsi; +}