
Untitled
By: a guest on
Aug 3rd, 2012 | syntax:
None | size: 0.72 KB | hits: 11 | expires: Never
/*
add a monkey-patched "require" function to the global scope (global object).
It is smarter in two ways:
- It only loads a module once
- If the exports object contains a function matching the module base name, return that
value from "require" - this is a bit of sugar added because Titanium's require implementation
does not allow you to replace the "exports" object directly
*/
//monkey patch "require" in the global scope
require('require_patch').monkeypatch(this);
//regular modules are the same...
var module = require('module');
module.sayHello('Marshall');
module.sayGoodbye('Kevin');
//modules which contain a type by the same name as the module...
var Person = require('Person');
var jedi = new Person('Luke','Skywalker');