You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
3.2 KiB
2 lines
3.2 KiB
// https://d3js.org/d3-request/ Version 1.0.6. Copyright 2017 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){return function(n,t){e(null==n?t:null)}}function u(e){var n=e.responseType;return n&&"text"!==n?e.response:e.responseText}function l(e,n){return function(t){return e(t.responseText,n)}}var i=function(e,r){function l(e){var n,t=d.status;if(!t&&u(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=l:d.onreadystatechange=function(e){d.readyState>3&&l(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=o(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},s=function(e,n){return function(t,r){var o=i(t).mimeType(e).response(n);if(null!=r){if("function"!=typeof r)throw new Error("invalid callback: "+r);return o.get(r)}return o}},c=s("text/html",function(e){return document.createRange().createContextualFragment(e.responseText)}),a=s("application/json",function(e){return JSON.parse(e.responseText)}),f=s("text/plain",function(e){return e.responseText}),p=s("application/xml",function(e){var n=e.responseXML;if(!n)throw new Error("parse error");return n}),d=function(e,n){return function(t,r,o){arguments.length<3&&(o=r,r=null);var u=i(t).mimeType(e);return u.row=function(e){return arguments.length?u.response(l(n,r=e)):r},u.row(r),o?u.get(o):u}},h=d("text/csv",r.csvParse),m=d("text/tab-separated-values",r.tsvParse);e.request=i,e.html=c,e.json=a,e.text=f,e.xml=p,e.csv=h,e.tsv=m,Object.defineProperty(e,"__esModule",{value:!0})}); |