UNPKG

react-http-fetch

Version:

An http library for React JS built on top of native JS fetch

38 lines (37 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HttpContext = exports.HttpContextToken = void 0; var HttpContextToken = /** @class */ (function () { function HttpContextToken(defaultValue) { this.defaultValue = defaultValue; } return HttpContextToken; }()); exports.HttpContextToken = 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; }()); exports.HttpContext = HttpContext;