(Go Back) Choose State To Move From
") {
if (typeof this.data[key] !== "undefined") {
data[key] = this.data[key];
} else {
data[key] = null;
}
}
}
return data;
};
/**
* @param {string} key
* @param {string} value
*/
Data.prototype.set = function(key, value) {
if (typeof key === "string") {
this.data[key] = value;
}
};
/**
* @param {string} key
* @returns {string}
*/
Data.prototype.get = function(key) {
if (typeof key === "string") {
return this.data[key];
}
};
/**
* @param {string} key
* @returns {boolean}
*/
Data.prototype.exists = function(key) {
if (typeof key === "string") {
return typeof this.data[key] !== "undefined";
}
return false;
};
/**
* @param {string} key
* @returns {boolean}
*/
Data.prototype.remove = function(key) {
if (typeof key === "string") {
if (typeof this.data[key] !== "undefined") {
delete this.data[key];
return true;
}
}
return false;
};
/**
* @returns {number}
*/
Data.prototype.length = function() {
return Object.keys(this.data).length;
};
/**
* @returns {object}
*/
Data.prototype.all = function() {
return this.data;
};
module.exports = Data;