-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Mix from '@ember/polyfills/types'; | ||
|
||
export type Nullable<T> = T | null | undefined; | ||
|
||
export type PlainObject<T = string | number | boolean> = { | ||
[key: string]: T | PlainObject<T> | PlainObject<T>[]; | ||
} | ||
|
||
export type PlainHeaders = { | ||
[key: string]: string; | ||
} | ||
|
||
export type Method = | ||
| 'HEAD' | ||
| 'GET' | ||
| 'POST' | ||
| 'PUT' | ||
| 'PATCH' | ||
| 'DELETE' | ||
| 'OPTIONS'; | ||
|
||
export type AjaxOptions = { | ||
url: string; | ||
type: Method; | ||
data?: PlainObject<string> | BodyInit; | ||
headers?: PlainHeaders; | ||
}; | ||
|
||
export type Credentials = 'omit' | 'same-origin' | 'include'; | ||
|
||
export type FetchOptions = Mix< | ||
AjaxOptions, | ||
{ body?: BodyInit | null; method?: Method, credentials: Credentials } | ||
>; | ||
|
||
export function isPlainObject(obj: any): obj is PlainObject { | ||
return Object.prototype.toString.call(obj) === '[object Object]'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters