Simplification of instantiation api

Issue #4 resolved
Jon Packer
created an issue

Again, just a suggestion, it might nice if the new was optional. This simplifies the initialisation further from

var TaggedLogger = require('tagged-logger');
var logger = new TaggedLogger(winstonThingy);


var logger = require('tagged-logger')(winstonThingy);

A good way of doing this is to check the instanceof this at the top of the constructor, i.e.:

function TaggedLogger() {
  if (!(this instanceof TaggedLogger)) return TaggedLogger.constructor.apply(this, arguments);

I'd do this myself but bitbucket keeps giving me "Access denied" when I try to fork.

Comments (4)

  1. Log in to comment