grncdr/js-capitalize — pull request #1 by imjoshholloway (2014-12-23 11:39:04+00:00)
Title: Added checks against input

This stops `Cannot call method 'replace' of undefined` errors when non strings are passed in.

Basically this would stop the need for users to have to manually check that a value is a string before passing it in.
Example is our particular use-case where an address field is optional and may be undefined.

Before:

...

address.line_1 = capitalize.words(address.line_1);

if (address.line_2 && (typeof address.line_2 === "string")) {
address.line_2 = capitalize.words(address.line_2);
}

After:

...

address.line_1 = capitalize.words(address.line_1);
address.line_2 = capitalize.words(address.line_2);

...