File tree Expand file tree Collapse file tree 3 files changed +20
-10
lines changed
Expand file tree Collapse file tree 3 files changed +20
-10
lines changed Original file line number Diff line number Diff line change 33[ ![ npm version] ( https://badge.fury.io/js/%40tkrotoff%2Ffetch.svg )] ( https://www.npmjs.com/package/@tkrotoff/fetch )
44[ ![ Node.js CI] ( https://github.com/tkrotoff/fetch/workflows/Node.js%20CI/badge.svg?branch=master )] ( https://github.com/tkrotoff/fetch/actions )
55[ ![ Test Coverage] ( https://api.codeclimate.com/v1/badges/67aaf07dd7577e2ef340/test_coverage )] ( https://codeclimate.com/github/tkrotoff/fetch/test_coverage )
6- [ ![ Bundle size] ( https://badgen.net/bundlephobia/minzip/@tkrotoff/fetch )] ( https://bundlephobia.com/result?p= @tkrotoff/fetch )
6+ [ ![ Bundle size] ( https://badgen.net/bundlephobia/minzip/@tkrotoff/fetch )] ( https://bundlephobia.com/package/ @tkrotoff/fetch )
77[ ![ Prettier] ( https://img.shields.io/badge/code_style-prettier-ff69b4.svg )] ( https://github.com/prettier/prettier )
88[ ![ Airbnb Code Style] ( https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb )] ( https://github.com/airbnb/javascript )
99
@@ -143,6 +143,9 @@ import { HttpStatus } from '@tkrotoff/fetch';
143143console .log (HttpStatus ._201_Created );
144144console .log (HttpStatus ._403_Forbidden );
145145console .log (HttpStatus ._503_ServiceUnavailable );
146+
147+ type HttpStatusEnum = typeof HttpStatus[keyof typeof HttpStatus];
148+ const status: HttpStatusEnum = HttpStatus ._200_OK ;
146149```
147150
148151### Configuration
Original file line number Diff line number Diff line change @@ -2,7 +2,10 @@ import { entriesToObject } from './utils/entriesToObject';
22import { wait } from './utils/wait' ;
33import { HttpError } from './HttpError' ;
44
5- // https://github.com/microsoft/TypeScript/blob/v4.4.4/lib/lib.dom.d.ts#L2446-L2450
5+ /**
6+ * `Promise<`[`Response`](https://fetch.spec.whatwg.org/#response)`>` with added methods from [`Body`](https://fetch.spec.whatwg.org/#body-mixin).
7+ */
8+ // https://github.com/microsoft/TypeScript/blob/v4.7.4/lib/lib.dom.d.ts#L2503-L2507
69export type ResponsePromiseWithBodyMethods = Promise < Response > &
710 Pick < Body , 'arrayBuffer' | 'blob' | 'formData' | /*'json' |*/ 'text' > & {
811 // FIXME https://github.com/microsoft/TypeScript/issues/26188
Original file line number Diff line number Diff line change 11/**
2- * List of HTTP status codes.
3- *
42 * [List of HTTP status codes](http://en.wikipedia.org/wiki/List_of_HTTP_status_codes)
5- * [Rails HTTP Status Code to Symbol Mapping](https://web.archive.org/web/20131211220540/http://www.codyfauser.com/2008/7/4/rails-http-status-code-to-symbol-mapping)
6- *
7- * https://www.rubydoc.info/github/rack/rack/master/Rack/Utils#HTTP_STATUS_CODES-constant
83 *
9- * curl -s https://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv | \
10- * ruby -ne 'm = /^(\d{3}),(?!Unassigned|\(Unused\))([^,]+)/.match($_) and \
11- * puts "_#{m[1]}_#{m[2].delete %Q[ ]} = #{m[1]},"'
4+ * With TypeScript use `typeof HttpStatus[keyof typeof HttpStatus]` to pull out the values
5+ * (https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums)
126 */
7+ // [Rails HTTP Status Code to Symbol Mapping](https://web.archive.org/web/20131211220540/http://www.codyfauser.com/2008/7/4/rails-http-status-code-to-symbol-mapping)
8+ //
9+ // https://www.rubydoc.info/gems/rack/Rack/Utils#HTTP_STATUS_CODES-constant
10+ //
11+ // ```
12+ // curl -s https://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv | \
13+ // ruby -ne 'm = /^(\d{3}),(?!Unassigned|\(Unused\))([^,]+)/.match($_) and \
14+ // puts "_#{m[1]}_#{m[2].delete %Q[ ]} = #{m[1]},"'
15+ // ```
1316export const HttpStatus = {
1417 /*
1518 * 1xx informational response
@@ -102,5 +105,6 @@ export const HttpStatus = {
102105 */
103106
104107 // A deprecated response used by the Spring Framework when a method has failed
108+ // Still in use at PMU as of 2022
105109 _420_MethodFailure : 420
106110} as const ;
You can’t perform that action at this time.
0 commit comments