d3-request
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-request/ Version 1.0.2. Copyright 2016 Mike Bostock. | ||
// https://d3js.org/d3-request/ Version 1.0.3. Copyright 2016 Mike Bostock. | ||
(function (global, factory) { | ||
@@ -6,212 +6,212 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-collection'), require('d3-dispatch'), require('d3-dsv')) : | ||
(factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3)); | ||
}(this, function (exports,d3Collection,d3Dispatch,d3Dsv) { 'use strict'; | ||
}(this, (function (exports,d3Collection,d3Dispatch,d3Dsv) { 'use strict'; | ||
function request(url, callback) { | ||
var request, | ||
event = d3Dispatch.dispatch("beforesend", "progress", "load", "error"), | ||
mimeType, | ||
headers = d3Collection.map(), | ||
xhr = new XMLHttpRequest, | ||
user = null, | ||
password = null, | ||
response, | ||
responseType, | ||
timeout = 0; | ||
var request = function(url, callback) { | ||
var request, | ||
event = d3Dispatch.dispatch("beforesend", "progress", "load", "error"), | ||
mimeType, | ||
headers = d3Collection.map(), | ||
xhr = new XMLHttpRequest, | ||
user = null, | ||
password = null, | ||
response, | ||
responseType, | ||
timeout = 0; | ||
// If IE does not support CORS, use XDomainRequest. | ||
if (typeof XDomainRequest !== "undefined" | ||
&& !("withCredentials" in xhr) | ||
&& /^(http(s)?:)?\/\//.test(url)) xhr = new XDomainRequest; | ||
// If IE does not support CORS, use XDomainRequest. | ||
if (typeof XDomainRequest !== "undefined" | ||
&& !("withCredentials" in xhr) | ||
&& /^(http(s)?:)?\/\//.test(url)) xhr = new XDomainRequest; | ||
"onload" in xhr | ||
? xhr.onload = xhr.onerror = xhr.ontimeout = respond | ||
: xhr.onreadystatechange = function(o) { xhr.readyState > 3 && respond(o); }; | ||
"onload" in xhr | ||
? xhr.onload = xhr.onerror = xhr.ontimeout = respond | ||
: xhr.onreadystatechange = function(o) { xhr.readyState > 3 && respond(o); }; | ||
function respond(o) { | ||
var status = xhr.status, result; | ||
if (!status && hasResponse(xhr) | ||
|| status >= 200 && status < 300 | ||
|| status === 304) { | ||
if (response) { | ||
try { | ||
result = response.call(request, xhr); | ||
} catch (e) { | ||
event.call("error", request, e); | ||
return; | ||
} | ||
} else { | ||
result = xhr; | ||
function respond(o) { | ||
var status = xhr.status, result; | ||
if (!status && hasResponse(xhr) | ||
|| status >= 200 && status < 300 | ||
|| status === 304) { | ||
if (response) { | ||
try { | ||
result = response.call(request, xhr); | ||
} catch (e) { | ||
event.call("error", request, e); | ||
return; | ||
} | ||
event.call("load", request, result); | ||
} else { | ||
event.call("error", request, o); | ||
result = xhr; | ||
} | ||
event.call("load", request, result); | ||
} else { | ||
event.call("error", request, o); | ||
} | ||
} | ||
xhr.onprogress = function(e) { | ||
event.call("progress", request, e); | ||
}; | ||
xhr.onprogress = function(e) { | ||
event.call("progress", request, e); | ||
}; | ||
request = { | ||
header: function(name, value) { | ||
name = (name + "").toLowerCase(); | ||
if (arguments.length < 2) return headers.get(name); | ||
if (value == null) headers.remove(name); | ||
else headers.set(name, value + ""); | ||
return request; | ||
}, | ||
request = { | ||
header: function(name, value) { | ||
name = (name + "").toLowerCase(); | ||
if (arguments.length < 2) return headers.get(name); | ||
if (value == null) headers.remove(name); | ||
else headers.set(name, value + ""); | ||
return request; | ||
}, | ||
// If mimeType is non-null and no Accept header is set, a default is used. | ||
mimeType: function(value) { | ||
if (!arguments.length) return mimeType; | ||
mimeType = value == null ? null : value + ""; | ||
return request; | ||
}, | ||
// If mimeType is non-null and no Accept header is set, a default is used. | ||
mimeType: function(value) { | ||
if (!arguments.length) return mimeType; | ||
mimeType = value == null ? null : value + ""; | ||
return request; | ||
}, | ||
// Specifies what type the response value should take; | ||
// for instance, arraybuffer, blob, document, or text. | ||
responseType: function(value) { | ||
if (!arguments.length) return responseType; | ||
responseType = value; | ||
return request; | ||
}, | ||
// Specifies what type the response value should take; | ||
// for instance, arraybuffer, blob, document, or text. | ||
responseType: function(value) { | ||
if (!arguments.length) return responseType; | ||
responseType = value; | ||
return request; | ||
}, | ||
timeout: function(value) { | ||
if (!arguments.length) return timeout; | ||
timeout = +value; | ||
return request; | ||
}, | ||
timeout: function(value) { | ||
if (!arguments.length) return timeout; | ||
timeout = +value; | ||
return request; | ||
}, | ||
user: function(value) { | ||
return arguments.length < 1 ? user : (user = value == null ? null : value + "", request); | ||
}, | ||
user: function(value) { | ||
return arguments.length < 1 ? user : (user = value == null ? null : value + "", request); | ||
}, | ||
password: function(value) { | ||
return arguments.length < 1 ? password : (password = value == null ? null : value + "", request); | ||
}, | ||
password: function(value) { | ||
return arguments.length < 1 ? password : (password = value == null ? null : value + "", request); | ||
}, | ||
// Specify how to convert the response content to a specific type; | ||
// changes the callback value on "load" events. | ||
response: function(value) { | ||
response = value; | ||
return request; | ||
}, | ||
// Specify how to convert the response content to a specific type; | ||
// changes the callback value on "load" events. | ||
response: function(value) { | ||
response = value; | ||
return request; | ||
}, | ||
// Alias for send("GET", …). | ||
get: function(data, callback) { | ||
return request.send("GET", data, callback); | ||
}, | ||
// Alias for send("GET", …). | ||
get: function(data, callback) { | ||
return request.send("GET", data, callback); | ||
}, | ||
// Alias for send("POST", …). | ||
post: function(data, callback) { | ||
return request.send("POST", data, callback); | ||
}, | ||
// Alias for send("POST", …). | ||
post: function(data, callback) { | ||
return request.send("POST", data, callback); | ||
}, | ||
// If callback is non-null, it will be used for error and load events. | ||
send: function(method, data, callback) { | ||
xhr.open(method, url, true, user, password); | ||
if (mimeType != null && !headers.has("accept")) headers.set("accept", mimeType + ",*/*"); | ||
if (xhr.setRequestHeader) headers.each(function(value, name) { xhr.setRequestHeader(name, value); }); | ||
if (mimeType != null && xhr.overrideMimeType) xhr.overrideMimeType(mimeType); | ||
if (responseType != null) xhr.responseType = responseType; | ||
if (timeout > 0) xhr.timeout = timeout; | ||
if (callback == null && typeof data === "function") callback = data, data = null; | ||
if (callback != null && callback.length === 1) callback = fixCallback(callback); | ||
if (callback != null) request.on("error", callback).on("load", function(xhr) { callback(null, xhr); }); | ||
event.call("beforesend", request, xhr); | ||
xhr.send(data == null ? null : data); | ||
return request; | ||
}, | ||
// If callback is non-null, it will be used for error and load events. | ||
send: function(method, data, callback) { | ||
xhr.open(method, url, true, user, password); | ||
if (mimeType != null && !headers.has("accept")) headers.set("accept", mimeType + ",*/*"); | ||
if (xhr.setRequestHeader) headers.each(function(value, name) { xhr.setRequestHeader(name, value); }); | ||
if (mimeType != null && xhr.overrideMimeType) xhr.overrideMimeType(mimeType); | ||
if (responseType != null) xhr.responseType = responseType; | ||
if (timeout > 0) xhr.timeout = timeout; | ||
if (callback == null && typeof data === "function") callback = data, data = null; | ||
if (callback != null && callback.length === 1) callback = fixCallback(callback); | ||
if (callback != null) request.on("error", callback).on("load", function(xhr) { callback(null, xhr); }); | ||
event.call("beforesend", request, xhr); | ||
xhr.send(data == null ? null : data); | ||
return request; | ||
}, | ||
abort: function() { | ||
xhr.abort(); | ||
return request; | ||
}, | ||
abort: function() { | ||
xhr.abort(); | ||
return request; | ||
}, | ||
on: function() { | ||
var value = event.on.apply(event, arguments); | ||
return value === event ? request : value; | ||
} | ||
}; | ||
if (callback != null) { | ||
if (typeof callback !== "function") throw new Error("invalid callback: " + callback); | ||
return request.get(callback); | ||
on: function() { | ||
var value = event.on.apply(event, arguments); | ||
return value === event ? request : value; | ||
} | ||
}; | ||
return request; | ||
if (callback != null) { | ||
if (typeof callback !== "function") throw new Error("invalid callback: " + callback); | ||
return request.get(callback); | ||
} | ||
function fixCallback(callback) { | ||
return function(error, xhr) { | ||
callback(error == null ? xhr : null); | ||
}; | ||
} | ||
return request; | ||
}; | ||
function hasResponse(xhr) { | ||
var type = xhr.responseType; | ||
return type && type !== "text" | ||
? xhr.response // null on error | ||
: xhr.responseText; // "" on error | ||
} | ||
function fixCallback(callback) { | ||
return function(error, xhr) { | ||
callback(error == null ? xhr : null); | ||
}; | ||
} | ||
function type(defaultMimeType, response) { | ||
return function(url, callback) { | ||
var r = request(url).mimeType(defaultMimeType).response(response); | ||
if (callback != null) { | ||
if (typeof callback !== "function") throw new Error("invalid callback: " + callback); | ||
return r.get(callback); | ||
} | ||
return r; | ||
}; | ||
} | ||
function hasResponse(xhr) { | ||
var type = xhr.responseType; | ||
return type && type !== "text" | ||
? xhr.response // null on error | ||
: xhr.responseText; // "" on error | ||
} | ||
var html = type("text/html", function(xhr) { | ||
return document.createRange().createContextualFragment(xhr.responseText); | ||
}); | ||
var type = function(defaultMimeType, response) { | ||
return function(url, callback) { | ||
var r = request(url).mimeType(defaultMimeType).response(response); | ||
if (callback != null) { | ||
if (typeof callback !== "function") throw new Error("invalid callback: " + callback); | ||
return r.get(callback); | ||
} | ||
return r; | ||
}; | ||
}; | ||
var json = type("application/json", function(xhr) { | ||
return JSON.parse(xhr.responseText); | ||
}); | ||
var html = type("text/html", function(xhr) { | ||
return document.createRange().createContextualFragment(xhr.responseText); | ||
}); | ||
var text = type("text/plain", function(xhr) { | ||
return xhr.responseText; | ||
}); | ||
var json = type("application/json", function(xhr) { | ||
return JSON.parse(xhr.responseText); | ||
}); | ||
var xml = type("application/xml", function(xhr) { | ||
var xml = xhr.responseXML; | ||
if (!xml) throw new Error("parse error"); | ||
return xml; | ||
}); | ||
var text = type("text/plain", function(xhr) { | ||
return xhr.responseText; | ||
}); | ||
function dsv(defaultMimeType, parse) { | ||
return function(url, row, callback) { | ||
if (arguments.length < 3) callback = row, row = null; | ||
var r = request(url).mimeType(defaultMimeType); | ||
r.row = function(_) { return arguments.length ? r.response(responseOf(parse, row = _)) : row; }; | ||
r.row(row); | ||
return callback ? r.get(callback) : r; | ||
}; | ||
} | ||
var xml = type("application/xml", function(xhr) { | ||
var xml = xhr.responseXML; | ||
if (!xml) throw new Error("parse error"); | ||
return xml; | ||
}); | ||
function responseOf(parse, row) { | ||
return function(request) { | ||
return parse(request.responseText, row); | ||
}; | ||
} | ||
var dsv = function(defaultMimeType, parse) { | ||
return function(url, row, callback) { | ||
if (arguments.length < 3) callback = row, row = null; | ||
var r = request(url).mimeType(defaultMimeType); | ||
r.row = function(_) { return arguments.length ? r.response(responseOf(parse, row = _)) : row; }; | ||
r.row(row); | ||
return callback ? r.get(callback) : r; | ||
}; | ||
}; | ||
var csv = dsv("text/csv", d3Dsv.csvParse); | ||
function responseOf(parse, row) { | ||
return function(request$$1) { | ||
return parse(request$$1.responseText, row); | ||
}; | ||
} | ||
var tsv = dsv("text/tab-separated-values", d3Dsv.tsvParse); | ||
var csv = dsv("text/csv", d3Dsv.csvParse); | ||
exports.request = request; | ||
exports.html = html; | ||
exports.json = json; | ||
exports.text = text; | ||
exports.xml = xml; | ||
exports.csv = csv; | ||
exports.tsv = tsv; | ||
var tsv = dsv("text/tab-separated-values", d3Dsv.tsvParse); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.request = request; | ||
exports.html = html; | ||
exports.json = json; | ||
exports.text = text; | ||
exports.xml = xml; | ||
exports.csv = csv; | ||
exports.tsv = tsv; | ||
})); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); |
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-request/ Version 1.0.2. 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})}); | ||
// https://d3js.org/d3-request/ Version 1.0.3. 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){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})}); |
@@ -11,3 +11,3 @@ 'use strict'; | ||
function request(url, callback) { | ||
var request = function(url, callback) { | ||
var request, | ||
@@ -146,3 +146,3 @@ event = d3Dispatch.dispatch("beforesend", "progress", "load", "error"), | ||
return request; | ||
} | ||
}; | ||
@@ -162,3 +162,3 @@ function fixCallback(callback) { | ||
function type(defaultMimeType, response) { | ||
var type = function(defaultMimeType, response) { | ||
return function(url, callback) { | ||
@@ -172,3 +172,3 @@ var r = request(url).mimeType(defaultMimeType).response(response); | ||
}; | ||
} | ||
}; | ||
@@ -193,3 +193,3 @@ var html = type("text/html", function(xhr) { | ||
function dsv(defaultMimeType, parse) { | ||
var dsv = function(defaultMimeType, parse) { | ||
return function(url, row, callback) { | ||
@@ -202,7 +202,7 @@ if (arguments.length < 3) callback = row, row = null; | ||
}; | ||
} | ||
}; | ||
function responseOf(parse, row) { | ||
return function(request) { | ||
return parse(request.responseText, row); | ||
return function(request$$1) { | ||
return parse(request$$1.responseText, row); | ||
}; | ||
@@ -221,2 +221,2 @@ } | ||
exports.csv = csv; | ||
exports.tsv = tsv; | ||
exports.tsv = tsv; |
{ | ||
"name": "d3-request", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A convenient alternative to XMLHttpRequest.", | ||
@@ -39,5 +39,5 @@ "keywords": [ | ||
"devDependencies": { | ||
"eslint": "2", | ||
"eslint": "3", | ||
"package-preamble": "0.0", | ||
"rollup": "0.34", | ||
"rollup": "0.36", | ||
"tape": "4", | ||
@@ -44,0 +44,0 @@ "uglify-js": "2" |
@@ -52,3 +52,3 @@ # d3-request | ||
<a name="request" href="#request">#</a> d3.<b>request</b>(<i>url</i>[, <i>callback</i>]) | ||
<a name="request" href="#request">#</a> d3.<b>request</b>(<i>url</i>[, <i>callback</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L4 "Source") | ||
@@ -64,3 +64,3 @@ Returns a new asynchronous request for specified *url*. If no *callback* is specified, the request is not yet [sent](#request_send) and can be further configured. If a *callback* is specified, it is equivalent to calling [*request*.get](#request_get) immediately after construction: | ||
<a name="request_header" href="#request_header">#</a> <i>request</i>.<b>header</b>(<i>name</i>[, <i>value</i>]) | ||
<a name="request_header" href="#request_header">#</a> <i>request</i>.<b>header</b>(<i>name</i>[, <i>value</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L51 "Source") | ||
@@ -80,3 +80,3 @@ If *value* is specified, sets the request header with the specified *name* to the specified value and returns this request instance. If *value* is null, removes the request header with the specified *name* instead. If *value* is not specified, returns the current value of the request header with the specified *name*. Header names are case-insensitive. | ||
<a name="request_mimeType" href="#request_mimeType">#</a> <i>request</i>.<b>mimeType</b>([<i>type</i>]) | ||
<a name="request_mimeType" href="#request_mimeType">#</a> <i>request</i>.<b>mimeType</b>([<i>type</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L60 "Source") | ||
@@ -93,23 +93,23 @@ If *type* is specified, sets the request mime type to the specified value and returns this request instance. If *type* is null, clears the current mime type (if any) instead. If *type* is not specified, returns the current mime type, which defaults to null. The mime type is used to both set the ["Accept" request header](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) and for [overrideMimeType](http://www.w3.org/TR/XMLHttpRequest/#the-overridemimetype%28%29-method), where supported. | ||
<a name="request_user" href="#request_user">#</a> <i>request</i>.<b>user</b>([<i>value</i>]) | ||
<a name="request_user" href="#request_user">#</a> <i>request</i>.<b>user</b>([<i>value</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L80 "Source") | ||
If *value* is specified, sets the user name for authentication to the specified string and returns this request instance. If *value* is not specified, returns the current user name, which defaults to null. | ||
<a name="request_password" href="#request_password">#</a> <i>request</i>.<b>password</b>([<i>value</i>]) | ||
<a name="request_password" href="#request_password">#</a> <i>request</i>.<b>password</b>([<i>value</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L84 "Source") | ||
If *value* is specified, sets the password for authentication to the specified string and returns this request instance. If *value* is not specified, returns the current password, which defaults to null. | ||
<a name="request_timeout" href="#request_timeout">#</a> <i>request</i>.<b>timeout</b>([<i>timeout</i>]) | ||
<a name="request_timeout" href="#request_timeout">#</a> <i>request</i>.<b>timeout</b>([<i>timeout</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L74 "Source") | ||
If *timeout* is specified, sets the [timeout](http://www.w3.org/TR/XMLHttpRequest/#the-timeout-attribute) attribute of the request to the specified number of milliseconds and returns this request instance. If *timeout* is not specified, returns the current response timeout, which defaults to 0. | ||
<a name="request_responseType" href="#request_responseType">#</a> <i>request</i>.<b>responseType</b>([<i>type</i>]) | ||
<a name="request_responseType" href="#request_responseType">#</a> <i>request</i>.<b>responseType</b>([<i>type</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L68 "Source") | ||
If *type* is specified, sets the [response type](http://www.w3.org/TR/XMLHttpRequest/#the-responsetype-attribute) attribute of the request and returns this request instance. Typical values are: `` (the empty string), `arraybuffer`, `blob`, `document`, and `text`. If *type* is not specified, returns the current response type, which defaults to ``. | ||
<a name="request_response" href="#request_response">#</a> <i>request</i>.<b>response</b>(<i>value</i>) | ||
<a name="request_response" href="#request_response">#</a> <i>request</i>.<b>response</b>(<i>value</i>) [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L90 "Source") | ||
Sets the response value function to the specified function and returns this request instance. The response value function is used to map the response XMLHttpRequest object to a useful data value. See the convenience methods [json](#json) and [text](#text) for examples. | ||
<a name="request_get" href="#request_get">#</a> <i>request</i>.<b>get</b>([<i>data</i>][, <i>callback</i>]) | ||
<a name="request_get" href="#request_get">#</a> <i>request</i>.<b>get</b>([<i>data</i>][, <i>callback</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L96 "Source") | ||
@@ -122,3 +122,3 @@ Equivalent to [*request*.send](#request_send) with the GET method: | ||
<a name="request_post" href="#request_post">#</a> <i>request</i>.<b>post</b>([<i>data</i>][, <i>callback</i>]) | ||
<a name="request_post" href="#request_post">#</a> <i>request</i>.<b>post</b>([<i>data</i>][, <i>callback</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L101 "Source") | ||
@@ -131,3 +131,3 @@ Equivalent to [*request*.send](#request_send) with the POST method: | ||
<a name="request_send" href="#request_send">#</a> <i>request</i>.<b>send</b>(<i>method</i>[, <i>data</i>][, <i>callback</i>]) | ||
<a name="request_send" href="#request_send">#</a> <i>request</i>.<b>send</b>(<i>method</i>[, <i>data</i>][, <i>callback</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L106 "Source") | ||
@@ -145,7 +145,7 @@ Issues this request using the specified *method* (such as `GET` or `POST`), optionally posting the specified *data* in the request body, and returns this request instance. If a *callback* is specified, the callback will be invoked asynchronously when the request succeeds or fails. The callback is invoked with two arguments: the error, if any, and the [response value](#request_response). The response value is undefined if an error occurs. This is equivalent to: | ||
<a name="request_abort" href="#request_abort">#</a> <i>request</i>.<b>abort</b>() | ||
<a name="request_abort" href="#request_abort">#</a> <i>request</i>.<b>abort</b>() [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L121 "Source") | ||
Aborts this request, if it is currently in-flight, and returns this request instance. See [XMLHttpRequest’s abort](http://www.w3.org/TR/XMLHttpRequest/#the-abort%28%29-method). | ||
<a name="request_on" href="#request_on">#</a> <i>request</i>.<b>on</b>(<i>type</i>[, <i>listener</i>]) | ||
<a name="request_on" href="#request_on">#</a> <i>request</i>.<b>on</b>(<i>type</i>[, <i>listener</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/request.js#L126 "Source") | ||
@@ -163,3 +163,3 @@ If *listener* is specified, sets the event *listener* for the specified *type* and returns this request instance. If an event listener was already registered for the same type, the existing listener is removed before the new listener is added. If *listener* is null, removes the current event *listener* for the specified *type* (if any) instead. If *listener* is not specified, returns the currently-assigned listener for the specified type, if any. | ||
<a name="csv" href="#csv">#</a> d3.<b>csv</b>(<i>url</i>[[, <i>row</i>], <i>callback</i>]) | ||
<a name="csv" href="#csv">#</a> d3.<b>csv</b>(<i>url</i>[[, <i>row</i>], <i>callback</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/csv.js "Source") | ||
@@ -202,3 +202,3 @@ Creates a request for the [CSV](https://github.com/d3/d3-dsv#csvParse) file at the specified *url* with the default mime type `text/csv`. An optional *row* conversion function may be specified to map and filter row objects to a more-specific representation; see [*dsv*.parse](https://github.com/d3/d3-dsv#dsv_parse) for details. For example: | ||
<a name="html" href="#html">#</a> d3.<b>html</b>(<i>url</i>[, <i>callback</i>]) | ||
<a name="html" href="#html">#</a> d3.<b>html</b>(<i>url</i>[, <i>callback</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/html.js "Source") | ||
@@ -218,3 +218,3 @@ Creates a request for the HTML file at the specified *url* with the default mime type `text/html`. The HTML file is returned as a [document fragment](https://developer.mozilla.org/en-US/docs/DOM/range.createContextualFragment). | ||
<a name="json" href="#json">#</a> d3.<b>json</b>(<i>url</i>[, <i>callback</i>]) | ||
<a name="json" href="#json">#</a> d3.<b>json</b>(<i>url</i>[, <i>callback</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/json.js "Source") | ||
@@ -232,3 +232,3 @@ Creates a request for the [JSON](http://json.org) file at the specified *url* with the default mime type `application/json`. | ||
<a name="text" href="#text">#</a> d3.<b>text</b>(<i>url</i>[, <i>callback</i>]) | ||
<a name="text" href="#text">#</a> d3.<b>text</b>(<i>url</i>[, <i>callback</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/text.js "Source") | ||
@@ -246,3 +246,3 @@ Creates a request for the text file at the specified *url* with the default mime type `text/plain`. | ||
<a name="tsv" href="#tsv">#</a> d3.<b>tsv</b>(<i>url</i>[[, <i>row</i>], <i>callback</i>]) | ||
<a name="tsv" href="#tsv">#</a> d3.<b>tsv</b>(<i>url</i>[[, <i>row</i>], <i>callback</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/tsv.js "Source") | ||
@@ -285,3 +285,3 @@ Creates a request for the [TSV](https://github.com/d3/d3-dsv#tsvParse) file at the specified *url* with the default mime type `text/tab-separated-values`. An optional *row* conversion function may be specified to map and filter row objects to a more-specific representation; see [*dsv*.parse](https://github.com/d3/d3-dsv#dsv_parse) for details. For example: | ||
<a name="xml" href="#xml">#</a> d3.<b>xml</b>(<i>url</i>[, <i>callback</i>]) | ||
<a name="xml" href="#xml">#</a> d3.<b>xml</b>(<i>url</i>[, <i>callback</i>]) [<>](https://github.com/d3/d3-request/blob/master/src/xml.js "Source") | ||
@@ -288,0 +288,0 @@ Creates a request for the XML file at the specified *url* with the default mime type `application/xml`. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41969
552