Skip to content

Commit

Permalink
npm libs
Browse files Browse the repository at this point in the history
  • Loading branch information
pilotmoon committed Mar 14, 2024
1 parent ef1f5f3 commit dd5fefb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 23 deletions.
35 changes: 22 additions & 13 deletions lib/axios.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@ type MethodsHeaders = Partial<{
[Key in Method as Lowercase<Key>]: AxiosHeaders;
} & {common: AxiosHeaders}>;

type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean;
type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean);

type AxiosHeaderParser = (this: AxiosHeaders, value: AxiosHeaderValue, header: string) => any;

export class AxiosHeaders {
constructor(
headers?: RawAxiosHeaders | AxiosHeaders
headers?: RawAxiosHeaders | AxiosHeaders | string
);

[key: string]: any;

set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
set(headers?: RawAxiosHeaders | AxiosHeaders, rewrite?: boolean): AxiosHeaders;
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders;

get(headerName: string, parser: RegExp): RegExpExecArray | null;
get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue;
get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue;

has(header: string, matcher?: true | AxiosHeaderMatcher): boolean;
has(header: string, matcher?: AxiosHeaderMatcher): boolean;

delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;

Expand Down Expand Up @@ -120,10 +122,7 @@ export interface AxiosBasicCredentials {
export interface AxiosProxyConfig {
host: string;
port: number;
auth?: {
username: string;
password: string;
};
auth?: AxiosBasicCredentials;
protocol?: string;
}

Expand Down Expand Up @@ -304,6 +303,15 @@ type AxiosAdapterName = 'xhr' | 'http' | string;

type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;

export type AddressFamily = 4 | 6 | undefined;

export interface LookupAddressEntry {
address: string;
family?: AddressFamily;
}

export type LookupAddress = string | LookupAddressEntry;

export interface AxiosRequestConfig<D = any> {
url?: string;
method?: Method | string;
Expand All @@ -330,7 +338,7 @@ export interface AxiosRequestConfig<D = any> {
maxBodyLength?: number;
maxRedirects?: number;
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
beforeRedirect?: (options: Record<string, any>, responseDetails: { headers: Record<string, string> }) => void;
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>, statusCode: HttpStatusCode}) => void;
socketPath?: string | null;
transport?: any;
httpAgent?: any;
Expand All @@ -345,9 +353,10 @@ export interface AxiosRequestConfig<D = any> {
FormData?: new (...args: any[]) => object;
};
formSerializer?: FormSerializerOptions;
family?: 4 | 6 | undefined;
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: string, family: number) => void) => void) |
((hostname: string, options: object) => Promise<[address: string, family: number] | string>);
family?: AddressFamily;
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) |
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>);
withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
}

// Alias
Expand Down
30 changes: 20 additions & 10 deletions lib/htmlparser2.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/* eslint-disable */
import { Parser, ParserOptions } from "./Parser.js";
export { Parser, type ParserOptions } from "./Parser.js";
import { DomHandlerOptions, ChildNode, Element, Document } from "domhandler";
import { Parser, type ParserOptions } from "./Parser.js";
export type { Handler, ParserOptions } from "./Parser.js";
export { Parser } from "./Parser.js";
import { type DomHandlerOptions, type ChildNode, type Element, type Document } from "domhandler";
export { DomHandler, DomHandler as DefaultHandler, type DomHandlerOptions, } from "domhandler";
export type Options = ParserOptions & DomHandlerOptions;
/**
* Parses the data, returns the resulting document.
*
* @param data The data that should be parsed.
* @param options Optional options for the parser and DOM builder.
* @param options Optional options for the parser and DOM handler.
*/
export declare function parseDocument(data: string, options?: Options): Document;
/**
Expand All @@ -18,22 +19,31 @@ export declare function parseDocument(data: string, options?: Options): Document
* Use `parseDocument` to get the `Document` node instead.
*
* @param data The data that should be parsed.
* @param options Optional options for the parser and DOM builder.
* @param options Optional options for the parser and DOM handler.
* @deprecated Use `parseDocument` instead.
*/
export declare function parseDOM(data: string, options?: Options): ChildNode[];
/**
* Creates a parser instance, with an attached DOM handler.
*
* @param callback A callback that will be called once parsing has been completed.
* @param options Optional options for the parser and DOM builder.
* @param callback A callback that will be called once parsing has been completed, with the resulting document.
* @param options Optional options for the parser and DOM handler.
* @param elementCallback An optional callback that will be called every time a tag has been completed inside of the DOM.
*/
export declare function createDocumentStream(callback: (error: Error | null, document: Document) => void, options?: Options, elementCallback?: (element: Element) => void): Parser;
/**
* Creates a parser instance, with an attached DOM handler.
*
* @param callback A callback that will be called once parsing has been completed, with an array of root nodes.
* @param options Optional options for the parser and DOM handler.
* @param elementCallback An optional callback that will be called every time a tag has been completed inside of the DOM.
* @deprecated Use `createDocumentStream` instead.
*/
export declare function createDomStream(callback: (error: Error | null, dom: ChildNode[]) => void, options?: Options, elementCallback?: (element: Element) => void): Parser;
export { default as Tokenizer, type Callbacks as TokenizerCallbacks, } from "./Tokenizer.js";
export { default as Tokenizer, type Callbacks as TokenizerCallbacks, QuoteType, } from "./Tokenizer.js";
export * as ElementType from "domelementtype";
import { Feed } from "domutils";
export { getFeed } from "domutils";
import { type Feed } from "domutils";
export { getFeed, type Feed } from "domutils";
/**
* Parse a feed.
*
Expand Down

0 comments on commit dd5fefb

Please sign in to comment.