MCPcopy
hub / github.com/trentm/node-bunyan / objCopy

Function objCopy

lib/bunyan.js:116–130  ·  view source on GitHub ↗

* A shallow copy of an object. Bunyan logging attempts to never cause * exceptions, so this function attempts to handle non-objects gracefully.

(obj)

Source from the content-addressed store, hash-verified

114 * exceptions, so this function attempts to handle non-objects gracefully.
115 */
116function objCopy(obj) {
117 if (obj == null) { // null or undefined
118 return obj;
119 } else if (Array.isArray(obj)) {
120 return obj.slice();
121 } else if (typeof (obj) === 'object') {
122 var copy = {};
123 Object.keys(obj).forEach(function (k) {
124 copy[k] = obj[k];
125 });
126 return copy;
127 } else {
128 return obj;
129 }
130}
131
132var format = util.format;
133if (!format) {

Callers 3

LoggerFunction · 0.70
bunyan.jsFile · 0.70
mkRecordFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected