Skip to content

Commit

Permalink
0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Aug 10, 2018
1 parent 884f9c6 commit e6d9f77
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 9 deletions.
21 changes: 19 additions & 2 deletions dist/karet.xhr.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ var performPlain = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? I.id :
end(emit(state = L.set(EVENT, event, state)));
});
xhr.open(method, url, true, user, password);
if (responseType) xhr.responseType = responseType;
if (responseType) {
xhr.responseType = responseType;
if (responseType === 'json' && xhr.responseType !== 'json') state = L.set('parse', true, state);
}
if (timeout) xhr.timeout = timeout;
if (withCredentials) xhr.withCredentials = withCredentials;
if (null != headers) {
Expand Down Expand Up @@ -144,6 +147,14 @@ function perform(argsIn) {
return (isObservable(args) ? args.flatMapLatest(performPlain) : performPlain(args)).toProperty();
}

function tryParse(json) {
try {
return JSON.parse(json);
} catch (_) {
return null;
}
}

var isOneOf = /*#__PURE__*/I.curry(function (values, value) {
return values.includes(value);
});
Expand Down Expand Up @@ -195,7 +206,13 @@ var headersReceived = /*#__PURE__*/I.defineNameU( /*#__PURE__*/L.get([XHR, 'read
return 2 <= state;
}]), 'headersReceived');
var isDone = /*#__PURE__*/I.defineNameU( /*#__PURE__*/L.get([EVENT, 'type', /*#__PURE__*/L.is('loadend')]), 'isDone');
var response = /*#__PURE__*/setName( /*#__PURE__*/I.pipe2U( /*#__PURE__*/L.get([XHR, 'response']), /*#__PURE__*/skipDuplicates(I.acyclicEqualsU)), 'response');
var response = /*#__PURE__*/setName( /*#__PURE__*/I.pipe2U( /*#__PURE__*/F.lift(function (_ref3) {
var xhr = _ref3.xhr,
parse = _ref3.parse;

var response = xhr.response;
return parse ? tryParse(response) : response;
}), /*#__PURE__*/skipDuplicates(I.acyclicEqualsU)), 'response');
var responseFull = /*#__PURE__*/setName( /*#__PURE__*/getAfter(isDone, response), 'responseFull');
var responseType = /*#__PURE__*/setName( /*#__PURE__*/L.get([XHR, 'responseType']), 'responseType');
var responseURL = /*#__PURE__*/setName( /*#__PURE__*/L.get([XHR, 'responseURL']), 'responseURL');
Expand Down
21 changes: 19 additions & 2 deletions dist/karet.xhr.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ var performPlain = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : va
end(emit(state = set(EVENT, event, state)));
});
xhr.open(method, url, true, user, password);
if (responseType) xhr.responseType = responseType;
if (responseType) {
xhr.responseType = responseType;
if (responseType === 'json' && xhr.responseType !== 'json') state = set('parse', true, state);
}
if (timeout) xhr.timeout = timeout;
if (withCredentials) xhr.withCredentials = withCredentials;
if (null != headers) {
Expand Down Expand Up @@ -140,6 +143,14 @@ function perform(argsIn) {
return (isObservable(args) ? args.flatMapLatest(performPlain) : performPlain(args)).toProperty();
}

function tryParse(json) {
try {
return JSON.parse(json);
} catch (_) {
return null;
}
}

var isOneOf = /*#__PURE__*/curry(function (values, value) {
return values.includes(value);
});
Expand Down Expand Up @@ -191,7 +202,13 @@ var headersReceived = /*#__PURE__*/defineNameU( /*#__PURE__*/get([XHR, 'readySta
return 2 <= state;
}]), 'headersReceived');
var isDone = /*#__PURE__*/defineNameU( /*#__PURE__*/get([EVENT, 'type', /*#__PURE__*/is('loadend')]), 'isDone');
var response = /*#__PURE__*/setName( /*#__PURE__*/pipe2U( /*#__PURE__*/get([XHR, 'response']), /*#__PURE__*/skipDuplicates(acyclicEqualsU)), 'response');
var response = /*#__PURE__*/setName( /*#__PURE__*/pipe2U( /*#__PURE__*/lift(function (_ref3) {
var xhr = _ref3.xhr,
parse = _ref3.parse;

var response = xhr.response;
return parse ? tryParse(response) : response;
}), /*#__PURE__*/skipDuplicates(acyclicEqualsU)), 'response');
var responseFull = /*#__PURE__*/setName( /*#__PURE__*/getAfter(isDone, response), 'responseFull');
var responseType = /*#__PURE__*/setName( /*#__PURE__*/get([XHR, 'responseType']), 'responseType');
var responseURL = /*#__PURE__*/setName( /*#__PURE__*/get([XHR, 'responseURL']), 'responseURL');
Expand Down
21 changes: 19 additions & 2 deletions dist/karet.xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@
end(emit(state = L.set(EVENT, event, state)));
});
xhr.open(method, url, true, user, password);
if (responseType) xhr.responseType = responseType;
if (responseType) {
xhr.responseType = responseType;
if (responseType === 'json' && xhr.responseType !== 'json') state = L.set('parse', true, state);
}
if (timeout) xhr.timeout = timeout;
if (withCredentials) xhr.withCredentials = withCredentials;
if (null != headers) {
Expand Down Expand Up @@ -136,6 +139,14 @@
return (isObservable(args) ? args.flatMapLatest(performPlain) : performPlain(args)).toProperty();
}

function tryParse(json) {
try {
return JSON.parse(json);
} catch (_) {
return null;
}
}

var isOneOf = /*#__PURE__*/I.curry(function (values, value) {
return values.includes(value);
});
Expand Down Expand Up @@ -187,7 +198,13 @@
return 2 <= state;
}]), 'headersReceived');
var isDone = /*#__PURE__*/I.defineNameU( /*#__PURE__*/L.get([EVENT, 'type', /*#__PURE__*/L.is('loadend')]), 'isDone');
var response = /*#__PURE__*/setName( /*#__PURE__*/I.pipe2U( /*#__PURE__*/L.get([XHR, 'response']), /*#__PURE__*/skipDuplicates(I.acyclicEqualsU)), 'response');
var response = /*#__PURE__*/setName( /*#__PURE__*/I.pipe2U( /*#__PURE__*/F.lift(function (_ref3) {
var xhr = _ref3.xhr,
parse = _ref3.parse;

var response = xhr.response;
return parse ? tryParse(response) : response;
}), /*#__PURE__*/skipDuplicates(I.acyclicEqualsU)), 'response');
var responseFull = /*#__PURE__*/setName( /*#__PURE__*/getAfter(isDone, response), 'responseFull');
var responseType = /*#__PURE__*/setName( /*#__PURE__*/L.get([XHR, 'responseType']), 'responseType');
var responseURL = /*#__PURE__*/setName( /*#__PURE__*/L.get([XHR, 'responseURL']), 'responseURL');
Expand Down
2 changes: 1 addition & 1 deletion dist/karet.xhr.min.js

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

2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "karet.xhr",
"version": "0.2.3-0",
"version": "0.2.3",
"description": "An observable wrapper for XMLHttpRequest using Kefir",
"module": "dist/karet.xhr.es.js",
"main": "dist/karet.xhr.cjs.js",
Expand Down

0 comments on commit e6d9f77

Please sign in to comment.