Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeromeetienne/466519 to your computer and use it in GitHub Desktop.
Save jeromeetienne/466519 to your computer and use it in GitHub Desktop.
nodejs: Support of console.dir + console.assert
From 25844820ac27eecad46bbf98841c9b97a3b784d6 Mon Sep 17 00:00:00 2001
From: Jerome Etienne <jerome.etienne@gmail.com>
Date: Wed, 7 Jul 2010 11:58:33 +0200
Subject: [PATCH] Support of console.dir + console.assert
---
src/node.js | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/node.js b/src/node.js
index 97b1f1b..2319527 100644
--- a/src/node.js
+++ b/src/node.js
@@ -220,6 +220,17 @@ global.console.warn = function () {
global.console.error = global.console.warn;
+global.console.dir = function(object){
+ var sys = module.requireNative('sys');
+ process.stdout.write(sys.inspect(object) + '\n');
+}
+
+global.console.assert = function(expression){
+ if(!expression){
+ var arr = Array.prototype.slice.call(arguments, 1);
+ process.assert(false, format.apply(this, arr));
+ }
+}
process.exit = function (code) {
process.emit("exit");
--
1.7.0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment