Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including femur with all npm packages installed. Try it out:

var femur = require("femur")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

femur v1.0.0

Wrap a function with a timer


femur is used to wrap a function so as to provide an execution timer. When wrapping a function with femur, you provide a callback to which femur will pass the function execution duration. As such, make sure your duration callback is asynchronous.


$ npm install femur --save


Wrapping functions

The main point of femur is to be able to provide an execution duration logger when initially wrapping a function. As such, using femur is pretty simple.

const femur = require('femur');

function durationLogger(duration) {

function max(a, b) {
  return Math.max(a, b);

// Wrapping synchronous functions is simple.
let wrappedMax = femur.wrap(max, durationLogger);
wrappedMax(4, 5); // returns 5 and logs the duration to the console

// Wrapping asynchronous functions is just as easy.
function asyncMax(a, b, cb) {
  cb(Math.max(a, b));

let asyncWrappedMax = femur.wrap(asyncMax, durationLogger);
// As a note on ordering, the below will log the duration to the console first,
// and then it will log 5 to the console.
asyncWrappedMax(4, 5, (val) => {

Release History

*1.0.0 Initial release.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free