export { default as ACKBAR } from '.cows/ackbar.cow'; export { default as APERTURE_BLANK } from '.cows/aperture-blank.cow'; export { default as APERTURE } from '.cows/aperture.cow'; export { default as ARMADILLO } from '.cows/armadillo.cow'; export { default as ATAT } from '.cows/atat.cow'; export { default as ATOM } from '.cows/atom.cow'; export { default as AWESOME_FACE } from '.cows/awesome-face.cow'; export { default as BANANA } from '.cows/banana.cow'; export { default as BEARFACE } from '.cows/bearface.cow'; export { default as BEES } from '.cows/bees.cow'; export { default as BILL_THE_CAT } from '.cows/bill-the-cat.cow'; export { default as BIOHAZARD } from '.cows/biohazard.cow'; export { default as BISHOP } from '.cows/bishop.cow'; export { default as BLACK_MESA } from '.cows/black-mesa.cow'; export { default as BOX } from '.cows/box.cow'; export { default as BROKEN_HEART } from '.cows/broken-heart.cow'; export { default as C3PO } from '.cows/C3PO.cow'; export { default as CAKE } from '.cows/cake.cow'; export { default as CAKE_WITH_CANDLES } from '.cows/cake-with-candles.cow'; export { default as CAT2 } from '.cows/cat2.cow'; export { default as CAT } from '.cows/cat.cow'; export { default as CATFENCE } from '.cows/catfence.cow'; export { default as CHARIZARDVICE } from '.cows/charizardvice.cow'; export { default as CHARLIE } from '.cows/charlie.cow'; export { default as CHESSMEN } from '.cows/chessmen.cow'; export { default as CHITO } from '.cows/chito.cow'; export { default as CLAW_ARM } from '.cows/claw-arm.cow'; export { default as CLIPPY } from '.cows/clippy.cow'; export { default as COMPANION_CUBE } from '.cows/companion-cube.cow'; export { default as COWFEE } from '.cows/cowfee.cow'; export { default as CTHULHU_MINI } from '.cows/cthulhu-mini.cow'; export { default as CUBE } from '.cows/cube.cow'; export { default as DALEK } from '.cows/dalek.cow'; export { default as DALEK_SHOOTING } from '.cows/dalek-shooting.cow'; export { default as DOCKER_WHALE } from '.cows/docker-whale.cow'; export { default as DOLPHIN } from '.cows/dolphin.cow'; export { default as EBI_FURAI } from '.cows/ebi_furai.cow'; export { default as ELEPHANT2 } from '.cows/elephant2.cow'; export { default as ELEPHANT } from '.cows/elephant.cow'; export { default as EXPLOSION } from '.cows/explosion.cow'; export { default as FAT_BANANA } from '.cows/fat-banana.cow'; export { default as FAT_COW } from '.cows/fat-cow.cow'; export { default as FENCE } from '.cows/fence.cow'; export { default as FIRE } from '.cows/fire.cow'; export { default as FOX } from '.cows/fox.cow'; export { default as GHOST } from '.cows/ghost.cow'; export { default as GLADOS } from '.cows/glados.cow'; export { default as GOAT2 } from '.cows/goat2.cow'; export { default as GOLDEN_EAGLE } from '.cows/golden-eagle.cow'; export { default as HAND } from '.cows/hand.cow'; export { default as HAPPY_WHALE } from '.cows/happy-whale.cow'; export { default as HIPPIE } from '.cows/hippie.cow'; export { default as HIYA } from '.cows/hiya.cow'; export { default as HIYOKO } from '.cows/hiyoko.cow'; export { default as HOMER } from '.cows/homer.cow'; export { default as HYPNO } from '.cows/hypno.cow'; export { default as IBM } from '.cows/ibm.cow'; export { default as IWASHI } from '.cows/iwashi.cow'; export { default as JELLYFISH } from '.cows/jellyfish.cow'; export { default as KARL_MARX } from '.cows/karl_marx.cow'; export { default as KILROY } from '.cows/kilroy.cow'; export { default as KING } from '.cows/king.cow'; export { default as KITTEN } from '.cows/kitten.cow'; export { default as KNIGHT } from '.cows/knight.cow'; export { default as LAMB2 } from '.cows/lamb2.cow'; export { default as LAMB } from '.cows/lamb.cow'; export { default as LIGHTBULB } from '.cows/lightbulb.cow'; export { default as LOBSTER } from '.cows/lobster.cow'; export { default as LOLLERSKATES } from '.cows/lollerskates.cow'; export { default as MAILCHIMP } from '.cows/mailchimp.cow'; export { default as MAZE_RUNNER } from '.cows/maze-runner.cow'; export { default as MINOTAUR } from '.cows/minotaur.cow'; export { default as MONA_LISA } from '.cows/mona-lisa.cow'; export { default as MOOGHIDJIRAH } from '.cows/mooghidjirah.cow'; export { default as MOOJIRA } from '.cows/moojira.cow'; export { default as MULE } from '.cows/mule.cow'; export { default as NYAN } from '.cows/nyan.cow'; export { default as OCTOPUS } from '.cows/octopus.cow'; export { default as OKAZU } from '.cows/okazu.cow'; export { default as OWL } from '.cows/owl.cow'; export { default as PAWN } from '.cows/pawn.cow'; export { default as PERIODIC_TABLE } from '.cows/periodic-table.cow'; export { default as PERSONALITY_SPHERE } from '.cows/personality-sphere.cow'; export { default as PINBALL_MACHINE } from '.cows/pinball-machine.cow'; export { default as PSYCHIATRICHELP2 } from '.cows/psychiatrichelp2.cow'; export { default as PSYCHIATRICHELP } from '.cows/psychiatrichelp.cow'; export { default as PTERODACTYL } from '.cows/pterodactyl.cow'; export { default as QUEEN } from '.cows/queen.cow'; export { default as R2_D2 } from '.cows/R2-D2.cow'; export { default as RADIO } from '.cows/radio.cow'; export { default as RENGE } from '.cows/renge.cow'; export { default as ROBOT } from '.cows/robot.cow'; export { default as ROBOTFINDSKITTEN } from '.cows/robotfindskitten.cow'; export { default as ROFLCOPTER } from '.cows/roflcopter.cow'; export { default as ROOK } from '.cows/rook.cow'; export { default as SACHIKO } from '.cows/sachiko.cow'; export { default as SEAHORSE_BIG } from '.cows/seahorse-big.cow'; export { default as SEAHORSE } from '.cows/seahorse.cow'; export { default as SHIKATO } from '.cows/shikato.cow'; export { default as SHRUG } from '.cows/shrug.cow'; export { default as SMILING_OCTOPUS } from '.cows/smiling-octopus.cow'; export { default as SNOOPY } from '.cows/snoopy.cow'; export { default as SNOOPYHOUSE } from '.cows/snoopyhouse.cow'; export { default as SNOOPYSLEEP } from '.cows/snoopysleep.cow'; export { default as SPIDERCOW } from '.cows/spidercow.cow'; export { default as SQUID } from '.cows/squid.cow'; export { default as SUDOWOODO } from '.cows/sudowoodo.cow'; export { default as TABLEFLIP } from '.cows/tableflip.cow'; export { default as TAXI } from '.cows/taxi.cow'; export { default as TEMPLATE } from '.cows/template.cow'; export { default as THREADER } from '.cows/threader.cow'; export { default as THREECUBES } from '.cows/threecubes.cow'; export { default as TOASTER } from '.cows/toaster.cow'; export { default as TORTOISE } from '.cows/tortoise.cow'; export { default as TUX_BIG } from '.cows/tux-big.cow'; export { default as TWEETY_BIRD } from '.cows/tweety-bird.cow'; export { default as USA } from '.cows/USA.cow'; export { default as VADER } from '.cows/vader.cow'; export { default as WEEPING_ANGEL } from '.cows/weeping-angel.cow'; export { default as WIZARD } from '.cows/wizard.cow'; export { default as WOOD } from '.cows/wood.cow'; export { default as WORLD } from '.cows/world.cow'; export { default as YASUNA_01 } from '.cows/yasuna_01.cow'; export { default as YASUNA_02 } from '.cows/yasuna_02.cow'; export { default as YASUNA_03A } from '.cows/yasuna_03a.cow'; export { default as YASUNA_03 } from '.cows/yasuna_03.cow'; export { default as YASUNA_04 } from '.cows/yasuna_04.cow'; export { default as YASUNA_05 } from '.cows/yasuna_05.cow'; export { default as YASUNA_06 } from '.cows/yasuna_06.cow'; export { default as YASUNA_07 } from '.cows/yasuna_07.cow'; export { default as YASUNA_08 } from '.cows/yasuna_08.cow'; export { default as YASUNA_09 } from '.cows/yasuna_09.cow'; export { default as YASUNA_10 } from '.cows/yasuna_10.cow'; export { default as YASUNA_11 } from '.cows/yasuna_11.cow'; export { default as YASUNA_12 } from '.cows/yasuna_12.cow'; export { default as YASUNA_13 } from '.cows/yasuna_13.cow'; export { default as YASUNA_14 } from '.cows/yasuna_14.cow'; export { default as YASUNA_16 } from '.cows/yasuna_16.cow'; export { default as YASUNA_17 } from '.cows/yasuna_17.cow'; export { default as YASUNA_18 } from '.cows/yasuna_18.cow'; export { default as YASUNA_19 } from '.cows/yasuna_19.cow'; export { default as YASUNA_20 } from '.cows/yasuna_20.cow'; export { default as YMD_UDON } from '.cows/ymd_udon.cow'; export { default as ZEN_NOH_MILK } from '.cows/zen-noh-milk.cow'; var ansiRegex = () => { const pattern = [ '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))' ].join('|'); return new RegExp(pattern, 'g'); }; var stripAnsi = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input; /* eslint-disable yoda */ var isFullwidthCodePoint = x => { if (Number.isNaN(x)) { return false; } // code points are derived from: // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt if ( x >= 0x1100 && ( x <= 0x115f || // Hangul Jamo x === 0x2329 || // LEFT-POINTING ANGLE BRACKET x === 0x232a || // RIGHT-POINTING ANGLE BRACKET // CJK Radicals Supplement .. Enclosed CJK Letters and Months (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A (0x3250 <= x && x <= 0x4dbf) || // CJK Unified Ideographs .. Yi Radicals (0x4e00 <= x && x <= 0xa4c6) || // Hangul Jamo Extended-A (0xa960 <= x && x <= 0xa97c) || // Hangul Syllables (0xac00 <= x && x <= 0xd7a3) || // CJK Compatibility Ideographs (0xf900 <= x && x <= 0xfaff) || // Vertical Forms (0xfe10 <= x && x <= 0xfe19) || // CJK Compatibility Forms .. Small Form Variants (0xfe30 <= x && x <= 0xfe6b) || // Halfwidth and Fullwidth Forms (0xff01 <= x && x <= 0xff60) || (0xffe0 <= x && x <= 0xffe6) || // Kana Supplement (0x1b000 <= x && x <= 0x1b001) || // Enclosed Ideographic Supplement (0x1f200 <= x && x <= 0x1f251) || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane (0x20000 <= x && x <= 0x3fffd) ) ) { return true; } return false; }; var stringWidth = str => { if (typeof str !== 'string' || str.length === 0) { return 0; } str = stripAnsi(str); let width = 0; for (let i = 0; i < str.length; i++) { const code = str.codePointAt(i); // Ignore control characters if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { continue; } // Ignore combining characters if (code >= 0x300 && code <= 0x36F) { continue; } // Surrogates if (code > 0xFFFF) { i++; } width += isFullwidthCodePoint(code) ? 2 : 1; } return width; }; var say = function (text, wrap) { var delimiters = { first : ["/", "\\"], middle : ["|", "|"], last : ["\\", "/"], only : ["<", ">"] }; return format(text, wrap, delimiters); }; var think = function (text, wrap) { var delimiters = { first : ["(", ")"], middle : ["(", ")"], last : ["(", ")"], only : ["(", ")"] }; return format(text, wrap, delimiters); }; function format (text, wrap, delimiters) { var lines = split(text, wrap); var maxLength = max(lines); var balloon; if (lines.length === 1) { balloon = [ " " + top(maxLength), delimiters.only[0] + " " + lines[0] + " " + delimiters.only[1], " " + bottom(maxLength) ]; } else { balloon = [" " + top(maxLength)]; for (var i = 0, len = lines.length; i < len; i += 1) { var delimiter; if (i === 0) { delimiter = delimiters.first; } else if (i === len - 1) { delimiter = delimiters.last; } else { delimiter = delimiters.middle; } balloon.push(delimiter[0] + " " + pad(lines[i], maxLength) + " " + delimiter[1]); } balloon.push(" " + bottom(maxLength)); } return balloon.join("\n"); } function split (text, wrap) { text = text.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, '').replace(/\t/g, ' '); var lines = []; if (!wrap) { lines = text.split("\n"); } else { var start = 0; while (start < text.length) { var nextNewLine = text.indexOf("\n", start); var wrapAt = Math.min(start + wrap, nextNewLine === -1 ? text.length : nextNewLine); lines.push(text.substring(start, wrapAt)); start = wrapAt; // Ignore next new line if (text.charAt(start) === "\n") { start += 1; } } } return lines; } function max (lines) { var max = 0; for (var i = 0, len = lines.length; i < len; i += 1) { if (stringWidth(lines[i]) > max) { max = stringWidth(lines[i]); } } return max; } function pad (text, length) { return text + (new Array(length - stringWidth(text) + 1)).join(" "); } function top (length) { return new Array(length + 3).join("_"); } function bottom (length) { return new Array(length + 3).join("-"); } var balloon = { say: say, think: think }; var replacer = function (cow, variables) { var eyes = escapeRe(variables.eyes); var eyeL = eyes.charAt(0); var eyeR = eyes.charAt(1); var tongue = escapeRe(variables.tongue); if (cow.indexOf("$the_cow") !== -1) { cow = extractTheCow(cow); } return cow .replace(/\$thoughts/g, variables.thoughts) .replace(/\$eyes/g, eyes) .replace(/\$tongue/g, tongue) .replace(/\$\{eyes\}/g, eyes) .replace(/\$eye/, eyeL) .replace(/\$eye/, eyeR) .replace(/\$\{tongue\}/g, tongue) ; }; /* * "$" dollar signs must be doubled before being used in a regex replace * This can occur in eyes or tongue. * For example: * * cowsay -g Moo! * * cowsay -e "\$\$" Moo! */ function escapeRe (s) { if (s && s.replace) { return s.replace(/\$/g, "$$$$"); } return s; } function extractTheCow (cow) { cow = cow.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''); var match = /\$the_cow\s*=\s*<<"*EOC"*;*\n([\s\S]+)\nEOC\n/.exec(cow); if (!match) { console.error("Cannot parse cow file\n", cow); return cow; } else { return match[1].replace(/\\{2}/g, "\\").replace(/\\@/g, "@").replace(/\\\$/g, "$"); } } var modes = { "b" : { eyes : "==", tongue : " " }, "d" : { eyes : "xx", tongue : "U " }, "g" : { eyes : "$$", tongue : " " }, "p" : { eyes : "@@", tongue : " " }, "s" : { eyes : "**", tongue : "U " }, "t" : { eyes : "--", tongue : " " }, "w" : { eyes : "OO", tongue : " " }, "y" : { eyes : "..", tongue : " " } }; var faces = function (options) { for (var mode in modes) { if (options[mode] === true) { return modes[mode]; } } return { eyes : options.e || "oo", tongue : options.T || " " }; }; var DEFAULT_COW = "$the_cow = <<\"EOC\";\n $thoughts ^__^\n $thoughts ($eyes)\\\\_______\n (__)\\\\ )\\\\/\\\\\n $tongue ||----w |\n || ||\nEOC\n"; var beavis_zen = "##\n## Beavis, with Zen philosophy removed.\n##\n$the_cow = < < > .---.\n $thoughts | \\\\ \\\\ - ~ ~ - / / |\n _____ ..-~ ~-..-~\n | | \\\\~~~\\\\.' `./~~~/\n --------- \\\\__/ \\\\__/\n .' $eye \\\\ / / \\\\ \" \n (_____, `._.' | } \\\\/~~~/\n `----. / } | / \\\\__/\n `-. | / | / `. ,~~|\n ~-.__| /_ - ~ ^| /- _ `..-‘ / \\\\ /\\\\\n | / | / ~-. `-/ _ \\\\/__\\\\\n |_____| |_____| ~ - . _ _ _ _ _>\nEOC\n"; var stimpy = "##\n## Stimpy!\n##\n$the_cow = <