JSFiddle - React, Tailwind, and code Playground

JavaScript

Object.extend = function(dest, source) {
    Object.getOwnPropertyNames(source).forEach(function (key) {
        dest[key] = source[key];
    });  
};

var Proto = Object.create(Function.prototype);
Object.extend(Proto, {
  constructor: function (d) {
    console.log("construct, argument : ", d);
    this.d = d; 
    // this is your constructor logic
  },
  call: function () {
    console.log("call", this.d);
    // this get's called when you invoke the "function" that is the instance
    return "from call";
  },
  method: function () {
    console.log("method");
    // some method
    return "return from method";
  },
  // some attr
  attr: 42
});

var functionFactory = function (proto) {
  return function () {
    var f = function () {
      return f.call.apply(f, arguments);      
    };
    Object.keys(proto).forEach(function (key) {
      f[key] = proto[key];
    });
    f.constructor.apply(f, arguments);
    return f;
  }
}

var protoFactory = functionFactory(Proto);
var instance = protoFactory("data");
console.log(instance());
console.log(instance.method());
console.log(instance.attr);