Skip to content

Commit

Permalink
🏁 Use a Map instead of an Array for catchers
Browse files Browse the repository at this point in the history
  • Loading branch information
elbywan committed Oct 3, 2017
1 parent 7717052 commit dba8e63
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 48 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ const w = wretcher()

// No need to catch 404 or 500 code, they are already taken care of.
w.url("http://myapi.com/get/something").get().json(json => /* ... */)

// Default catchers can be overridden if needed.
w.url("...").notFound(err => /* overrides the default 'redirect' catcher */)
```
#### options(options: Object)
Expand Down
2 changes: 1 addition & 1 deletion dist/bundle/wretch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/bundle/wretch.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/resolver.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export declare type WretcherError = Error & {
text?: string;
json?: any;
};
export declare const resolver: (url: any) => (catchers?: any[]) => (opts?: {}) => {
export declare const resolver: (url: any) => (catchers?: Map<number, (error: WretcherError) => void>) => (opts?: {}) => {
res: <Result = Response>(cb?: (type: void) => Result) => Promise<Result>;
json: <Result = {
[key: string]: any;
Expand Down
16 changes: 8 additions & 8 deletions dist/resolver.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/resolver.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/wretcher.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export declare class Wretcher {
private _url;
private _options;
private _catchers;
protected constructor(_url: string, _options?: RequestInit, _catchers?: Array<(error: WretcherError) => void>);
protected constructor(_url: string, _options?: RequestInit, _catchers?: Map<number, (error: WretcherError) => void>);
static factory(url?: string, opts?: RequestInit): Wretcher;
private selfFactory({url, options, catchers}?);
/**
Expand Down
19 changes: 5 additions & 14 deletions dist/wretcher.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dba8e63

Please sign in to comment.