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

tfunk

v4.0.0

Published

Multi-colour console output from chalk with added awesome

Downloads

1,376,668

Readme

##tfunk Build Status

Multi-colour console output from Chalk with added awesome.

by @shakyshane & @AydinHassan

tfunk

##Install

npm install tfunk

##Usage

Syntax rules:

{ <color> : YOUR STRING }

Example

{blue:This is a blue line}

} is optional

{blue:This is a blue line <- Perfectly valid

##Usage

var tFunk = require("tfunk");

console.log( tfunk("{cyan:tFunk terminal colours") )

// => tFunk terminal colours

Or get a custom compiler with a set prefix:

var compiler = require("tfunk").Compiler({
    prefix: "[{magenta:tFunk}]"
});

console.log( compiler.compile("tFunk is awesome") );
console.log( compiler.compile("don't you think?") );

// => [tFunk] tFunk is awesome
// => [tFunk] don't you think?

Define your own syntax

You can define your own methods, they receive the string section as the first parameter & have access to the compiler through this.compile() keyword.

var compiler = require("tfunk").Compiler({
    "warn": function(string) {
        return this.compile("{red:WARNING:" + string);
    }
});

Now you can use warn anywhere you like.

console.log( compiler.compile("{warn: Could not file your config file...") );

// => WARNING: Could not file your config file...

##Examples

Here are some comparisons to chalk, to help you understand how to use tFunk.

###Single Colours

// chalk
console.log( chalk.red("This has a single colour") );

// tFunk
console.log( tFunk("{red:This has a single colour") );

###Single Colour mid string

// chalk
console.log( "This has a single colour " + chalk.cyan("that begins mid-string") );

// tFunck
console.log( tFunk("This has a single colour {cyan:that begins mid-string") );

###Single Colour with end point

// chalk
console.log( chalk.red("This has a single colour with ") + "an endpoint");

// tFunk
console.log( tFunk("{red:This has a single colour with }an endpoint") );

###Two Colours

// chalk
console.log( chalk.green("This has ") + chalk.cyan("two colours") );

// tFunk
console.log( tFunk("{green:This has {cyan:two colours") );

###Nested Colours

// chalk
console.log( chalk.green("This has a colour " + chalk.cyan("nested inside") + " another colour") );

//tFunk
console.log( tFunk("{green:This has a colour {cyan:nested inside} another colour") );

###Multiple Nested

// chalk
console.log( chalk.blue("Multiple " + chalk.cyan("NESTED") + " styles in " + chalk.red("the same string") + " with an ending") );

// tFunk
console.log( tFunk("{blue:Multiple {cyan:NESTED} styles in {red:the same string} with an ending") );

###Multi line

var multiline = require("multiline");

var string = multiline(function () {/*
{cyan:This is a multi-line coloured string
With a single {yellow:yellow} word in the center of a line
Pretty cool huh?
*/});

console.log( tFunk(string) );

###Escaping when you need curly braces

console.log( tFunk("This has a \\{\\{mustache\\}\\}") );

##TODO

  • [x] Colours
  • [x] Nested Colours
  • [x] Custom syntax
  • [x] Prefixed compiler
  • [x] Make the chain-able API work like this "{white.bgRed: White text, red BG"
  • [x] Offer a way of escaping. Right now, ALL instances of } will be lost