-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}) |