Comparing version 2.0.1 to 2.1.0
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.middleware = exports.callback = exports.promise = exports.sync = undefined; | ||
exports.middleware = exports.callback = exports.promise = exports.sync = exports.isWrapped = undefined; | ||
@@ -36,2 +36,3 @@ var _debug = require('debug'); | ||
var debug = (0, _debug2.default)('derf'); | ||
var DERFED = Symbol('derfed'); | ||
@@ -86,6 +87,9 @@ function hrToNano(hr) { | ||
// mimic original function because the name and arity might matter | ||
var wrappedFn = handler(fn, print); | ||
(0, _mimicFn2.default)(wrappedFn, fn); | ||
// because the name and arity might matter | ||
(0, _mimicFn2.default)(wrappedFn, fn); | ||
// mark it with a symbol so it's possible to tell the difference | ||
wrappedFn[DERFED] = true; | ||
return wrappedFn; | ||
@@ -95,2 +99,6 @@ }; | ||
var isWrapped = exports.isWrapped = function isWrapped(fn) { | ||
return !!fn && !!fn[DERFED]; | ||
}; | ||
/** | ||
@@ -97,0 +105,0 @@ * Wrap a synchronous function |
{ | ||
"name": "derf", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "A javascript performance debugger.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -92,3 +92,6 @@ # derf | ||
#### `derf.isWrapped(fn) -> boolean` | ||
Returns true if a given function has already been wrapped by derf. | ||
### Custom Logging | ||
@@ -95,0 +98,0 @@ You can pass in a function as the last argument of each derf wrapper to customize what is logged. The function must return a string and is passed the following arguments: |
14299
212
128