react-http-fetch
Version:
An http library for React JS built on top of native JS fetch
35 lines (34 loc) • 971 B
JavaScript
var HttpContextToken = /** @class */ (function () {
function HttpContextToken(defaultValue) {
this.defaultValue = defaultValue;
}
return HttpContextToken;
}());
export { HttpContextToken };
var HttpContext = /** @class */ (function () {
function HttpContext() {
this.map = new Map();
}
HttpContext.prototype.set = function (token, value) {
this.map.set(token, value);
return this;
};
HttpContext.prototype.get = function (token) {
if (!this.map.has(token)) {
return token.defaultValue;
}
return this.map.get(token);
};
HttpContext.prototype.delete = function (token) {
this.map.delete(token);
return this;
};
HttpContext.prototype.has = function (token) {
return this.map.has(token);
};
HttpContext.prototype.keys = function () {
return this.map.keys();
};
return HttpContext;
}());
export { HttpContext };