UNPKG

@darkobits/lolcatjs

Version:

Fork of https://github.com/robertmarsal/lolcatjs.

99 lines (98 loc) 2.31 kB
import streamz from 'stream'; import iCanHazThruStream from 'through'; import { idk, newp, MuhLolcatOpts } from '../etc/typez'; export default class MakinUrText { /** * It's not nice to tamper with globals so we make a speshul chalk just for * us. */ private readonly _muhChalk; /** * Cursors for teh streams we get piped to. */ private readonly _cursorz; /** * Rainbow frequency. */ private readonly _freq; /** * Rainbow spread. */ private readonly _spread; /** * Animate ur linez? */ private readonly _animate; /** * Makes animation go faster. */ private readonly _speed; /** * How much duration for animating. */ private readonly _duration; /** * So we only anime 1 of ur linez at a tiem. */ private readonly _wait4Turn; /** * Rainbow seed. */ private _seed; /** * Keeps all the loltext we make. */ private _loltext; /** * Duplex stream to which colorized output is written. This stream may also be * piped into another writable stream, such as process.stdout. */ stream: iCanHazThruStream.ThroughStream; constructor({ seed, freq, spread, animate, speed, duration, force }?: MuhLolcatOpts); /** * Makes an strem for us. */ private makeStreamPlz; /** * Brings ur cursor back 4 u. */ private yesCursor; /** * Hides ur cursor 4 u. */ private noCursor; /** * Turns text into -----> !loltext!. */ private colorizeUrLine; /** * Makes ur linez animated. FTW! */ private animateUrLine; /** * Makes 1 line of loltext 4 u. * * If ur wantin animated text can does that too. */ private makeLine; /** * Lets u lol ur strings. */ fromString(urString?: string): void; /** * Lets u lol ur streams. */ fromStream(urStream: streamz.Readable): Promise<newp>; /** * Lets u lol ur filez. */ fromFile(urFile: idk): Promise<newp>; /** * Lets u use ur loltext. */ toString(): string; /** * 4 when u wants 2 jus lulz a string orly quick. */ static fromString(urString: string, urOpshunz?: MuhLolcatOpts): string; }