Skip to content

Commit

Permalink
🏭 init
Browse files Browse the repository at this point in the history
  • Loading branch information
elbywan committed Oct 3, 2017
1 parent 494dbf8 commit ac4ae15
Show file tree
Hide file tree
Showing 15 changed files with 7,642 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# IDE
.vscode

6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js

node_js:
- "stable"

after_success: npm run coverage
157 changes: 157 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
declare const _default: (url?: string, opts?: {}) => Wretcher;
export default _default;
/**
* The Wretcher class used to perform easy fetch requests.
*
* Almost every method of this class return a fresh Wretcher object.
*/
export declare class Wretcher {
private _url;
private _options;
constructor(_url: string, _options?: {});
/**
* Sets the default fetch options used for every subsequent fetch call.
* @param opts New default options
*/
defaults(opts: any): this;
/**
* Mixins the default fetch options used for every subsequent fetch calls.
* @param opts Options to mixin with the current default options
*/
mixdefaults(opts: any): this;
/**
* Sets the method (text, json ...) used to parse the data contained in the response body in case of an HTTP error.
*
* Persists for every subsequent requests.
*
* Default is "text".
*/
errorType(method: any): this;
/**
* Returns a new Wretcher object with the url specified and the same options.
* @param url String url
*/
url(url: string): Wretcher;
/**
* Returns a new Wretcher object with the same url and new options.
* @param options New options
*/
options(options: Object): Wretcher;
/**
* Converts a javascript object to query parameters,
* then appends this query string to the current url.
*
* ```
* let w = wretch("http://example.com") // url is http://example.com
* w = w.query({ a: 1, b : 2 }) // url is now http://example.com?a=1&b=2
* ```
*
* @param qp An object which will be converted.
*/
query(qp: Object): Wretcher;
/**
* Shortcut to set the "Accept" header.
* @param what Header value
*/
accept(what: string): Wretcher;
/**
* Performs a get request.
*/
get(opts?: {}): {
res: () => any;
json: () => any;
blob: () => any;
formData: () => any;
arrayBuffer: () => any;
text: () => any;
error: (code: number, cb: any) => any;
badRequest: (cb: any) => any;
unauthorized: (cb: any) => any;
forbidden: (cb: any) => any;
notFound: (cb: any) => any;
timeout: (cb: any) => any;
internalError: (cb: any) => any;
};
/**
* Performs a delete request.
*/
delete(opts?: {}): {
res: () => any;
json: () => any;
blob: () => any;
formData: () => any;
arrayBuffer: () => any;
text: () => any;
error: (code: number, cb: any) => any;
badRequest: (cb: any) => any;
unauthorized: (cb: any) => any;
forbidden: (cb: any) => any;
notFound: (cb: any) => any;
timeout: (cb: any) => any;
internalError: (cb: any) => any;
};
/**
* Performs a put request.
*/
put(opts?: {}): {
res: () => any;
json: () => any;
blob: () => any;
formData: () => any;
arrayBuffer: () => any;
text: () => any;
error: (code: number, cb: any) => any;
badRequest: (cb: any) => any;
unauthorized: (cb: any) => any;
forbidden: (cb: any) => any;
notFound: (cb: any) => any;
timeout: (cb: any) => any;
internalError: (cb: any) => any;
};
/**
* Performs a post request.
*/
post(opts?: {}): {
res: () => any;
json: () => any;
blob: () => any;
formData: () => any;
arrayBuffer: () => any;
text: () => any;
error: (code: number, cb: any) => any;
badRequest: (cb: any) => any;
unauthorized: (cb: any) => any;
forbidden: (cb: any) => any;
notFound: (cb: any) => any;
timeout: (cb: any) => any;
internalError: (cb: any) => any;
};
/**
* Performs a patch request.
*/
patch(opts?: {}): {
res: () => any;
json: () => any;
blob: () => any;
formData: () => any;
arrayBuffer: () => any;
text: () => any;
error: (code: number, cb: any) => any;
badRequest: (cb: any) => any;
unauthorized: (cb: any) => any;
forbidden: (cb: any) => any;
notFound: (cb: any) => any;
timeout: (cb: any) => any;
internalError: (cb: any) => any;
};
/**
* Sets the content type header, stringifies an object and sets the request body.
* @param obj An object
*/
json(jsObject: any): Wretcher;
/**
* Converts the javascript object to a FormData and sets the request body.
* @param obj An object
*/
formData(obj: any): Wretcher;
}
1 change: 1 addition & 0 deletions dist/mix.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const mix: (one: Object, two: Object, mergeArrays?: boolean) => Object;
2 changes: 2 additions & 0 deletions dist/wretch.js

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

1 change: 1 addition & 0 deletions dist/wretch.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit ac4ae15

Please sign in to comment.