Skip to content

Commit

Permalink
Replace Object#keys with #objectkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
erithmetic committed Apr 3, 2012
1 parent 84ae1b4 commit fc03648
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions builtins/querystring.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
var isArray = typeof Array.isArray === 'function'
? Array.isArray
: function (xs) {
return Object.toString.call(xs) === '[object Array]'
}
;
return Object.prototype.toString.call(xs) === '[object Array]'
};

var objectKeys = Object.keys || function objectKeys(object) {
if (object !== Object(object)) throw new TypeError('Invalid object');
var keys = [];
for (var key in object) if (object.hasOwnProperty(key)) keys[keys.length] = key;
return keys;
}


/*!
* querystring
Expand Down Expand Up @@ -94,7 +101,7 @@ exports.parse = function(str){
if (isArray(obj)) {
if ('' != val) obj.push(val);
} else if ('object' == typeof obj) {
obj[Object.keys(obj).length] = val;
obj[objectKeys(obj).length] = val;
} else {
obj = parent[key] = [parent[key], val];
}
Expand Down Expand Up @@ -189,7 +196,7 @@ function stringifyArray(arr, prefix) {

function stringifyObject(obj, prefix) {
var ret = []
, keys = Object.keys(obj)
, keys = objectKeys(obj)
, key;
for (var i = 0, len = keys.length; i < len; ++i) {
key = keys[i];
Expand Down

0 comments on commit fc03648

Please sign in to comment.