mirror of
https://github.com/Redocly/redoc.git
synced 2024-12-01 04:43:43 +03:00
32 lines
643 B
TypeScript
32 lines
643 B
TypeScript
'use strict';
|
|
|
|
export function statusCodeType(statusCode) {
|
|
if (statusCode < 100 || statusCode > 599) {
|
|
throw new Error('invalid HTTP code');
|
|
}
|
|
let res = 'success';
|
|
if (statusCode >= 300 && statusCode < 400) {
|
|
res = 'redirect';
|
|
} else if (statusCode >= 400) {
|
|
res = 'error';
|
|
} else if (statusCode < 200) {
|
|
res = 'info';
|
|
}
|
|
return res;
|
|
}
|
|
|
|
export function defaults(target, src) {
|
|
var props = Object.keys(src);
|
|
|
|
var index = -1,
|
|
length = props.length;
|
|
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
if (target[key] === undefined) {
|
|
target[key] = src[key];
|
|
}
|
|
}
|
|
return target;
|
|
}
|