Skip to content

Commit

Permalink
support for traversing an Error object.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeferner committed Feb 27, 2012
1 parent aeebf14 commit 642dd51
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ function copy (src) {
else if (src instanceof Date) {
dst = new Date(src);
}
else if (src instanceof Error) {
dst = { message: src.message };
}
else if (src instanceof Boolean) {
dst = new Boolean(src);
}
Expand Down
13 changes: 13 additions & 0 deletions test/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var assert = require('assert');
var Traverse = require('../');

exports['traverse an Error'] = function () {
var obj = new Error("test");

var results = Traverse(obj).map(function (node) { });

assert.deepEqual(results, {
message: 'test'
});
};

0 comments on commit 642dd51

Please sign in to comment.