Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*
patchcharm.js
=============
A patch to charm to add text scrolling capability
and also a fix to `erase()`.
*/
'use strict';
const charm = require('charm');
const Charm = charm.Charm;
function encode(xs) {
function bytes(s) {
if (typeof s === 'string') {
return s.split('').map(ord);
} else if (Array.isArray(s)) {
return s.reduce((acc, c) => acc.concat(bytes(c)), []);
}
}
return new Buffer([0x1b].concat(bytes(xs)));
}
function ord(c) {
return c.charCodeAt(0);
}