How to use charm - 3 common examples

To help you get started, we’ve selected a few charm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github testem / testem / lib / reporters / dev / patchcharm.js View on Github external
/*

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);
}

charm

ansi control sequences for terminal cursor hopping and colors

MIT
Latest version published 7 years ago

Package Health Score

71 / 100
Full package analysis

Popular charm functions