diff options
Diffstat (limited to 'node_modules/string-length/index.js')
-rw-r--r-- | node_modules/string-length/index.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/node_modules/string-length/index.js b/node_modules/string-length/index.js new file mode 100644 index 0000000..c2589a2 --- /dev/null +++ b/node_modules/string-length/index.js @@ -0,0 +1,19 @@ +'use strict'; +const stripAnsi = require('strip-ansi'); +const charRegex = require('char-regex'); + +const stringLength = string => { + if (string === '') { + return 0; + } + + const strippedString = stripAnsi(string); + + if (strippedString === '') { + return 0; + } + + return strippedString.match(charRegex()).length; +}; + +module.exports = stringLength; |