« get me outta code hell

tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/util/wrap.js
diff options
context:
space:
mode:
Diffstat (limited to 'util/wrap.js')
-rw-r--r--util/wrap.js28
1 files changed, 0 insertions, 28 deletions
diff --git a/util/wrap.js b/util/wrap.js
deleted file mode 100644
index 71a1f1c..0000000
--- a/util/wrap.js
+++ /dev/null
@@ -1,28 +0,0 @@
-const ansi = require('./ansi')
-
-module.exports = function wrap(str, width) {
-  // Wraps a string into separate lines. Returns an array of strings, for
-  // each line of the text.
-
-  const lines = []
-  const words = str.split(' ')
-
-  let curLine = words[0]
-  let curColumns = ansi.measureColumns(curLine)
-
-  for (const word of words.slice(1)) {
-    const wordColumns = ansi.measureColumns(word)
-    if (curColumns + wordColumns > width) {
-      lines.push(curLine)
-      curLine = word
-      curColumns = wordColumns
-    } else {
-      curLine += ' ' + word
-      curColumns += 1 + wordColumns
-    }
-  }
-
-  lines.push(curLine)
-
-  return lines
-}