Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Add colors methods to Function.prototype
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

fn-colors Donate on Gittip

Add colors methods to Function.prototype

WARNING: This will result in context (i.e. this) loss every time unless you use .bind.

Getting Started

Install the module with: npm install fn-colors

var fn_colors = require('fn-colors');'Hello World!'); // 'Hello World!' in green


Currently, only default colors and styles work. fn-colors returns the colors which has a proxied addProperty(color, func), allowing you to add colors one-by-one.

If you are dying for your setTheme support, please create an issue. I am pretty fast at responding and patching. However, this was a side project of a side project of a side project.

How does it work?

fn-colors operates by directly extending Function.prototype. For each color added, it adds a getter property which will colorize any function it is invoke on.

To dive deeper, it receives console.log as its context (i.e. this) when is run. It wraps the function (console.log in this case) and returns a special function (i.e. colorizedFn) such that any time it is invoked, it maps all the string arguments into colorized strings.


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via grunt and test via npm test.


Copyright (c) 2013 Todd Wolfson

Licensed under the MIT license.

Something went wrong with that request. Please try again.