1
0
Fork 0
forked from 0x2620/oxjs

serialize/unserialize

This commit is contained in:
rolux 2010-07-14 00:38:53 +02:00
commit 5ee998b263
4 changed files with 39 additions and 11 deletions

View file

@ -96,7 +96,7 @@ Ox.user = function() {
outerHeight: outerHeight,
outerWidth: outerWidth
}
}
};
/*
================================================================================
@ -330,6 +330,14 @@ Ox.range = function(start, stop, step) {
return range;
};
Ox.serialize = function(obj) {
var arr = [];
Ox.each(obj, function(k, v) {
arr.push(k + "=" + v);
});
return arr.join("&");
};
Ox.shuffle = function(arr) {
/*
>>> Ox.shuffle([1, 2, 3]).length
@ -368,6 +376,15 @@ Ox.sum = function(obj) {
return sum;
};
Ox.unserialize = function(str) {
var arr, obj = {};
Ox.each(str.split("&"), function(i, v) {
arr = v.split("=");
obj[arr[0]] = arr[1];
});
return obj;
};
Ox.values = function(obj) {
/*
>>> Ox.values({"a": 1, "b": 2, "c": 3}).join(",")
@ -1708,4 +1725,4 @@ Ox.isUndefined = function(val) {
true
*/
return typeof val == "undefined";
};
};