@leyyo/http-mock 1.1.1 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +415 -6
  2. package/dist/application/index.types.d.ts +114 -0
  3. package/dist/{request/index-types.js → application/index.types.js} +1 -1
  4. package/dist/application/index.types.js.map +1 -0
  5. package/dist/application/mock-application.d.ts +112 -56
  6. package/dist/application/mock-application.js +230 -96
  7. package/dist/application/mock-application.js.map +1 -1
  8. package/dist/http-mock.d.ts +7 -10
  9. package/dist/http-mock.js +30 -9
  10. package/dist/http-mock.js.map +1 -1
  11. package/dist/index.d.ts +5 -0
  12. package/dist/index.js +5 -0
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.types.d.ts +32 -0
  15. package/dist/index.types.js +3 -0
  16. package/dist/index.types.js.map +1 -0
  17. package/dist/internal.d.ts +1 -0
  18. package/dist/internal.js +6 -0
  19. package/dist/internal.js.map +1 -0
  20. package/dist/request/index.d.ts +2 -2
  21. package/dist/request/index.js +2 -2
  22. package/dist/request/index.types.d.ts +61 -0
  23. package/dist/request/index.types.js +3 -0
  24. package/dist/request/index.types.js.map +1 -0
  25. package/dist/request/mock.request.d.ts +248 -0
  26. package/dist/request/mock.request.js +342 -0
  27. package/dist/request/mock.request.js.map +1 -0
  28. package/dist/response/index-types.d.ts +63 -14
  29. package/dist/response/mock-response.d.ts +218 -76
  30. package/dist/response/mock-response.js +273 -153
  31. package/dist/response/mock-response.js.map +1 -1
  32. package/dist/shared/http-event.d.ts +39 -0
  33. package/dist/shared/http-event.js +97 -0
  34. package/dist/shared/http-event.js.map +1 -0
  35. package/dist/shared/http-method.d.ts +11 -0
  36. package/dist/shared/http-method.js +21 -0
  37. package/dist/shared/http-method.js.map +1 -0
  38. package/dist/shared/http-protocol.d.ts +10 -0
  39. package/dist/shared/http-protocol.js +13 -0
  40. package/dist/shared/http-protocol.js.map +1 -0
  41. package/dist/shared/index.d.ts +4 -0
  42. package/dist/shared/index.js +21 -0
  43. package/dist/shared/index.js.map +1 -0
  44. package/dist/shared/index.types.d.ts +41 -0
  45. package/dist/shared/index.types.js +3 -0
  46. package/dist/shared/index.types.js.map +1 -0
  47. package/package.json +29 -33
  48. package/dist/internal-component.d.ts +0 -3
  49. package/dist/internal-component.js +0 -8
  50. package/dist/internal-component.js.map +0 -1
  51. package/dist/request/index-types.d.ts +0 -20
  52. package/dist/request/index-types.js.map +0 -1
  53. package/dist/request/mock-request.d.ts +0 -121
  54. package/dist/request/mock-request.js +0 -229
  55. package/dist/request/mock-request.js.map +0 -1
  56. package/dist/server.d.ts +0 -0
  57. package/dist/server.js +0 -2
  58. package/dist/server.js.map +0 -1
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpEvent = void 0;
4
+ /**
5
+ * Abstract class for Request and Response
6
+ * */
7
+ class HttpEvent {
8
+ constructor(_origin) {
9
+ this._origin = _origin;
10
+ }
11
+ /** @inheritDoc */
12
+ addListener(e, l) {
13
+ var _a;
14
+ (_a = this._origin) === null || _a === void 0 ? void 0 : _a.addListener(e, l);
15
+ return this;
16
+ }
17
+ /** @inheritDoc */
18
+ emit(e, ...a) {
19
+ var _a, _b;
20
+ return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.emit(e, a)) !== null && _b !== void 0 ? _b : false;
21
+ }
22
+ /** @inheritDoc */
23
+ eventNames() {
24
+ var _a, _b;
25
+ return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.eventNames()) !== null && _b !== void 0 ? _b : [];
26
+ }
27
+ /** @inheritDoc */
28
+ getMaxListeners() {
29
+ var _a, _b;
30
+ return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.getMaxListeners()) !== null && _b !== void 0 ? _b : 10;
31
+ }
32
+ /** @inheritDoc */
33
+ listenerCount(e) {
34
+ var _a, _b;
35
+ return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.listenerCount(e)) !== null && _b !== void 0 ? _b : 0;
36
+ }
37
+ /** @inheritDoc */
38
+ listeners(e) {
39
+ var _a, _b;
40
+ return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.listeners(e)) !== null && _b !== void 0 ? _b : [];
41
+ }
42
+ /** @inheritDoc */
43
+ off(e, l) {
44
+ var _a;
45
+ (_a = this._origin) === null || _a === void 0 ? void 0 : _a.off(e, l);
46
+ return this;
47
+ }
48
+ /** @inheritDoc */
49
+ on(e, l) {
50
+ var _a;
51
+ (_a = this._origin) === null || _a === void 0 ? void 0 : _a.on(e, l);
52
+ return this;
53
+ }
54
+ /** @inheritDoc */
55
+ once(e, l) {
56
+ var _a;
57
+ (_a = this._origin) === null || _a === void 0 ? void 0 : _a.once(e, l);
58
+ return this;
59
+ }
60
+ /** @inheritDoc */
61
+ prependListener(e, l) {
62
+ var _a;
63
+ (_a = this._origin) === null || _a === void 0 ? void 0 : _a.prependListener(e, l);
64
+ return this;
65
+ }
66
+ /** @inheritDoc */
67
+ prependOnceListener(e, l) {
68
+ var _a;
69
+ (_a = this._origin) === null || _a === void 0 ? void 0 : _a.prependOnceListener(e, l);
70
+ return this;
71
+ }
72
+ /** @inheritDoc */
73
+ rawListeners(e) {
74
+ var _a, _b;
75
+ return (_b = (_a = this._origin) === null || _a === void 0 ? void 0 : _a.rawListeners(e)) !== null && _b !== void 0 ? _b : [];
76
+ }
77
+ /** @inheritDoc */
78
+ removeAllListeners(e) {
79
+ var _a;
80
+ (_a = this._origin) === null || _a === void 0 ? void 0 : _a.removeAllListeners(e);
81
+ return this;
82
+ }
83
+ /** @inheritDoc */
84
+ removeListener(e, l) {
85
+ var _a;
86
+ (_a = this._origin) === null || _a === void 0 ? void 0 : _a.removeListener(e, l);
87
+ return this;
88
+ }
89
+ /** @inheritDoc */
90
+ setMaxListeners(m) {
91
+ var _a;
92
+ (_a = this._origin) === null || _a === void 0 ? void 0 : _a.setMaxListeners(m);
93
+ return this;
94
+ }
95
+ }
96
+ exports.HttpEvent = HttpEvent;
97
+ //# sourceMappingURL=http-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-event.js","sourceRoot":"","sources":["../../src/shared/http-event.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,11 @@
1
+ declare const literals: readonly ["delete", "get", "head", "link", "options", "patch", "post", "purge", "put", "unlink"];
2
+ /**
3
+ * Http Method
4
+ * */
5
+ type _HttpMethod = typeof literals[number];
6
+ export type HttpMethod = _HttpMethod | Uppercase<_HttpMethod>;
7
+ /**
8
+ * @type {ReadonlyArray<HttpMethod>}
9
+ * */
10
+ export declare const HttpMethodItems: ReadonlyArray<HttpMethod>;
11
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpMethodItems = void 0;
4
+ const literals = [
5
+ 'delete',
6
+ 'get',
7
+ 'head',
8
+ 'link',
9
+ 'options',
10
+ 'patch',
11
+ 'post',
12
+ 'purge',
13
+ 'put',
14
+ 'unlink',
15
+ ];
16
+ // noinspection JSUnusedGlobalSymbols
17
+ /**
18
+ * @type {ReadonlyArray<HttpMethod>}
19
+ * */
20
+ exports.HttpMethodItems = literals;
21
+ //# sourceMappingURL=http-method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-method.js","sourceRoot":"","sources":["../../src/shared/http-method.ts"],"names":[],"mappings":";;;AAAA,MAAM,QAAQ,GAAG;IACb,QAAQ;IACR,KAAK;IACL,MAAM;IACN,MAAM;IACN,SAAS;IACT,OAAO;IACP,MAAM;IACN,OAAO;IACP,KAAK;IACL,QAAQ;CACF,CAAC;AAMX,qCAAqC;AACrC;;KAEK;AACQ,QAAA,eAAe,GAA8B,QAAQ,CAAC"}
@@ -0,0 +1,10 @@
1
+ declare const literals: readonly ["http", "https"];
2
+ /**
3
+ * Http Protocol
4
+ * */
5
+ export type HttpProtocol = typeof literals[number];
6
+ /**
7
+ * @type {ReadonlyArray<HttpProtocol>}
8
+ * */
9
+ export declare const HttpProtocolItems: ReadonlyArray<HttpProtocol>;
10
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpProtocolItems = void 0;
4
+ const literals = [
5
+ 'http',
6
+ 'https',
7
+ ];
8
+ // noinspection JSUnusedGlobalSymbols
9
+ /**
10
+ * @type {ReadonlyArray<HttpProtocol>}
11
+ * */
12
+ exports.HttpProtocolItems = literals;
13
+ //# sourceMappingURL=http-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-protocol.js","sourceRoot":"","sources":["../../src/shared/http-protocol.ts"],"names":[],"mappings":";;;AAAA,MAAM,QAAQ,GAAG;IACb,MAAM;IACN,OAAO;CACD,CAAC;AAKX,qCAAqC;AACrC;;KAEK;AACQ,QAAA,iBAAiB,GAAgC,QAAQ,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './index.types';
2
+ export * from './http-method';
3
+ export * from './http-protocol';
4
+ export * from './http-event';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./index.types"), exports);
18
+ __exportStar(require("./http-method"), exports);
19
+ __exportStar(require("./http-protocol"), exports);
20
+ __exportStar(require("./http-event"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,gDAA8B;AAC9B,kDAAgC;AAChC,+CAA6B"}
@@ -0,0 +1,41 @@
1
+ import type { OneOrMore } from "@leyyo/common";
2
+ /**
3
+ * Http path params parameters
4
+ * */
5
+ export interface HttpParams {
6
+ [key: string]: string | undefined;
7
+ }
8
+ /**
9
+ * Http cookie parameters
10
+ * */
11
+ export interface HttpCookies {
12
+ [key: string]: string | undefined;
13
+ }
14
+ /**
15
+ * Http headers
16
+ * */
17
+ export interface HttpHeaders {
18
+ [key: string]: OneOrMore<string> | undefined;
19
+ }
20
+ /**
21
+ * Http query parameters
22
+ * */
23
+ export interface HttpQuery {
24
+ [key: string]: undefined | OneOrMore<string | HttpQuery>;
25
+ }
26
+ /**
27
+ * Http data
28
+ * */
29
+ export interface HttpData {
30
+ }
31
+ export type _StreamCompose = (source: any) => void;
32
+ export type _StreamBool = (data: any, options?: _StreamAbort) => (boolean | Promise<boolean>);
33
+ export type _StreamVoid = (data: any, options?: _StreamAbort) => (void | Promise<void>);
34
+ export type _StreamGeneric<T> = (data: any, options?: _StreamAbort) => data is T;
35
+ export type _StreamReduce<T> = (previous: any, data: any, options?: _StreamAbort) => T;
36
+ export interface _StreamIterator {
37
+ destroyOnReturn?: boolean;
38
+ }
39
+ export interface _StreamAbort {
40
+ signal: AbortSignal;
41
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.types.js","sourceRoot":"","sources":["../../src/shared/index.types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,35 +1,32 @@
1
1
  {
2
2
  "name": "@leyyo/http-mock",
3
- "version": "1.1.1",
4
- "description": "Fake request and response object for express",
3
+ "version": "1.3.1",
4
+ "description": "Http Mock",
5
5
  "keywords": [
6
- "request",
7
- "response"
6
+ "http mock",
7
+ "request mock",
8
+ "response mock"
8
9
  ],
9
10
  "repository": {
10
11
  "type": "git",
11
12
  "url": "git+https://github.com/leyyonet/http-mock.git"
12
13
  },
13
14
  "bugs": {
14
- "email": "mustafayelmer@gmail.com",
15
- "url": "https://github.com/leyyonet/http-mock/issues"
16
- },
17
- "homepage": "https://github.com/leyyonet/http-mock#readme",
18
- "author": {
19
- "name": "Mustafa Yelmer",
15
+ "url": "https://github.com/leyyonet/http-mock.git/issues",
20
16
  "email": "mustafayelmer@gmail.com"
21
17
  },
18
+ "homepage": "https://github.com/leyyonet/http-mock.git/#readme",
19
+ "author": "Mustafa Yelmer <mustafayelmer@gmail.com>",
22
20
  "main": "dist/index.js",
21
+ "type": "commonjs",
23
22
  "scripts": {
24
23
  "clear": "rimraf dist",
25
24
  "lint": "eslint src/**/*.ts",
26
- "build": "npm run clear && tsc && cp -rv src/assets dist/assets/",
27
- "test": "jest --config=jest.json",
25
+ "asset": "node -r ts-node/register commands/assets.ts",
26
+ "build": "npm run clear && tsc && npm run asset",
27
+ "test": "npx jest --config=jest.json --clearCache && npx jest --config=jest.json --verbose",
28
28
  "test:watch": "jest --watch --config=jest.json",
29
29
  "test:coverage": "jest --config=jest.json --coverage --coverageDirectory=coverage",
30
- "simulate": "npm run lint && npm run build && node dist/server.js",
31
- "run:js": "node dist/index.js",
32
- "run:ts": "node -r ts-node/register src/index.ts",
33
30
  "~publish": "npm run build && npm publish -access=public"
34
31
  },
35
32
  "files": [
@@ -37,27 +34,26 @@
37
34
  ],
38
35
  "license": "ISC",
39
36
  "devDependencies": {
40
- "@types/express": "^4.17.13",
41
- "@types/jest": "^28.1.4",
42
- "@types/node": "^18.0.0",
43
- "@typescript-eslint/eslint-plugin": "^5.30.0",
44
- "@typescript-eslint/parser": "^5.30.0",
45
- "eslint": "^8.18.0",
46
- "eslint-config-prettier": "^8.5.0",
47
- "eslint-config-standard": "^17.0.0",
37
+ "@babel/preset-typescript": "^7.27.0",
38
+ "@types/express": "^5.0.6",
39
+ "@types/geoip-lite": "^1.4.4",
40
+ "@types/jest": "^29.5.14",
41
+ "@types/node": "^22.14.0",
42
+ "@typescript-eslint/eslint-plugin": "^8.29.0",
43
+ "@typescript-eslint/parser": "^8.29.0",
44
+ "eslint": "^9.23.0",
45
+ "eslint-config-prettier": "^10.1.1",
46
+ "eslint-plugin-jsdoc": "^50.6.9",
48
47
  "eslint-plugin-node": "^11.1.0",
49
- "jest": "^28.1.2",
50
- "prettier": "^2.7.1",
51
- "rimraf": "^3.0.2",
52
- "ts-jest": "^28.0.5",
48
+ "jest": "^29.7.0",
49
+ "prettier": "^3.5.3",
50
+ "rimraf": "^6.0.1",
51
+ "ts-jest": "^29.3.1",
53
52
  "ts-node": "^10.8.1",
54
- "typescript": "^4.7.4"
53
+ "typescript": "^5.7.3"
55
54
  },
56
55
  "dependencies": {
57
- "@leyyo/cast": "^1.1.1",
58
- "@leyyo/core": "^1.1.2",
59
- "@leyyo/fqn": "^1.1.1",
60
- "@leyyo/scalar": "^1.1.1",
61
- "mime": "^3.0.0"
56
+ "@leyyo/common": "^1.3.3",
57
+ "mime-types": "^3.0.2"
62
58
  }
63
59
  }
@@ -1,3 +0,0 @@
1
- export declare const BASE_NAME = "http-mock";
2
- export declare const COMPONENT_NAME: string;
3
- export declare const FQN_NAME: string[];
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FQN_NAME = exports.COMPONENT_NAME = exports.BASE_NAME = void 0;
4
- const core_1 = require("@leyyo/core");
5
- exports.BASE_NAME = 'http-mock';
6
- exports.COMPONENT_NAME = `@${core_1.LEYYO_NAME}/${exports.BASE_NAME}`;
7
- exports.FQN_NAME = [core_1.LEYYO_NAME, exports.BASE_NAME];
8
- //# sourceMappingURL=internal-component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal-component.js","sourceRoot":"","sources":["../src/internal-component.ts"],"names":[],"mappings":";;;AAAA,sCAAuC;AAE1B,QAAA,SAAS,GAAG,WAAW,CAAC;AACxB,QAAA,cAAc,GAAG,IAAI,iBAAU,IAAI,iBAAS,EAAE,CAAC;AAC/C,QAAA,QAAQ,GAAG,CAAC,iBAAU,EAAE,iBAAS,CAAC,CAAC"}
@@ -1,20 +0,0 @@
1
- import { ArraySome, HttpMethod, OneOrMore, RecLike } from "@leyyo/core";
2
- import { Request } from "express";
3
- import { ResponseData } from "../response";
4
- export declare type RequestBody = ArraySome | RecLike | string | unknown;
5
- export declare type RequestErrorCallback = (error?: Error) => void;
6
- export interface MockServiceRequest {
7
- method: HttpMethod;
8
- url: string;
9
- body?: RequestBody;
10
- headers?: RecLike<OneOrMore<string>>;
11
- cookies?: RecLike;
12
- signedCookies?: RecLike;
13
- }
14
- export interface MockRequestLike<B = RequestBody, L extends RecLike = RecLike> extends Request<RecLike, B, ResponseData, RecLike, L> {
15
- isFake?: boolean;
16
- locals?: L;
17
- }
18
- export interface PipeOption {
19
- end?: boolean;
20
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-types.js","sourceRoot":"","sources":["../../src/request/index-types.ts"],"names":[],"mappings":""}
@@ -1,121 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
- import { Application, MediaType, Request } from "express";
6
- import { RecLike, FuncLike } from "@leyyo/core";
7
- import { Socket } from "net";
8
- import { IncomingHttpHeaders } from "http";
9
- import RangeParser from "range-parser";
10
- import { Response, NextFunction } from "express-serve-static-core";
11
- import { MockRequestLike, MockServiceRequest, PipeOption, RequestBody, RequestErrorCallback } from "./index-types";
12
- export declare class MockRequest<T = RequestBody, L extends RecLike = RecLike> implements MockRequestLike<T, L>, RecLike {
13
- readonly isFake: boolean;
14
- locals: L;
15
- [key: string]: unknown;
16
- [Symbol.asyncIterator](): AsyncIterableIterator<any>;
17
- res?: Response<unknown, L>;
18
- next?: NextFunction;
19
- closed: boolean;
20
- errored: Error;
21
- aborted: boolean;
22
- accepted: MediaType[];
23
- app: Application;
24
- baseUrl: string;
25
- body: RequestBody;
26
- complete: boolean;
27
- connection: Socket;
28
- cookies: any;
29
- destroyed: boolean;
30
- fresh: boolean;
31
- headers: IncomingHttpHeaders;
32
- host: string;
33
- hostname: string;
34
- httpVersion: string;
35
- httpVersionMajor: number;
36
- httpVersionMinor: number;
37
- ip: string;
38
- ips: string[];
39
- method: string;
40
- originalUrl: string;
41
- params: RecLike;
42
- path: string;
43
- protocol: string;
44
- query: RecLike;
45
- rawHeaders: string[];
46
- rawTrailers: string[];
47
- readable: boolean;
48
- readonly readableAborted: boolean;
49
- readonly readableDidRead: boolean;
50
- readonly readableEncoding: BufferEncoding | null;
51
- readonly readableEnded: boolean;
52
- readonly readableFlowing: boolean | null;
53
- readonly readableHighWaterMark: number;
54
- readonly readableLength: number;
55
- readonly readableObjectMode: boolean;
56
- route: any;
57
- secure: boolean;
58
- signedCookies: any;
59
- socket: Socket;
60
- stale: boolean;
61
- statusCode: number | undefined;
62
- statusMessage: string | undefined;
63
- subdomains: string[];
64
- trailers: NodeJS.Dict<string>;
65
- url: string;
66
- xhr: boolean;
67
- constructor(service?: MockServiceRequest, origin?: Request, custom?: RecLike);
68
- _construct(callback: RequestErrorCallback): void;
69
- _destroy(error: Error | null, callback: RequestErrorCallback): void;
70
- _read(size: number): void;
71
- destroy(error?: Error): this;
72
- read(size: number | undefined): string | Buffer;
73
- push(chunk: any, encoding?: BufferEncoding): boolean;
74
- isPaused(): boolean;
75
- resume(): this;
76
- setEncoding(encoding: BufferEncoding): this;
77
- setTimeout(msecs: number, callback?: FuncLike): this;
78
- unpipe(destination?: NodeJS.WritableStream): this;
79
- unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
80
- wrap(stream: NodeJS.ReadableStream): this;
81
- accepts(): string[];
82
- accepts(type: string): string | false;
83
- accepts(type: string[]): string | false;
84
- accepts(...type: string[]): string | false;
85
- acceptsCharsets(): string[];
86
- acceptsCharsets(charset: string): string | false;
87
- acceptsCharsets(charset: string[]): string | false;
88
- acceptsCharsets(...charset: string[]): string | false;
89
- acceptsEncodings(): string[];
90
- acceptsEncodings(encoding: string): string | false;
91
- acceptsEncodings(encoding: string[]): string | false;
92
- acceptsEncodings(...encoding: string[]): string | false;
93
- acceptsLanguages(): string[];
94
- acceptsLanguages(lang: string): string | false;
95
- acceptsLanguages(lang: string[]): string | false;
96
- acceptsLanguages(...lang: string[]): string | false;
97
- addListener(eventName: string | symbol, listener: FuncLike): this;
98
- emit(eventName: string | symbol, ...args: any[]): boolean;
99
- eventNames(): Array<string | symbol>;
100
- get(name: "set-cookie"): string[] | undefined;
101
- get(name: string): string | undefined;
102
- getMaxListeners(): number;
103
- header(name: "set-cookie"): string[] | undefined;
104
- header(name: string): string | undefined;
105
- is(type: string | string[]): string | false | null;
106
- listenerCount(eventName: string | symbol): number;
107
- listeners(eventName: string | symbol): Array<FuncLike>;
108
- off(eventName: string | symbol, listener: FuncLike): this;
109
- on(eventName: string | symbol, listener: FuncLike): this;
110
- once(eventName: string | symbol, listener: FuncLike): this;
111
- param(name: string, defaultValue?: any): string;
112
- pause(): this;
113
- pipe<T>(destination: T, options?: PipeOption): T;
114
- prependListener(eventName: string | symbol, listener: FuncLike): this;
115
- prependOnceListener(eventName: string | symbol, listener: FuncLike): this;
116
- range(size: number, options?: RangeParser.Options): RangeParser.Ranges | RangeParser.Result | undefined;
117
- rawListeners(eventName: string | symbol): Array<FuncLike>;
118
- removeAllListeners(event?: string | symbol): this;
119
- removeListener(eventName: string | symbol, listener: FuncLike): this;
120
- setMaxListeners(n: number): this;
121
- }