vox-core
Version:
Runtime de aplicaciones multiplataforma
76 lines • 2.44 kB
JavaScript
{
var ServerCookie = function ServerCookie() {
ServerCookie.$constructor ? ServerCookie.$constructor.apply(this, arguments) : ServerCookie.$superClass && ServerCookie.$superClass.apply(this, arguments);
};
ServerCookie.$constructor = function () {
this.$json = {};
};
ServerCookie.prototype.set = function (name, value) {
name = name.toLowerCase().trim();
this.$json[name] = value.toString();
};
ServerCookie.prototype.get = function (name) {
return this.$json[name];
};
ServerCookie.prototype.keys = function () {
return Object.keys(this.$json);
};
ServerCookie.prototype.toStr = function (id) {
return id + '=' + this.$json[id];
};
ServerCookie.prototype.toString = function () {
var e = [];
for (var id in this.$json) {
e.push(this.toStr(id));
}
e.push('');
return e.join('; ');
};
ServerCookie.fromString = function (str) {
var d = {}, p, p1, p2;
var items = str.split(';');
{
var item;
var $_iterator0 = regeneratorRuntime.values(items), $_normal0 = false, $_err0;
try {
while (true) {
var $_step0 = $_iterator0.next();
if ($_step0.done) {
$_normal0 = true;
break;
}
{
item = $_step0.value;
if (item) {
p = item.indexOf('=');
p1 = item.substring(0, p).trim();
p2 = item.substring(p + 1).trim();
if (p1) {
d[p1] = p2;
}
}
}
}
} catch (e) {
$_normal0 = false;
$_err0 = e;
}
try {
if (!$_normal0 && $_iterator0['return']) {
$_iterator0['return']();
}
} catch (e) {
}
if ($_err0) {
throw $_err0;
}
}
var c = new ServerCookie();
c.$json = d;
return c;
};
ServerCookie.prototype.toJSON = function () {
return this.$json;
};
}
exports.default = ServerCookie;