Skip to content

Commit

Permalink
compatibility updates
Browse files Browse the repository at this point in the history
  • Loading branch information
njhoffman committed Dec 24, 2021
1 parent 5cb6515 commit 33c942e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -10,8 +10,8 @@ const {
truncateString
} = require('./utils')

const wcwidth = function(str) {
return getWCwidth(stripAnsi(str))
const wcwidth = async function(str) {
return getWCwidth(await stripAnsi(str))
}

const DEFAULT_HEADING_TRANSFORM = key => key.toUpperCase()
Expand Down
10 changes: 10 additions & 0 deletions strip-ansi.js
@@ -0,0 +1,10 @@
// const ansiRegex = require('ansi-regex');

const stripAnsi = async(string) => {
const { default: ansiRegex } = await import('ansi-regex');
if (typeof string !== 'string') {
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
}

return string.replace(ansiRegex(), '');
}
10 changes: 10 additions & 0 deletions width.js
@@ -0,0 +1,10 @@
var wcwidth = require('./wcwidth')

const getWidth = async(string) => {
const { default: stripAnsi } = await import('ansi-regex');
return wcwidth(stripAnsi(str))
}

module.exports = function(str) {

}

0 comments on commit 33c942e

Please sign in to comment.