From 1e793b182c7cfaef942260f7eb7fb44c9d6c4a05 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Fri, 5 Dec 2014 22:23:43 -0500 Subject: [PATCH] Don't make objCopy crash on non-objects --- lib/bunyan.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/bunyan.js b/lib/bunyan.js index e6e29a4..7f37d84 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -55,16 +55,18 @@ var isBrowser = function () { //---- Internal support stuff function objCopy(obj) { - if (obj === null) { - return null; + if (obj == null) { + return obj; } else if (Array.isArray(obj)) { return obj.slice(); - } else { + } else if (typeof obj === 'object') { var copy = {}; Object.keys(obj).forEach(function (k) { copy[k] = obj[k]; }); return copy; + } else { + return obj; } }