ui.js.vendor.d3.d3-request.min.js Maven / Gradle / Ivy
The newest version!
// https://d3js.org/d3-request/ Version 1.0.1. Copyright 2016 Mike Bostock.
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-collection"),require("d3-dispatch"),require("d3-dsv")):"function"==typeof define&&define.amd?define(["exports","d3-collection","d3-dispatch","d3-dsv"],n):n(e.d3=e.d3||{},e.d3,e.d3,e.d3)}(this,function(e,n,t,r){"use strict";function o(e,r){function o(e){var n,t=d.status;if(!t&&l(d)||t>=200&&t<300||304===t){if(c)try{n=c.call(i,d)}catch(e){return void f.call("error",i,e)}else n=d;f.call("load",i,n)}else f.call("error",i,e)}var i,s,c,a,f=t.dispatch("beforesend","progress","load","error"),p=n.map(),d=new XMLHttpRequest,h=null,m=null,v=0;if("undefined"==typeof XDomainRequest||"withCredentials"in d||!/^(http(s)?:)?\/\//.test(e)||(d=new XDomainRequest),"onload"in d?d.onload=d.onerror=d.ontimeout=o:d.onreadystatechange=function(e){d.readyState>3&&o(e)},d.onprogress=function(e){f.call("progress",i,e)},i={header:function(e,n){return e=(e+"").toLowerCase(),arguments.length<2?p.get(e):(null==n?p.remove(e):p.set(e,n+""),i)},mimeType:function(e){return arguments.length?(s=null==e?null:e+"",i):s},responseType:function(e){return arguments.length?(a=e,i):a},timeout:function(e){return arguments.length?(v=+e,i):v},user:function(e){return arguments.length<1?h:(h=null==e?null:e+"",i)},password:function(e){return arguments.length<1?m:(m=null==e?null:e+"",i)},response:function(e){return c=e,i},get:function(e,n){return i.send("GET",e,n)},post:function(e,n){return i.send("POST",e,n)},send:function(n,t,r){return d.open(n,e,!0,h,m),null==s||p.has("accept")||p.set("accept",s+",*/*"),d.setRequestHeader&&p.each(function(e,n){d.setRequestHeader(n,e)}),null!=s&&d.overrideMimeType&&d.overrideMimeType(s),null!=a&&(d.responseType=a),v>0&&(d.timeout=v),null==r&&"function"==typeof t&&(r=t,t=null),null!=r&&1===r.length&&(r=u(r)),null!=r&&i.on("error",r).on("load",function(e){r(null,e)}),f.call("beforesend",i,d),d.send(null==t?null:t),i},abort:function(){return d.abort(),i},on:function(){var e=f.on.apply(f,arguments);return e===f?i:e}},null!=r){if("function"!=typeof r)throw new Error("invalid callback: "+r);return i.get(r)}return i}function u(e){return function(n,t){e(null==n?t:null)}}function l(e){var n=e.responseType;return n&&"text"!==n?e.response:e.responseText}function i(e,n){return function(t,r){var u=o(t).mimeType(e).response(n);if(null!=r){if("function"!=typeof r)throw new Error("invalid callback: "+r);return u.get(r)}return u}}function s(e,n){return function(t,r,u){arguments.length<3&&(u=r,r=null);var l=o(t).mimeType(e);return l.row=function(e){return arguments.length?l.response(c(n,r=e)):r},l.row(r),u?l.get(u):l}}function c(e,n){return function(t){return e(t.responseText,n)}}var a=i("text/html",function(e){return document.createRange().createContextualFragment(e.responseText)}),f=i("application/json",function(e){return JSON.parse(e.responseText)}),p=i("text/plain",function(e){return e.responseText}),d=i("application/xml",function(e){var n=e.responseXML;if(!n)throw new Error("parse error");return n}),h=s("text/csv",r.csvParse),m=s("text/tab-separated-values",r.tsvParse);e.request=o,e.html=a,e.json=f,e.text=p,e.xml=d,e.csv=h,e.tsv=m,Object.defineProperty(e,"__esModule",{value:!0})});