From d4c9dc3197a82bd731db8d2dd969af1534c0dc6b Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Mon, 25 Apr 2016 16:47:15 +0200 Subject: [PATCH] Add type definitions for wrap-ansi (https://www.npmjs.com/package/wrap-ansi) (#9090) --- wrap-ansi/wrap-ansi-tests.ts | 8 ++++++++ wrap-ansi/wrap-ansi.d.ts | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 wrap-ansi/wrap-ansi-tests.ts create mode 100644 wrap-ansi/wrap-ansi.d.ts 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; +}