@ckpack/fetch-helper
Advanced tools
Comparing version 0.1.6 to 0.1.7
import type { FetchHelperInit, FetchHelperInput, RequestParams } from './FetchHelper.js'; | ||
export * from './FetchHelper.js'; | ||
export type WithoutBodyMethod<T = Response> = (input: FetchHelperInput, params?: RequestParams, options?: FetchHelperInit) => Promise<T>; | ||
export type WithBodyMethod<T = Response> = (input: FetchHelperInput, body?: BodyInit | Object, options?: FetchHelperInit) => Promise<T>; | ||
export type InputBodyMethod<T = Response> = (options: FetchHelperInit & { | ||
export type WithoutBodyMethod<T = Response> = <U = T>(input: FetchHelperInput, params?: RequestParams, options?: FetchHelperInit) => Promise<U>; | ||
export type WithBodyMethod<T = Response> = <U = T>(input: FetchHelperInput, body?: BodyInit | Object, options?: FetchHelperInit) => Promise<U>; | ||
export type InputBodyMethod<T = Response> = <U = T>(options: FetchHelperInit & { | ||
input: FetchHelperInput; | ||
}) => Promise<T>; | ||
}) => Promise<U>; | ||
export declare function createInstance<T = Response>(defaultConfig?: FetchHelperInit): (<T_1 = Response>(input: RequestInfo, init?: FetchHelperInit | undefined) => Promise<T_1>) & { | ||
@@ -9,0 +9,0 @@ create: typeof createInstance; |
{ | ||
"name": "@ckpack/fetch-helper", | ||
"private": false, | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "一个轻量级的工具函数库", | ||
@@ -6,0 +6,0 @@ "sideEffects": false, |
@@ -8,7 +8,7 @@ import type { FetchHelperInit, FetchHelperInput, RequestParams } from './FetchHelper.js'; | ||
export type WithoutBodyMethod<T = Response> = (input: FetchHelperInput, params?: RequestParams, options?: FetchHelperInit) => Promise<T>; | ||
export type WithBodyMethod<T = Response> = (input: FetchHelperInput, body?: BodyInit | Object, options?: FetchHelperInit) => Promise<T>; | ||
export type InputBodyMethod<T = Response> = (options: FetchHelperInit & { | ||
export type WithoutBodyMethod<T = Response> = <U = T> (input: FetchHelperInput, params?: RequestParams, options?: FetchHelperInit) => Promise<U>; | ||
export type WithBodyMethod<T = Response> = <U = T> (input: FetchHelperInput, body?: BodyInit | Object, options?: FetchHelperInit) => Promise<U>; | ||
export type InputBodyMethod<T = Response> = <U = T> (options: FetchHelperInit & { | ||
input: FetchHelperInput | ||
}) => Promise<T>; | ||
}) => Promise<U>; | ||
@@ -42,8 +42,8 @@ export function createInstance<T = Response>(defaultConfig?: FetchHelperInit) { | ||
WITHOUT_BODY_METHODS.map(val => val.toLowerCase() as Lowercase<typeof val>).forEach((value) => { | ||
instance[value] = (input, params, options) => instance<T>(input, { ...defaultConfig, params, method: value, ...options }); | ||
instance[value] = (input, params, options) => instance(input, { ...defaultConfig, params, method: value, ...options }); | ||
}); | ||
WITH_BODY_METHODS.map(val => val.toLowerCase() as Lowercase<typeof val>).forEach((value) => { | ||
instance[value] = (input, body: any, options) => instance<T>(input, { ...defaultConfig, body, method: value, ...options }); | ||
instance[value] = (input, body: any, options) => instance(input, { ...defaultConfig, body, method: value, ...options }); | ||
}); | ||
instance.request = options => instance<T>(options.input, { ...defaultConfig, ...options }); | ||
instance.request = options => instance(options.input, { ...defaultConfig, ...options }); | ||
@@ -50,0 +50,0 @@ return instance; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27309