1.0.0 • Published 11 years ago

euh.js v1.0.0

Weekly downloads
1
License
-
Repository
github
Last release
11 years ago

§1. Synopsis

euh.js1 is a JavaScript console wrapper that provides a simple, unified and non-breaking way of logging across several different environments. It makes things, arguably, a little bit less painful than this:

try { console.log("I can has cheezburger?"); } catch (e) { // }

                                ***

§2. Quick Reference

euh.js exposes the “ø” object—the console wrapper—to the environment on “load”, if the environment is a browser, or on “require”, if the environ- ment supports CommonJS modules (e.g. Node.js).

• ø.log • ø.warn • ø.error

These are the core methods of “ø” and they behave pretty much like you’d probably expect. Additionally, they support “chaining”:

ø.log("Hi kids!").warn("Do you like chains?");

• ø.enabled

You can use this boolean property to toggle logging on/off, at any time. By default, “ø.enabled” is “true”.

• ø.VERSION

This property can be queried to find out the current euh.js release. euh.js is semantically versioned2. See “§4. Change Log” for a brief re- lease history.

• ø.consoleExists

This boolean property allows you to check the presence of the “console” object in the environment—There are some environments (e.g. IE w/o F12) that don’t provide “console” straight out of the box.

• ø.logs

This property stores the log messages when “ø.consoleExists” is “false”, so that you can examine them when and by whatever means you desire.

• ø.fyi, ø.par, ø.pil —wrap around ø.log • ø.wtf, ø.wat, ø.wut — ” ø.warn • ø.omg, ø.omd — ” ø.error • ø.ln, ø.br, ø.nl — ” ø.log —new lines/breaks • ø.ast, ø.sep — ” ø.log —asterisms/separators

These are various alias methods that wrap around the core methods of “ø”, as specified. They can output timestamps in ISO 8601 format—An attribute that you might find handy for basic performance tests.

• ø.logTimestamps

You can use this boolean property to toggle timestamp output on/off, for the alias methods. By default, “ø.logTimestamps” is “true”.

• ø.noConflict

If the environment is a browser, this method would—if called—throw euh.js into “no conflict” mode3 and restore “ø” to its previous owner, if any.

                                ***

§3. Support4

I’ve tested euh.js on the following environments:

• Chrome “latest” (23)

• Chrome 4

• Firefox “latest” (16.0.2) • w/ the native console • w/ Firebug “latest” (1.10.6)

• Firefox 3.6 • w/o console (default) • w/ Firebug 1.7.3

• IE 9 • w/o F12 (default) • w/ F12, in all modes: IE 9, IE 9 Compat View, IE 8, IE 7

• IE 8 • w/o F12 (default) • w/ F12, in all modes: IE 8, IE 8 Compat View, IE 7

• Safari “latest” (5.1.7)

• Mobile Safari on iOS 5 w/ Debug Console

• Opera “latest” (12.10)

• Node.js “latest” (0.8.14)

                                ***

§4. Change Log

• 0.3.1 (2012-11-10)

Made euh.js semicolon-less.

Fixed a bug where the “toISOString” “shim” was being applied to a local proxy variable instead of “Date.prototype”.

• 0.3.0 (2012-06-21)

Made euh.js Ender-compatible.

Changed the output of “ø.ast” and “ø.sep”.

• 0.2.0 (2012-06-14)

Added timestamps to “ø.fyi”, “ø.par”, “ø.pil”, “ø.wtf”, “ø.wat”, “ø.wut”, “ø.omg” and “ø.omd”, toggleable via “ø.logTimestamps”.

• 0.1.2 (2012-06-04)

Updated the Node.js module exports/require sections.

• 0.1.1 (2012-05-28)

Changed the output of “ø.ast” and “ø.sep”. The new asterism/separator style uses less non-Latin-1 characters.

• 0.1.0 (2012-05-25)

Initial development release of euh.js.

                                ***

§5. Future Plans5

• Replace the “ø.consoleExists” property with a “ø.doesConsoleExist” meth- od, as some platforms may “inject” the “console” object in the environ- ment later than euh.js checks for its presence.

• Test on IE 10, IE 7 and IE 6. Support these platforms, too, if euh.js doesn’t already work on them.

• On iOS 6, the Mobile Safari Debug Console is gone and debugging is sup- ported only via the Remote Web Inspector. I might, at some point, get my hands on a Mac with OS X and Safari 6, in order to have that system tested, as well.

• Comment out the code.

                                ***

§6. Credits

• Cristian Tincu (@CristianTincu)

                                ***

§7. License

I made euh.js as an exercise and as an experiment. You’re free to use it in your own exercises, experiments or projects, whether they’re “closed” or “open”, commercial or non-commercial, “good” or “evil”, subject to the terms of the MIT License6.

                                ***

§8. Notes

1

Yep, “euh” (IPA: /ø/) is an interjection.

See: • http://www.larousse.com/en/dictionaries/french-english/euh

2

See: • http://semver.org/

3

I’ve borrowed this trick—as well as others—from Underscore.js.

See: • http://underscorejs.org/#noConflict

4

I’m not really “supporting” all these environments in the cheering-clap- ping sense, as you might already imagine.

“Latest” means the current stable version of the respective environment, at the time I’m writing this text.

5

Planning is one thing and doing is another. Please don’t take these as promises—They’re mere intentions and might never become more than that.

6

See: • https://raw.github.com/CristianTincu/euh.js/master/license.txt

1.0.0

11 years ago

0.4.0

11 years ago

0.3.1

12 years ago

0.3.0

12 years ago

0.2.0

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago