Permalink
Browse files

Replace Object#keys with #objectkeys

  • Loading branch information...
1 parent 84ae1b4 commit fc036480b0a6ac8da5f84c73473c70bfcac61775 @dkastner committed Apr 3, 2012
Showing with 12 additions and 5 deletions.
  1. +12 −5 builtins/querystring.js
View
@@ -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
@@ -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];
}
@@ -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];

0 comments on commit fc03648

Please sign in to comment.