Skip to content

Commit

Permalink
fix on config handler return undefi
Browse files Browse the repository at this point in the history
  • Loading branch information
superAlibi committed Sep 17, 2024
1 parent 464d204 commit dbebc17
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 64 deletions.
7 changes: 1 addition & 6 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
{
"name": "@advanced/fetcher",
"version": "1.0.2",
"version": "1.0.3",
"exports": "./mod.ts",
"publish": {
"exclude": [
"test/"
]
},
"imports": {
"@cross/deepmerge": "jsr:@cross/deepmerge@^1.0.0",
"$std/": "https://deno.land/std@0.212.0/",
"~/": "./"
}
}
52 changes: 0 additions & 52 deletions deno.lock

This file was deleted.

4 changes: 3 additions & 1 deletion libs/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SyncEventDispatcher } from "./sync-event-dispatcher.ts";
import { deepMerge } from '@cross/deepmerge'
import { deepMerge } from 'deepmerge'

/**
* 请求拦截器
Expand Down Expand Up @@ -194,6 +194,8 @@ export class Fetcher extends SyncEventDispatcher<{
url: string,
options: FetherConfig = {},
): Promise<T> {
console.log(url);

return this.request<T>(url, {
...this.config,
...options,
Expand Down
4 changes: 2 additions & 2 deletions libs/sync-event-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export class SyncEventDispatcher<EventMap extends Record<string, unknown[]>> {
*/
public async dispatchEvent<T extends keyof EventMap, R = unknown>(type: T, data: EventMap[T]): Promise<unknown> {
const listeners = this.events[type];
if (!listeners) {
if (!listeners || !listeners.length) {
return data

}
let result: unknown
let result: unknown = data

for (const listener of listeners) {
try {
Expand Down
4 changes: 2 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from '~/libs/fetcher.ts'
export * from '~/libs/sync-event-dispatcher.ts'
export * from './libs/fetcher.ts'
export * from './libs/sync-event-dispatcher.ts'
2 changes: 1 addition & 1 deletion test/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createFetcher } from "~/libs/fetcher.ts";
import { createFetcher } from "../libs/fetcher.ts";
import { assertEquals } from "$std/assert/mod.ts";

const urlObj = new URL('https://xjm.deno.dev/api/joke', "http://localhost:300/api/joke")
Expand Down

0 comments on commit dbebc17

Please sign in to comment.