mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add definitions for statuses (https://github.com/jshttp/statuses)
This commit is contained in:
parent
d73cbcb405
commit
d404baa8b6
33
statuses/statuses-tests.ts
Normal file
33
statuses/statuses-tests.ts
Normal file
@ -0,0 +1,33 @@
|
||||
/// <reference path="statuses.d.ts" />
|
||||
|
||||
import status = require('statuses');
|
||||
|
||||
var code: number;
|
||||
|
||||
code = status(403) // => 403
|
||||
code = status('403') // => 403
|
||||
code = status('forbidden') // => 403
|
||||
code = status('Forbidden') // => 403
|
||||
code = status(306) // throws, as it's not supported by node.js
|
||||
|
||||
var codes: Array<number>;
|
||||
codes = status.codes;
|
||||
|
||||
var msg: string;
|
||||
msg = status[404] // => 'Not Found'
|
||||
|
||||
code = status['not found'] // => 404
|
||||
code = status['Not Found'] // => 404
|
||||
|
||||
var isRedirect: boolean;
|
||||
isRedirect = status.redirect[200] // => undefined
|
||||
isRedirect = status.redirect[301] // => true
|
||||
|
||||
var isEmpty: boolean;
|
||||
isEmpty = status.empty[200] // => undefined
|
||||
isEmpty = status.empty[204] // => true
|
||||
isEmpty = status.empty[304] // => true
|
||||
|
||||
var isRetry: boolean;
|
||||
isRetry = status.retry[501] // => undefined
|
||||
isRetry = status.retry[503] // => true
|
||||
21
statuses/statuses.d.ts
vendored
Normal file
21
statuses/statuses.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Type definitions for http-errors v1.2.1
|
||||
// Project: https://github.com/jshttp/statuses
|
||||
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module 'statuses' {
|
||||
interface Status {
|
||||
[code: number]: string;
|
||||
[msg: string]: any | number;
|
||||
|
||||
codes: Array<number>;
|
||||
redirect: {[code: number]: boolean};
|
||||
empty: {[code: number]: boolean};
|
||||
retry: {[code: number]: boolean};
|
||||
|
||||
(code: number | string): number;
|
||||
}
|
||||
|
||||
var status: Status;
|
||||
export = status;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user