// Dual licensed under the MIT and GPL licenses.
// http://docs.jquery.com/License
process.mixin = function() {
- // copy reference to target object
- var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
-
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
- target = arguments[1] || {};
- // skip the boolean and the target
- i = 2;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !(typeof target === 'function') )
- target = {};
-
- // mixin process itself if only one argument is passed
- if ( length == i ) {
- target = GLOBAL;
- --i;
- }
-
- for ( ; i < length; i++ ) {
- // Only deal with non-null/undefined values
- if ( (options = arguments[ i ]) != null ) {
- // Extend the base object
- for ( var name in options ) {
- var src = target[ name ], copy = options[ name ];
-
- // Prevent never-ending loop
- if ( target === copy )
- continue;
-
- // Recurse if we're merging object values
- if ( deep && copy && typeof copy === "object" ) {
- target[ name ] = process.mixin( deep,
- // Never move original objects, clone them
- src || ( copy.length != null ? [ ] : { } )
- , copy );
-
- // Don't bring in undefined values
- } else {
- target[ name ] = copy;
- }
- }
- }
- }
- // Return the modified object
- return target;
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !(typeof target === 'function') )
+ target = {};
+
+ // mixin process itself if only one argument is passed
+ if ( length == i ) {
+ target = GLOBAL;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( var name in options ) {
+ var src = target[ name ], copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy )
+ continue;
+
+ // Recurse if we're merging object values
+ if ( deep && copy && typeof copy === "object" ) {
+ target[ name ] = process.mixin( deep,
+ // Never move original objects, clone them
+ src || ( copy.length != null ? [ ] : { } )
+ , copy );
+
+ // Don't bring in undefined values
+ } else {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+ // Return the modified object
+ return target;
};
options = {};
listener = arguments[1];
}
-
+
if (options.persistent === undefined) options.persistent = true;
if (options.interval === undefined) options.interval = 0;
process.paths = [ path.join(process.installPrefix, "lib/node/libraries")
];
-
+
if (process.ENV["HOME"]) {
process.paths.unshift(path.join(process.ENV["HOME"], ".node_libraries"));
}
callback();
return;
}
-
+
var dir = dirs[0];
var rest = dirs.slice(1, dirs.length);
Module.prototype.loadObject = function (filename, loadPromise) {
var self = this;
// XXX Not yet supporting loading from HTTP. would need to download the
- // file, store it to tmp then run dlopen on it.
+ // file, store it to tmp then run dlopen on it.
setTimeout(function () {
self.loaded = true;
process.dlopen(filename, self.exports); // FIXME synchronus
function cat (id, loadPromise) {
var promise;
-
+
debug(id);
if (id.match(/^http:\/\//)) {
require.async = requireAsync;
require.main = process.mainModule;
// create wrapper function
- var wrapper = "var __wrap__ = function (exports, require, module, __filename) { "
- + content
+ var wrapper = "var __wrap__ = function (exports, require, module, __filename) { "
+ + content
+ "\n}; __wrap__;";
var compiledWrapper = process.compile(wrapper, filename);