dwnpm
Version:
Decentralized Registry Package Manager (DRPM) helps developers publish, install, find and manage Decentralized Packages (DPKs) published to Decentralized Web Nodes (DWNs). DRPM does this by looking up a Decentralized Identifier (DID) to find its DID docum
22 lines • 1.1 kB
JavaScript
export class ResponseUtils {
static is2xx = (code) => code >= 200 && code <= 299;
static is3xx = (code) => code >= 300 && code <= 399;
static OK = (ok) => ok === true;
static notOK = (ok) => !this.OK(ok);
static codeSuccess = (statusCode) => this.is2xx(statusCode) || this.is3xx(statusCode);
static codeFail = (statusCode) => !this.codeSuccess(statusCode);
static statusOk = (status) => status === 'OK';
static statusNotOk = (status) => !this.statusOk(status);
static dwnSuccess = ({ status: { code, detail } }) => this.codeSuccess(code) ||
this.statusNotOk(detail);
static dwnFail = (status) => !this.dwnSuccess(status);
static success = ({ ok, code, status }) => this.OK(ok) ||
this.codeSuccess(code) ||
this.statusOk(status);
static fail = (info) => !this.success(info);
static fetchSuccess = (response) => this.OK(response.ok) ||
this.codeSuccess(response.status) ||
this.statusOk(response.statusText);
static fetchFail = (response) => !this.fetchSuccess(response);
}
//# sourceMappingURL=response.js.map