lib/pwf.js
function(items)
	{
		var register = [];

		/// Export as module if running under nodejs
		if (typeof global === 'object') {
			register.push(global);
		}

		if (typeof window === 'object') {
			register.push(window);
		}

		// Browse all resolved global objects and bind pwf items
		for (var i = 0; i < register.length; i++) {
			var obj = register[i];

			// Bind all requested items as global
			for (var key in items) {
				if (!items.hasOwnProperty(key)) {
					continue;
				}

				obj[key] = items[key];
			}

			// Check for all callbacks bound to this global object and call them
			if (typeof obj.on_pwf !== 'undefined') {
				var calls = obj.on_pwf;

				// Expecting list/array
				if (!(calls instanceof Array)) {
					calls = [calls];
				}

				for (var j = 0; j < calls.length; j++) {
					if (typeof calls[j] !== 'function') {
						throw new Error('on_pwf:not-a-method:' + j);
					}

					calls[j].apply(obj.pwf);
				}
			}
		}
	}
function(items)
	{
		var register = [];

		/// Export as module if running under nodejs
		if (typeof global === 'object') {
			register.push(global);
		}

		if (typeof window === 'object') {
			register.push(window);
		}

		// Browse all resolved global objects and bind pwf items
		for (var i = 0; i < register.length; i++) {
			var obj = register[i];

			// Bind all requested items as global
			for (var key in items) {
				if (!items.hasOwnProperty(key)) {
					continue;
				}

				obj[key] = items[key];
			}

			// Check for all callbacks bound to this global object and call them
			if (typeof obj.on_pwf !== 'undefined') {
				var calls = obj.on_pwf;

				// Expecting list/array
				if (!(calls instanceof Array)) {
					calls = [calls];
				}

				for (var j = 0; j < calls.length; j++) {
					if (typeof calls[j] !== 'function') {
						throw new Error('on_pwf:not-a-method:' + j);
					}

					calls[j].apply(obj.pwf);
				}
			}
		}
	}
function ( items ) { var register = [ ] ; /// Export as module if running under nodejs if ( typeof global === 'object' ) { register . push ( global ) ; } if ( typeof window === 'object' ) { register . push ( window ) ; } // Browse all resolved global objects and bind pwf items for ( var i = 0 ; i < register . length ; i ++ ) { var obj = register [ i ] ; // Bind all requested items as global for ( var key in items ) { if ( ! items . hasOwnProperty ( key ) ) { continue ; } obj [ key ] = items [ key ] ; } // Check for all callbacks bound to this global object and call them if ( typeof obj . on_pwf !== 'undefined' ) { var calls = obj . on_pwf ; // Expecting list/array if ( ! ( calls instanceof Array ) ) { calls = [ calls ] ; } for ( var j = 0 ; j < calls . length ; j ++ ) { if ( typeof calls [ j ] !== 'function' ) { throw new Error ( 'on_pwf:not-a-method:' + j ) ; } calls [ j ] . apply ( obj . pwf ) ; } } } }
Register items into global objects
@param object items Key-value objects to register
@return void
Register items into global objects