Skip to content

Instantly share code, notes, and snippets.

@hota1024
Created August 23, 2018 08:55
Show Gist options
  • Save hota1024/ba8f3b43fbae9ebdaeae2e5d279e69f3 to your computer and use it in GitHub Desktop.
Save hota1024/ba8f3b43fbae9ebdaeae2e5d279e69f3 to your computer and use it in GitHub Desktop.
Boxol.js
const Boxol = {
Marked (data) {
let result = ''
let maxLength = 0
data.forEach(line => {
maxLength = Math.max(maxLength, line.length)
console.log(maxLength)
})
result += '╭' + '─'.repeat(maxLength) + '╮\n'
data.forEach(line => {
let afterPad = ' '.repeat(maxLength - line.length)
result += '|' + line + afterPad + '|\n'
})
result += '╰' + '─'.repeat(maxLength) + '╯\n'
return result
},
Mark (data) {
console.log(this.Marked(data))
}
}
export default Boxol
@hota1024
Copy link
Author

Boxol.Mark([
  'Hell world',
  'abcdefghijklmnopqrtstuvwxyz'
])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment