Skip to content

Commit

Permalink
chore(all): prepare release 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Sep 11, 2018
1 parent 65bfbf5 commit 882f8c7
Show file tree
Hide file tree
Showing 11 changed files with 344 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-fetch-client",
"version": "1.4.0",
"version": "1.5.0",
"description": "A simple client based on the Fetch standard.",
"keywords": [
"aurelia",
Expand Down
37 changes: 37 additions & 0 deletions dist/amd/aurelia-fetch-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,26 @@ define(['exports', 'aurelia-pal'], function (exports, _aureliaPal) {
return request;
};

HttpClient.prototype.get = function get(input, init) {
return this.fetch(input, init);
};

HttpClient.prototype.post = function post(input, body, init) {
return callFetch.call(this, input, body, init, 'post');
};

HttpClient.prototype.put = function put(input, body, init) {
return callFetch.call(this, input, body, init, 'put');
};

HttpClient.prototype.patch = function patch(input, body, init) {
return callFetch.call(this, input, body, init, 'patch');
};

HttpClient.prototype.delete = function _delete(input, body, init) {
return callFetch.call(this, input, body, init, 'delete');
};

return HttpClient;
}();

Expand All @@ -353,6 +373,12 @@ define(['exports', 'aurelia-pal'], function (exports, _aureliaPal) {

function trackRequestEnd() {
this.isRequesting = !! --this.activeRequestCount;
if (!this.isRequesting) {
var evt = _aureliaPal.DOM.createCustomEvent('aurelia-fetch-client-requests-drained', { bubbles: true, cancelable: true });
setTimeout(function () {
return _aureliaPal.DOM.dispatchEvent(evt);
}, 1);
}
}

function parseHeaderValues(headers) {
Expand Down Expand Up @@ -423,4 +449,15 @@ define(['exports', 'aurelia-pal'], function (exports, _aureliaPal) {
function thrower(x) {
throw x;
}

function callFetch(input, body, init, method) {
if (!init) {
init = {};
}
init.method = method;
if (body) {
init.body = body;
}
return this.fetch(input, init);
}
});
62 changes: 61 additions & 1 deletion dist/aurelia-fetch-client.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
PLATFORM
PLATFORM,
DOM
} from 'aurelia-pal';

/* eslint-disable */
Expand Down Expand Up @@ -280,4 +281,63 @@ export declare class HttpClient {
*/
fetch(input: Request | string, init?: RequestInit): Promise<Response>;
buildRequest(input: string, init: RequestInit): Request;

/**
* Calls fetch as a GET request.
*
* @param input The resource that you wish to fetch. Either a
* Request object, or a string containing the URL of the resource.
* @param init An options object containing settings to be applied to
* the Request.
* @returns A Promise for the Response from the fetch request.
*/
get(input: Request | string, init?: RequestInit): Promise<Response>;

/**
* Calls fetch with request method set to POST.
*
* @param input The resource that you wish to fetch. Either a
* Request object, or a string containing the URL of the resource.
* @param body The body of the request.
* @param init An options object containing settings to be applied to
* the Request.
* @returns A Promise for the Response from the fetch request.
*/
post(input: Request | string, body?: any, init?: RequestInit): Promise<Response>;

/**
* Calls fetch with request method set to PUT.
*
* @param input The resource that you wish to fetch. Either a
* Request object, or a string containing the URL of the resource.
* @param body The body of the request.
* @param init An options object containing settings to be applied to
* the Request.
* @returns A Promise for the Response from the fetch request.
*/
put(input: Request | string, body?: any, init?: RequestInit): Promise<Response>;

/**
* Calls fetch with request method set to PATCH.
*
* @param input The resource that you wish to fetch. Either a
* Request object, or a string containing the URL of the resource.
* @param body The body of the request.
* @param init An options object containing settings to be applied to
* the Request.
* @returns A Promise for the Response from the fetch request.
*/
patch(input: Request | string, body?: any, init?: RequestInit): Promise<Response>;

/**
* Calls fetch with request method set to DELETE.
*
* @param input The resource that you wish to fetch. Either a
* Request object, or a string containing the URL of the resource.
* @param body The body of the request.
* @param init An options object containing settings to be applied to
* the Request.
* @returns A Promise for the Response from the fetch request.
*/
delete(input: Request | string, body?: any, init?: RequestInit): Promise<Response>;
}
86 changes: 85 additions & 1 deletion dist/aurelia-fetch-client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {PLATFORM} from 'aurelia-pal';
import {PLATFORM,DOM} from 'aurelia-pal';

/**
* Serialize an object to JSON. Useful for easily creating JSON fetch request bodies.
Expand Down Expand Up @@ -517,6 +517,75 @@ export class HttpClient {
}
return request;
}

/**
* Calls fetch as a GET request.
*
* @param input The resource that you wish to fetch. Either a
* Request object, or a string containing the URL of the resource.
* @param init An options object containing settings to be applied to
* the Request.
* @returns A Promise for the Response from the fetch request.
*/
get(input: Request|string, init?: RequestInit): Promise<Response> {
return this.fetch(input, init);
}

/**
* Calls fetch with request method set to POST.
*
* @param input The resource that you wish to fetch. Either a
* Request object, or a string containing the URL of the resource.
* @param body The body of the request.
* @param init An options object containing settings to be applied to
* the Request.
* @returns A Promise for the Response from the fetch request.
*/
post(input: Request|string, body?: any, init?: RequestInit): Promise<Response> {
return this::callFetch(input, body, init, 'post');
}

/**
* Calls fetch with request method set to PUT.
*
* @param input The resource that you wish to fetch. Either a
* Request object, or a string containing the URL of the resource.
* @param body The body of the request.
* @param init An options object containing settings to be applied to
* the Request.
* @returns A Promise for the Response from the fetch request.
*/
put(input: Request|string, body?: any, init?: RequestInit): Promise<Response> {
return this::callFetch(input, body, init, 'put');
}

/**
* Calls fetch with request method set to PATCH.
*
* @param input The resource that you wish to fetch. Either a
* Request object, or a string containing the URL of the resource.
* @param body The body of the request.
* @param init An options object containing settings to be applied to
* the Request.
* @returns A Promise for the Response from the fetch request.
*/
patch(input: Request|string, body?: any, init?: RequestInit): Promise<Response> {
return this::callFetch(input, body, init, 'patch');
}

/**
* Calls fetch with request method set to DELETE.
*
* @param input The resource that you wish to fetch. Either a
* Request object, or a string containing the URL of the resource.
* @param body The body of the request.
* @param init An options object containing settings to be applied to
* the Request.
* @returns A Promise for the Response from the fetch request.
*/
delete(input: Request|string, body?: any, init?: RequestInit): Promise<Response> {
return this::callFetch(input, body, init, 'delete');
}
}

const absoluteUrlRegexp = /^([a-z][a-z0-9+\-.]*:)?\/\//i;
Expand All @@ -527,6 +596,10 @@ function trackRequestStart() {

function trackRequestEnd() {
this.isRequesting = !!(--this.activeRequestCount);
if (!this.isRequesting) {
let evt = DOM.createCustomEvent('aurelia-fetch-client-requests-drained', { bubbles: true, cancelable: true });
setTimeout(() => DOM.dispatchEvent(evt), 1);
}
}

function parseHeaderValues(headers) {
Expand Down Expand Up @@ -592,3 +665,14 @@ function identity(x) {
function thrower(x) {
throw x;
}

function callFetch(input, body, init, method) {
if (!init) {
init = {};
}
init.method = method;
if (body) {
init.body = body;
}
return this.fetch(input, init);
}
37 changes: 37 additions & 0 deletions dist/commonjs/aurelia-fetch-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,26 @@ var HttpClient = exports.HttpClient = function () {
return request;
};

HttpClient.prototype.get = function get(input, init) {
return this.fetch(input, init);
};

HttpClient.prototype.post = function post(input, body, init) {
return callFetch.call(this, input, body, init, 'post');
};

HttpClient.prototype.put = function put(input, body, init) {
return callFetch.call(this, input, body, init, 'put');
};

HttpClient.prototype.patch = function patch(input, body, init) {
return callFetch.call(this, input, body, init, 'patch');
};

HttpClient.prototype.delete = function _delete(input, body, init) {
return callFetch.call(this, input, body, init, 'delete');
};

return HttpClient;
}();

Expand All @@ -351,6 +371,12 @@ function trackRequestStart() {

function trackRequestEnd() {
this.isRequesting = !! --this.activeRequestCount;
if (!this.isRequesting) {
var evt = _aureliaPal.DOM.createCustomEvent('aurelia-fetch-client-requests-drained', { bubbles: true, cancelable: true });
setTimeout(function () {
return _aureliaPal.DOM.dispatchEvent(evt);
}, 1);
}
}

function parseHeaderValues(headers) {
Expand Down Expand Up @@ -420,4 +446,15 @@ function identity(x) {

function thrower(x) {
throw x;
}

function callFetch(input, body, init, method) {
if (!init) {
init = {};
}
init.method = method;
if (body) {
init.body = body;
}
return this.fetch(input, init);
}
37 changes: 36 additions & 1 deletion dist/es2015/aurelia-fetch-client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PLATFORM } from 'aurelia-pal';
import { PLATFORM, DOM } from 'aurelia-pal';

export function json(body, replacer) {
return JSON.stringify(body !== undefined ? body : {}, replacer);
Expand Down Expand Up @@ -264,6 +264,26 @@ export let HttpClient = class HttpClient {
}
return request;
}

get(input, init) {
return this.fetch(input, init);
}

post(input, body, init) {
return callFetch.call(this, input, body, init, 'post');
}

put(input, body, init) {
return callFetch.call(this, input, body, init, 'put');
}

patch(input, body, init) {
return callFetch.call(this, input, body, init, 'patch');
}

delete(input, body, init) {
return callFetch.call(this, input, body, init, 'delete');
}
};

const absoluteUrlRegexp = /^([a-z][a-z0-9+\-.]*:)?\/\//i;
Expand All @@ -274,6 +294,10 @@ function trackRequestStart() {

function trackRequestEnd() {
this.isRequesting = !! --this.activeRequestCount;
if (!this.isRequesting) {
let evt = DOM.createCustomEvent('aurelia-fetch-client-requests-drained', { bubbles: true, cancelable: true });
setTimeout(() => DOM.dispatchEvent(evt), 1);
}
}

function parseHeaderValues(headers) {
Expand Down Expand Up @@ -335,4 +359,15 @@ function identity(x) {

function thrower(x) {
throw x;
}

function callFetch(input, body, init, method) {
if (!init) {
init = {};
}
init.method = method;
if (body) {
init.body = body;
}
return this.fetch(input, init);
}
Loading

0 comments on commit 882f8c7

Please sign in to comment.