npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cowsay2

v2.0.4

Published

cowsay is a configurable talking cow

Downloads

234

Readme

cowsay

Build Status npm version

Modernized version of cowsay

This borrows from https://github.com/piuccio/cowsay. The cow files are the same content but instead of Perl heredoc text files they're ES6 template literals.

  • No reading files at runtime. Cows are declared as static compile-time dependencies.
  • Works the same whether client-side or server-side, and whether running from raw source for from a transpiled bundle.
  • Leveraging modern language features like destructuring and arrow functions.
  • Update to more modern Javascript style with two-space indents, single quoted strings, and const and let instead of var, as you might see on the Google or airbnb JS style guides.

Usage

See test/example.js for examples, but the basic usage is:

cowsay.say('What you want to say');

Or pass some options:

cowsay.say('Did you hear someting?', { mode: 'paranoid' });
cowsay.say('A quick brown fox jumped over the lazy dog', { W: 15 });
cowsay.think('I\'m looking sideways', { e: 'cc' });

Get a demo of all available cows with node test/cows.js, and get a demo of all available modes with node test/modes.js. Get a general test demonstrating line wrapping and whitespace handling at node test/example.js.

Importing cows

The above examples use the default cow file. You can import other cows and pass them in on the cow option. Do that one of two ways.

Import all cows, like:

let cows = require('cowsay2/cows');
cowsay('Gobble gobble', { cow: cows.turkey });

Or just import the cow you need (better for client-side bundles):

let cow = require('cowsay2/turkey');
cowsay('Gobble gobble', { cow });

Text options

  • n or nowrap: Don't do any line wrapping beyond whatever newlines occur in the provided text
  • W: Number of columns to wrap at (defaults to 40)

Examples

See some live example on RunKit at https://runkit.com/johnnysprinkles/5e28a5470e860e001a25123f

console.log(cowsay('hi'));
 ____
< hi >
 ----
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||


console.log(cowsay.say("The static String.raw() method is a tag function of template literals. This is similar to the r prefix in Python, or the @ prefix in C# for string literals. (But it is not identical; see explanations in this issue.) It's used to get the raw string form of template strings, that is, substitutions (e.g. \${foo}) are processed, but escapes (e.g. \n) are not."));
 __________________________________________
/ The static String.raw() method is a tag  \
| function of template literals. This is   |
| similar to the r prefix in Python, or    |
| the @ prefix in C# for string literals.  |
| (But it is not identical; see            |
| explanations in this issue.) It's used   |
| to get the raw string form of template   |
| strings, that is, substitutions (e.g.    |
| ${foo}) are processed, but escapes (e.g. |
\ ) are not.                               /
 ------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||


const whale = require('./cows/whale');
console.log(cowsay.say('Moo', { cow: whale }));
 _____
< Moo >
 -----
   \
    \
     \
                '-.
      .---._     \ .--'
    /       `-..__)  ,-'
   |    0           /
    --.__,   .__.,`
     `-.___'._\_.'

Related packages

https://github.com/piuccio/cowsay