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.

102 lines
2.7 KiB

1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. // https://d3js.org/d3-fetch/ v1.1.2 Copyright 2018 Mike Bostock
  2. (function (global, factory) {
  3. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-dsv')) :
  4. typeof define === 'function' && define.amd ? define(['exports', 'd3-dsv'], factory) :
  5. (factory((global.d3 = global.d3 || {}),global.d3));
  6. }(this, (function (exports,d3Dsv) { 'use strict';
  7. function responseBlob(response) {
  8. if (!response.ok) throw new Error(response.status + " " + response.statusText);
  9. return response.blob();
  10. }
  11. function blob(input, init) {
  12. return fetch(input, init).then(responseBlob);
  13. }
  14. function responseArrayBuffer(response) {
  15. if (!response.ok) throw new Error(response.status + " " + response.statusText);
  16. return response.arrayBuffer();
  17. }
  18. function buffer(input, init) {
  19. return fetch(input, init).then(responseArrayBuffer);
  20. }
  21. function responseText(response) {
  22. if (!response.ok) throw new Error(response.status + " " + response.statusText);
  23. return response.text();
  24. }
  25. function text(input, init) {
  26. return fetch(input, init).then(responseText);
  27. }
  28. function dsvParse(parse) {
  29. return function(input, init, row) {
  30. if (arguments.length === 2 && typeof init === "function") row = init, init = undefined;
  31. return text(input, init).then(function(response) {
  32. return parse(response, row);
  33. });
  34. };
  35. }
  36. function dsv(delimiter, input, init, row) {
  37. if (arguments.length === 3 && typeof init === "function") row = init, init = undefined;
  38. var format = d3Dsv.dsvFormat(delimiter);
  39. return text(input, init).then(function(response) {
  40. return format.parse(response, row);
  41. });
  42. }
  43. var csv = dsvParse(d3Dsv.csvParse);
  44. var tsv = dsvParse(d3Dsv.tsvParse);
  45. function image(input, init) {
  46. return new Promise(function(resolve, reject) {
  47. var image = new Image;
  48. for (var key in init) image[key] = init[key];
  49. image.onerror = reject;
  50. image.onload = function() { resolve(image); };
  51. image.src = input;
  52. });
  53. }
  54. function responseJson(response) {
  55. if (!response.ok) throw new Error(response.status + " " + response.statusText);
  56. return response.json();
  57. }
  58. function json(input, init) {
  59. return fetch(input, init).then(responseJson);
  60. }
  61. function parser(type) {
  62. return function(input, init) {
  63. return text(input, init).then(function(text$$1) {
  64. return (new DOMParser).parseFromString(text$$1, type);
  65. });
  66. };
  67. }
  68. var xml = parser("application/xml");
  69. var html = parser("text/html");
  70. var svg = parser("image/svg+xml");
  71. exports.blob = blob;
  72. exports.buffer = buffer;
  73. exports.dsv = dsv;
  74. exports.csv = csv;
  75. exports.tsv = tsv;
  76. exports.image = image;
  77. exports.json = json;
  78. exports.text = text;
  79. exports.xml = xml;
  80. exports.html = html;
  81. exports.svg = svg;
  82. Object.defineProperty(exports, '__esModule', { value: true });
  83. })));