« get me outta code hell

Add isCaselessLetter util function - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-05-30 23:55:12 -0300
committerFlorrie <towerofnix@gmail.com>2018-05-30 23:55:12 -0300
commitf782f7395cd287d4767c1f3ffd20a72a51007595 (patch)
treeffe4c62ca1c38a72121509baeb68d344fe999312
parent581c8db27bc25c74b02a1b29d795c847118c6234 (diff)
Add isCaselessLetter util function
-rw-r--r--util/telchars.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/util/telchars.js b/util/telchars.js
index 6908600..b39e17b 100644
--- a/util/telchars.js
+++ b/util/telchars.js
@@ -35,6 +35,8 @@ const telchars = {
   isShiftDown: buf => buf[0] === 0x1b && compareBufStr(buf.slice(1), '[1;2B'),
   isShiftRight: buf => buf[0] === 0x1b && compareBufStr(buf.slice(1), '[1;2C'),
   isShiftLeft: buf => buf[0] === 0x1b && compareBufStr(buf.slice(1), '[1;2D'),
+
+  isCaselessLetter: (buf, letter) => compareBufStr(buf, letter.toLowerCase()) || compareBufStr(buf, letter.toUpperCase()),
 }
 
 module.exports = telchars