JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://cdn.crafty-modules.com/crafty-DEBUG.js"></script>

JavaScript

Crafty.init(256, 256);
Crafty.background('rgb(0,0,0)');
//A Crafty component, with a method treated as an object
Crafty.c('FnAsObj',
{
    foo: function () {  //a method of the Crafty component
        //console.log(this)  //this refers to the function foo
        foo = this  //otherwise 'foo' is undefined      
        if (foo.t) {      //does the function have a .t property?
            return foo.t; //then simply return the value
        }
        foo.t = new Date(); //otherwise we add the property to the function here
        return foo.t;  //then simply return the value
    }
});
//We can use our Crafty component like so:
var craftyObj = Crafty.e("2D, DOM, FnAsObj")
craftyObj.attr({x: 0, y: 0, w: 233, h: 275})
//These date objects will be the same:
console.log(  craftyObj.foo()  );
console.log(  craftyObj.foo()  );
console.log(  craftyObj.foo()  );
console.log(  craftyObj.foo()  );