@mptool/all 0.6.2 → 0.6.4

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.
package/lib/index.d.mts CHANGED
@@ -8,10 +8,10 @@ declare const isMp: boolean;
8
8
  type EventType = string | symbol;
9
9
  type Handler<T = unknown> = (event: T) => void | Promise<void>;
10
10
  type WildcardHandler<T = Record<string, unknown>> = (type: keyof T, event: T[keyof T]) => void | Promise<void>;
11
- type EventHandlerList<T = unknown> = Array<Handler<T>>;
12
- type WildCardEventHandlerList<T = Record<string, unknown>> = Array<WildcardHandler<T>>;
13
- type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<keyof Events | "*", EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>>;
14
- interface EmitterInstance<Events extends Record<EventType, unknown>> {
11
+ type EventHandlerList<T = unknown> = Handler<T>[];
12
+ type WildCardEventHandlerList<T = Record<string, unknown>> = WildcardHandler<T>[];
13
+ type EventHandlerMap<Events> = Map<keyof Events | "*", EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>>;
14
+ interface EmitterInstance<Events> {
15
15
  all: EventHandlerMap<Events>;
16
16
  on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;
17
17
  on(type: "*", handler: WildcardHandler<Events>): void;
@@ -27,7 +27,7 @@ interface EmitterInstance<Events extends Record<EventType, unknown>> {
27
27
  * @name emitter
28
28
  * @returns Emitter
29
29
  */
30
- declare function Emitter<Events extends Record<EventType, unknown>>(all?: EventHandlerMap<Events>): EmitterInstance<Events>;
30
+ declare function Emitter<Events>(all?: EventHandlerMap<Events>): EmitterInstance<Events>;
31
31
 
32
32
  /** 写入普通日志 */
33
33
  declare const debug: (...args: any[]) => void;
@@ -145,7 +145,7 @@ declare function wrapFunction<T>(original: ((this: T, ...args: any[]) => Promise
145
145
  * }, 15);
146
146
  * ```
147
147
  */
148
- declare const lock: <T, A extends unknown[], R>(fn: (this: T, release: () => void, ...args: A) => R, ctx?: T | undefined) => (this: T, ...args: A) => R | undefined;
148
+ declare const lock: <T, A extends unknown[], R>(fn: (this: T, release: () => void, ...args: A) => R, ctx?: T) => ((this: T, ...args: A) => R | undefined);
149
149
  /**
150
150
  * 包装函数保证其之被调用一次
151
151
  *
@@ -163,7 +163,7 @@ declare const lock: <T, A extends unknown[], R>(fn: (this: T, release: () => voi
163
163
  * counter(); // count is still 1
164
164
  * ```
165
165
  */
166
- declare const once: <T, A extends unknown[], R>(func: (...args: A) => R, ctx?: T | undefined) => (this: T, ...args: A) => R | undefined;
166
+ declare const once: <T, A extends unknown[], R>(func: (...args: A) => R, ctx?: T) => ((this: T, ...args: A) => R | undefined);
167
167
  interface Task<ArgType extends unknown[] = unknown[], This = unknown> {
168
168
  /** 函数本身 */
169
169
  func: (this: This, next: () => void, ...args: ArgType) => void;
@@ -182,7 +182,7 @@ declare class Queue {
182
182
  /** 允许同时并行的任务数 */
183
183
  capacity?: number);
184
184
  /** 回调队列 */
185
- funcQueue: Task<any, any>[];
185
+ funcQueue: Task[];
186
186
  /** 正在运行的数量 */
187
187
  running: number;
188
188
  /** 执行下一个函数 */
@@ -193,7 +193,7 @@ declare class Queue {
193
193
  * @param ctx 函数运行上下文
194
194
  * @param args 函数参数
195
195
  */
196
- add<A extends unknown[], T>(func: (next: () => void, ...args: A) => void, ctx?: T, ...args: A): void;
196
+ add<A extends any[], T>(func: (next: () => void, ...args: A) => void, ctx?: T, ...args: A): void;
197
197
  /** 清除队列,不再执行尚未执行的函数 */
198
198
  clear(): void;
199
199
  }
@@ -206,7 +206,7 @@ declare class Queue {
206
206
  * @returns 包装过的函数
207
207
  * @async
208
208
  */
209
- declare const funcQueue: <A extends unknown[], T = unknown>(fn: (next: () => void, ...args: A) => void, capacity?: number) => (this: T, ...args: A) => void;
209
+ declare const funcQueue: <A extends unknown[], T = unknown>(fn: (next: () => void, ...args: A) => void, capacity?: number) => ((this: T, ...args: A) => void);
210
210
 
211
211
  type Props = Record<string, unknown>;
212
212
  type PropsOptions<Property = Props> = {
@@ -230,11 +230,7 @@ type PropMethod<Type, TypeConstructor = any> = Type extends (...args: any) => an
230
230
  (): Type;
231
231
  readonly prototype: TypeConstructor;
232
232
  } : never;
233
- type PropConstructor<Type = any> = {
234
- new (...args: any[]): Type & {};
235
- } | {
236
- (): Type;
237
- } | PropMethod<Type>;
233
+ type PropConstructor<Type = any> = (new (...args: any[]) => Type & {}) | (() => Type) | PropMethod<Type>;
238
234
  type PropType<T> = PropConstructor<T> | PropConstructor<T>[];
239
235
  type RequiredKeys<T> = {
240
236
  [K in keyof T]: T[K] extends {
@@ -371,9 +367,7 @@ type ComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Prope
371
367
  /** 组件属性 */
372
368
  properties: Property;
373
369
  }> & Partial<WechatMiniprogram.Component.Method<Method, IsPage>> & Partial<WechatMiniprogram.Component.OtherOption> & Partial<ComponentLifetimes> & ThisType<ComponentInstance<Data, Property, Method, CustomInstanceProperty, IsPage>>;
374
- interface ComponentConstructor {
375
- <Data extends WechatMiniprogram.Component.DataOption, Property extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, CustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false>(options: ComponentOptions<Data, Property, Method, CustomInstanceProperty, IsPage>): string;
376
- }
370
+ type ComponentConstructor = <Data extends WechatMiniprogram.Component.DataOption, Property extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, CustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false>(options: ComponentOptions<Data, Property, Method, CustomInstanceProperty, IsPage>) => string;
377
371
  type TrivialComponentInstance = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: unknown[]) => any>>;
378
372
  type TrivialComponentOptions = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: any[]) => any>>;
379
373
  type RefMap = Record<string, TrivialComponentInstance>;
@@ -571,9 +565,7 @@ interface NavigatorMethods {
571
565
  $bindBack(): Promise<void> | void;
572
566
  }
573
567
 
574
- interface PageQuery {
575
- [props: string]: string;
576
- }
568
+ type PageQuery = Record<string, string>;
577
569
  interface PageState {
578
570
  /** 是否是打开的第一个页面 */
579
571
  firstOpen: boolean;
@@ -666,9 +658,7 @@ type PageInstance<Data extends WechatMiniprogram.IAnyObject, Custom extends Wech
666
658
  type PageOptions<Data extends WechatMiniprogram.IAnyObject, Custom extends WechatMiniprogram.IAnyObject> = (Custom & Partial<WechatMiniprogram.Page.Data<Data>> & Partial<WechatMiniprogram.Page.ILifetime & ExtendedPageLifeCycles> & Partial<ExtendedPageProperties> & {
667
659
  options?: WechatMiniprogram.Component.ComponentOptions;
668
660
  }) & ThisType<PageInstance<Data, Custom>>;
669
- interface PageConstructor {
670
- <Data extends WechatMiniprogram.IAnyObject, Custom extends WechatMiniprogram.IAnyObject>(name: string, options: PageOptions<Data, Custom>): void;
671
- }
661
+ type PageConstructor = <Data extends WechatMiniprogram.IAnyObject, Custom extends WechatMiniprogram.IAnyObject>(name: string, options: PageOptions<Data, Custom>) => void;
672
662
  type TrivialPageInstance = PageInstance<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>;
673
663
  type TrivialPageOptions = PageOptions<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>;
674
664
 
@@ -740,9 +730,7 @@ interface ExtendsAppOptions {
740
730
  type ExtendedAppMethods = InstanceEmitterMethods;
741
731
  type AppOptions<Custom> = ExtendsAppOptions & Partial<WechatMiniprogram.App.Option> & Custom & Partial<ExtendedAppMethods> & ThisType<AppInstance<Custom>>;
742
732
  type AppInstance<Custom> = AppOptions<Custom> & Custom & ExtendedAppMethods;
743
- interface AppConstructor {
744
- <Custom extends WechatMiniprogram.IAnyObject>(appOptions: AppOptions<Custom>): void;
745
- }
733
+ type AppConstructor = <Custom extends WechatMiniprogram.IAnyObject>(appOptions: AppOptions<Custom>) => void;
746
734
 
747
735
  /**
748
736
  * Application wrapper
@@ -1107,49 +1095,6 @@ declare class Cookie {
1107
1095
  toJSON(): CookieType;
1108
1096
  }
1109
1097
 
1110
- type HeadersInit = [string, string][] | Record<string, string> | Headers;
1111
- declare class Headers {
1112
- private headers;
1113
- private headerNames;
1114
- constructor(init?: HeadersInit);
1115
- /**
1116
- * Appends a new value onto an existing header inside a `Headers` object, or adds the header if it does not already exist.
1117
- */
1118
- append(name: string, value: string): void;
1119
- /**
1120
- * Deletes a header from the `Headers` object.
1121
- */
1122
- delete(name: string): void;
1123
- /**
1124
- * Returns a `ByteString` sequence of all the values of a header with a given name.
1125
- */
1126
- get(name: string): string | null;
1127
- /**
1128
- * Returns an array containing the values
1129
- * of all Set-Cookie headers associated
1130
- * with a response
1131
- */
1132
- getSetCookie(): string[];
1133
- /**
1134
- * Returns a boolean stating whether a `Headers` object contains a certain header.
1135
- */
1136
- has(name: string): boolean;
1137
- /**
1138
- * Sets a new value for an existing header inside a `Headers` object, or adds the header if it does not already exist.
1139
- */
1140
- set(name: string, value: string): void;
1141
- /**
1142
- * Traverses the `Headers` object,
1143
- * calling the given callback for each header.
1144
- */
1145
- forEach<ThisArg = this>(callback: (this: ThisArg, value: string, name: string, parent: this) => void, thisArg?: ThisArg): void;
1146
- keys(): IterableIterator<string>;
1147
- values(): IterableIterator<string>;
1148
- entries(): IterableIterator<[string, string]>;
1149
- toObject(): Record<string, string>;
1150
- [Symbol.iterator](): IterableIterator<[string, string]>;
1151
- }
1152
-
1153
1098
  /**
1154
1099
  * @see RFC 6265
1155
1100
  */
@@ -1290,6 +1235,49 @@ declare class CookieStore {
1290
1235
  private save;
1291
1236
  }
1292
1237
 
1238
+ type HeadersInit = [string, string][] | Record<string, string> | Headers;
1239
+ declare class Headers {
1240
+ private headers;
1241
+ private headerNames;
1242
+ constructor(init?: HeadersInit);
1243
+ /**
1244
+ * Appends a new value onto an existing header inside a `Headers` object, or adds the header if it does not already exist.
1245
+ */
1246
+ append(name: string, value: string): void;
1247
+ /**
1248
+ * Deletes a header from the `Headers` object.
1249
+ */
1250
+ delete(name: string): void;
1251
+ /**
1252
+ * Returns a `ByteString` sequence of all the values of a header with a given name.
1253
+ */
1254
+ get(name: string): string | null;
1255
+ /**
1256
+ * Returns an array containing the values
1257
+ * of all Set-Cookie headers associated
1258
+ * with a response
1259
+ */
1260
+ getSetCookie(): string[];
1261
+ /**
1262
+ * Returns a boolean stating whether a `Headers` object contains a certain header.
1263
+ */
1264
+ has(name: string): boolean;
1265
+ /**
1266
+ * Sets a new value for an existing header inside a `Headers` object, or adds the header if it does not already exist.
1267
+ */
1268
+ set(name: string, value: string): void;
1269
+ /**
1270
+ * Traverses the `Headers` object,
1271
+ * calling the given callback for each header.
1272
+ */
1273
+ forEach<ThisArg = this>(callback: (this: ThisArg, value: string, name: string, parent: this) => void, thisArg?: ThisArg): void;
1274
+ keys(): IterableIterator<string>;
1275
+ values(): IterableIterator<string>;
1276
+ entries(): IterableIterator<[string, string]>;
1277
+ toObject(): Record<string, string>;
1278
+ [Symbol.iterator](): IterableIterator<[string, string]>;
1279
+ }
1280
+
1293
1281
  declare class URLSearchParams {
1294
1282
  private params;
1295
1283
  constructor(init?: URLSearchParams | string | Record<string, string | string[]> | Iterable<[string, string]>);
package/lib/index.d.ts CHANGED
@@ -8,10 +8,10 @@ declare const isMp: boolean;
8
8
  type EventType = string | symbol;
9
9
  type Handler<T = unknown> = (event: T) => void | Promise<void>;
10
10
  type WildcardHandler<T = Record<string, unknown>> = (type: keyof T, event: T[keyof T]) => void | Promise<void>;
11
- type EventHandlerList<T = unknown> = Array<Handler<T>>;
12
- type WildCardEventHandlerList<T = Record<string, unknown>> = Array<WildcardHandler<T>>;
13
- type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<keyof Events | "*", EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>>;
14
- interface EmitterInstance<Events extends Record<EventType, unknown>> {
11
+ type EventHandlerList<T = unknown> = Handler<T>[];
12
+ type WildCardEventHandlerList<T = Record<string, unknown>> = WildcardHandler<T>[];
13
+ type EventHandlerMap<Events> = Map<keyof Events | "*", EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>>;
14
+ interface EmitterInstance<Events> {
15
15
  all: EventHandlerMap<Events>;
16
16
  on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;
17
17
  on(type: "*", handler: WildcardHandler<Events>): void;
@@ -27,7 +27,7 @@ interface EmitterInstance<Events extends Record<EventType, unknown>> {
27
27
  * @name emitter
28
28
  * @returns Emitter
29
29
  */
30
- declare function Emitter<Events extends Record<EventType, unknown>>(all?: EventHandlerMap<Events>): EmitterInstance<Events>;
30
+ declare function Emitter<Events>(all?: EventHandlerMap<Events>): EmitterInstance<Events>;
31
31
 
32
32
  /** 写入普通日志 */
33
33
  declare const debug: (...args: any[]) => void;
@@ -145,7 +145,7 @@ declare function wrapFunction<T>(original: ((this: T, ...args: any[]) => Promise
145
145
  * }, 15);
146
146
  * ```
147
147
  */
148
- declare const lock: <T, A extends unknown[], R>(fn: (this: T, release: () => void, ...args: A) => R, ctx?: T | undefined) => (this: T, ...args: A) => R | undefined;
148
+ declare const lock: <T, A extends unknown[], R>(fn: (this: T, release: () => void, ...args: A) => R, ctx?: T) => ((this: T, ...args: A) => R | undefined);
149
149
  /**
150
150
  * 包装函数保证其之被调用一次
151
151
  *
@@ -163,7 +163,7 @@ declare const lock: <T, A extends unknown[], R>(fn: (this: T, release: () => voi
163
163
  * counter(); // count is still 1
164
164
  * ```
165
165
  */
166
- declare const once: <T, A extends unknown[], R>(func: (...args: A) => R, ctx?: T | undefined) => (this: T, ...args: A) => R | undefined;
166
+ declare const once: <T, A extends unknown[], R>(func: (...args: A) => R, ctx?: T) => ((this: T, ...args: A) => R | undefined);
167
167
  interface Task<ArgType extends unknown[] = unknown[], This = unknown> {
168
168
  /** 函数本身 */
169
169
  func: (this: This, next: () => void, ...args: ArgType) => void;
@@ -182,7 +182,7 @@ declare class Queue {
182
182
  /** 允许同时并行的任务数 */
183
183
  capacity?: number);
184
184
  /** 回调队列 */
185
- funcQueue: Task<any, any>[];
185
+ funcQueue: Task[];
186
186
  /** 正在运行的数量 */
187
187
  running: number;
188
188
  /** 执行下一个函数 */
@@ -193,7 +193,7 @@ declare class Queue {
193
193
  * @param ctx 函数运行上下文
194
194
  * @param args 函数参数
195
195
  */
196
- add<A extends unknown[], T>(func: (next: () => void, ...args: A) => void, ctx?: T, ...args: A): void;
196
+ add<A extends any[], T>(func: (next: () => void, ...args: A) => void, ctx?: T, ...args: A): void;
197
197
  /** 清除队列,不再执行尚未执行的函数 */
198
198
  clear(): void;
199
199
  }
@@ -206,7 +206,7 @@ declare class Queue {
206
206
  * @returns 包装过的函数
207
207
  * @async
208
208
  */
209
- declare const funcQueue: <A extends unknown[], T = unknown>(fn: (next: () => void, ...args: A) => void, capacity?: number) => (this: T, ...args: A) => void;
209
+ declare const funcQueue: <A extends unknown[], T = unknown>(fn: (next: () => void, ...args: A) => void, capacity?: number) => ((this: T, ...args: A) => void);
210
210
 
211
211
  type Props = Record<string, unknown>;
212
212
  type PropsOptions<Property = Props> = {
@@ -230,11 +230,7 @@ type PropMethod<Type, TypeConstructor = any> = Type extends (...args: any) => an
230
230
  (): Type;
231
231
  readonly prototype: TypeConstructor;
232
232
  } : never;
233
- type PropConstructor<Type = any> = {
234
- new (...args: any[]): Type & {};
235
- } | {
236
- (): Type;
237
- } | PropMethod<Type>;
233
+ type PropConstructor<Type = any> = (new (...args: any[]) => Type & {}) | (() => Type) | PropMethod<Type>;
238
234
  type PropType<T> = PropConstructor<T> | PropConstructor<T>[];
239
235
  type RequiredKeys<T> = {
240
236
  [K in keyof T]: T[K] extends {
@@ -371,9 +367,7 @@ type ComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Prope
371
367
  /** 组件属性 */
372
368
  properties: Property;
373
369
  }> & Partial<WechatMiniprogram.Component.Method<Method, IsPage>> & Partial<WechatMiniprogram.Component.OtherOption> & Partial<ComponentLifetimes> & ThisType<ComponentInstance<Data, Property, Method, CustomInstanceProperty, IsPage>>;
374
- interface ComponentConstructor {
375
- <Data extends WechatMiniprogram.Component.DataOption, Property extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, CustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false>(options: ComponentOptions<Data, Property, Method, CustomInstanceProperty, IsPage>): string;
376
- }
370
+ type ComponentConstructor = <Data extends WechatMiniprogram.Component.DataOption, Property extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, CustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false>(options: ComponentOptions<Data, Property, Method, CustomInstanceProperty, IsPage>) => string;
377
371
  type TrivialComponentInstance = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: unknown[]) => any>>;
378
372
  type TrivialComponentOptions = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: any[]) => any>>;
379
373
  type RefMap = Record<string, TrivialComponentInstance>;
@@ -571,9 +565,7 @@ interface NavigatorMethods {
571
565
  $bindBack(): Promise<void> | void;
572
566
  }
573
567
 
574
- interface PageQuery {
575
- [props: string]: string;
576
- }
568
+ type PageQuery = Record<string, string>;
577
569
  interface PageState {
578
570
  /** 是否是打开的第一个页面 */
579
571
  firstOpen: boolean;
@@ -666,9 +658,7 @@ type PageInstance<Data extends WechatMiniprogram.IAnyObject, Custom extends Wech
666
658
  type PageOptions<Data extends WechatMiniprogram.IAnyObject, Custom extends WechatMiniprogram.IAnyObject> = (Custom & Partial<WechatMiniprogram.Page.Data<Data>> & Partial<WechatMiniprogram.Page.ILifetime & ExtendedPageLifeCycles> & Partial<ExtendedPageProperties> & {
667
659
  options?: WechatMiniprogram.Component.ComponentOptions;
668
660
  }) & ThisType<PageInstance<Data, Custom>>;
669
- interface PageConstructor {
670
- <Data extends WechatMiniprogram.IAnyObject, Custom extends WechatMiniprogram.IAnyObject>(name: string, options: PageOptions<Data, Custom>): void;
671
- }
661
+ type PageConstructor = <Data extends WechatMiniprogram.IAnyObject, Custom extends WechatMiniprogram.IAnyObject>(name: string, options: PageOptions<Data, Custom>) => void;
672
662
  type TrivialPageInstance = PageInstance<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>;
673
663
  type TrivialPageOptions = PageOptions<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>;
674
664
 
@@ -740,9 +730,7 @@ interface ExtendsAppOptions {
740
730
  type ExtendedAppMethods = InstanceEmitterMethods;
741
731
  type AppOptions<Custom> = ExtendsAppOptions & Partial<WechatMiniprogram.App.Option> & Custom & Partial<ExtendedAppMethods> & ThisType<AppInstance<Custom>>;
742
732
  type AppInstance<Custom> = AppOptions<Custom> & Custom & ExtendedAppMethods;
743
- interface AppConstructor {
744
- <Custom extends WechatMiniprogram.IAnyObject>(appOptions: AppOptions<Custom>): void;
745
- }
733
+ type AppConstructor = <Custom extends WechatMiniprogram.IAnyObject>(appOptions: AppOptions<Custom>) => void;
746
734
 
747
735
  /**
748
736
  * Application wrapper
@@ -1107,49 +1095,6 @@ declare class Cookie {
1107
1095
  toJSON(): CookieType;
1108
1096
  }
1109
1097
 
1110
- type HeadersInit = [string, string][] | Record<string, string> | Headers;
1111
- declare class Headers {
1112
- private headers;
1113
- private headerNames;
1114
- constructor(init?: HeadersInit);
1115
- /**
1116
- * Appends a new value onto an existing header inside a `Headers` object, or adds the header if it does not already exist.
1117
- */
1118
- append(name: string, value: string): void;
1119
- /**
1120
- * Deletes a header from the `Headers` object.
1121
- */
1122
- delete(name: string): void;
1123
- /**
1124
- * Returns a `ByteString` sequence of all the values of a header with a given name.
1125
- */
1126
- get(name: string): string | null;
1127
- /**
1128
- * Returns an array containing the values
1129
- * of all Set-Cookie headers associated
1130
- * with a response
1131
- */
1132
- getSetCookie(): string[];
1133
- /**
1134
- * Returns a boolean stating whether a `Headers` object contains a certain header.
1135
- */
1136
- has(name: string): boolean;
1137
- /**
1138
- * Sets a new value for an existing header inside a `Headers` object, or adds the header if it does not already exist.
1139
- */
1140
- set(name: string, value: string): void;
1141
- /**
1142
- * Traverses the `Headers` object,
1143
- * calling the given callback for each header.
1144
- */
1145
- forEach<ThisArg = this>(callback: (this: ThisArg, value: string, name: string, parent: this) => void, thisArg?: ThisArg): void;
1146
- keys(): IterableIterator<string>;
1147
- values(): IterableIterator<string>;
1148
- entries(): IterableIterator<[string, string]>;
1149
- toObject(): Record<string, string>;
1150
- [Symbol.iterator](): IterableIterator<[string, string]>;
1151
- }
1152
-
1153
1098
  /**
1154
1099
  * @see RFC 6265
1155
1100
  */
@@ -1290,6 +1235,49 @@ declare class CookieStore {
1290
1235
  private save;
1291
1236
  }
1292
1237
 
1238
+ type HeadersInit = [string, string][] | Record<string, string> | Headers;
1239
+ declare class Headers {
1240
+ private headers;
1241
+ private headerNames;
1242
+ constructor(init?: HeadersInit);
1243
+ /**
1244
+ * Appends a new value onto an existing header inside a `Headers` object, or adds the header if it does not already exist.
1245
+ */
1246
+ append(name: string, value: string): void;
1247
+ /**
1248
+ * Deletes a header from the `Headers` object.
1249
+ */
1250
+ delete(name: string): void;
1251
+ /**
1252
+ * Returns a `ByteString` sequence of all the values of a header with a given name.
1253
+ */
1254
+ get(name: string): string | null;
1255
+ /**
1256
+ * Returns an array containing the values
1257
+ * of all Set-Cookie headers associated
1258
+ * with a response
1259
+ */
1260
+ getSetCookie(): string[];
1261
+ /**
1262
+ * Returns a boolean stating whether a `Headers` object contains a certain header.
1263
+ */
1264
+ has(name: string): boolean;
1265
+ /**
1266
+ * Sets a new value for an existing header inside a `Headers` object, or adds the header if it does not already exist.
1267
+ */
1268
+ set(name: string, value: string): void;
1269
+ /**
1270
+ * Traverses the `Headers` object,
1271
+ * calling the given callback for each header.
1272
+ */
1273
+ forEach<ThisArg = this>(callback: (this: ThisArg, value: string, name: string, parent: this) => void, thisArg?: ThisArg): void;
1274
+ keys(): IterableIterator<string>;
1275
+ values(): IterableIterator<string>;
1276
+ entries(): IterableIterator<[string, string]>;
1277
+ toObject(): Record<string, string>;
1278
+ [Symbol.iterator](): IterableIterator<[string, string]>;
1279
+ }
1280
+
1293
1281
  declare class URLSearchParams {
1294
1282
  private params;
1295
1283
  constructor(init?: URLSearchParams | string | Record<string, string | string[]> | Iterable<[string, string]>);