Skip to content

Commit

Permalink
Initial browser builder
Browse files Browse the repository at this point in the history
  • Loading branch information
jhs committed Sep 1, 2011
1 parent be0438b commit da0b0b5
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ task :export => ([:clean, "cli.js"] + LIBRARY + BROWSER_TOOLS) do |task|
sh "cp", file, build
end

# EventEmitter2 needs wrapping.
sh "node", "browser/export.js", "browser/eventemitter2.js", "#{build}/eventemitter2.js"

File.open("#{build}/boot.js", 'w') do |boot|
requirejs_paths = { 'request' => '../request.jquery',
requirejs_paths = { 'request' => 'request.jquery',
'events' => 'eventemitter2',
# 'foo' => 'bar', etc.
}

Expand Down
Empty file added browser/log4js.js
Empty file.
28 changes: 28 additions & 0 deletions browser/querystring.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
define([], function() {
var exports = {};

exports.parse = function(str) {
var result = {};

str = str || "";
str = str.replace(/^\?/, "");
if(!str) return result;

var kvs = str.split('&');
kvs.forEach(function(pair) {
var both = pair.split('=');
result[both[0]] = both[1];
})

return result;
}

exports.stringify = function(query) {
var result = [];
for (var k in query)
result.push(k + '=' + encodeURIComponent(query[k]));
return result.join('&');
}

return exports;
})
28 changes: 28 additions & 0 deletions browser/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
define([], function() {
var exports = {};

exports.inspect = JSON.stringify;

// Copy from Node
/**
* Inherit the prototype methods from one constructor into another.
*
* The Function.prototype.inherits from lang.js rewritten as a standalone
* function (not on Function.prototype). NOTE: If this file is to be loaded
* during bootstrapping this function needs to be revritten using some native
* functions as prototype setup using normal JavaScript does not work as
* expected during bootstrapping (see mirror.js in r114903).
*
* @param {function} ctor Constructor function which needs to inherit the
* prototype.
* @param {function} superCtor Constructor function to inherit prototype from.
*/
exports.inherits = function(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: { value: ctor, enumerable: false }
});
};

return exports;
})

0 comments on commit da0b0b5

Please sign in to comment.