Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-request

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-request - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

src/dsv.js

2

build/bundle.js

@@ -1,1 +0,1 @@

var version = "0.3.2"; export * from "../index"; export {version};
var version = "0.4.0"; export * from "../index"; export {version};

@@ -143,3 +143,3 @@ (function (global, factory) {

function requestType(defaultMimeType, response) {
function type(defaultMimeType, response) {
return function(url, callback) {

@@ -151,15 +151,15 @@ var r = request(url).mimeType(defaultMimeType).response(response);

var html = requestType("text/html", function(xhr) {
var html = type("text/html", function(xhr) {
return document.createRange().createContextualFragment(xhr.responseText);
});
var json = requestType("application/json", function(xhr) {
var json = type("application/json", function(xhr) {
return JSON.parse(xhr.responseText);
});
var text = requestType("text/plain", function(xhr) {
var text = type("text/plain", function(xhr) {
return xhr.responseText;
});
var xml = requestType("application/xml", function(xhr) {
var xml = type("application/xml", function(xhr) {
var xml = xhr.responseXML;

@@ -170,7 +170,7 @@ if (!xml) throw new Error("parse error");

function requestDsv(defaultMimeType, dsv) {
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(dsv, row = _)) : row; };
r.row = function(_) { return arguments.length ? r.response(responseOf(parse, row = _)) : row; };
r.row(row);

@@ -181,23 +181,23 @@ return callback ? r.get(callback) : r;

function responseOf(dsv, row) {
function responseOf(parse, row) {
return function(request) {
return dsv.parse(request.responseText, row);
return parse(request.responseText, row);
};
}
var csv$1 = requestDsv("text/csv", d3Dsv.csv);
var csv = dsv("text/csv", d3Dsv.csvParse);
var tsv$1 = requestDsv("text/tab-separated-values", d3Dsv.tsv);
var tsv = dsv("text/tab-separated-values", d3Dsv.tsvParse);
var version = "0.3.2";
var version = "0.4.0";
exports.version = version;
exports.request = request;
exports.requestHtml = html;
exports.requestJson = json;
exports.requestText = text;
exports.requestXml = xml;
exports.requestCsv = csv$1;
exports.requestTsv = tsv$1;
exports.html = html;
exports.json = json;
exports.text = text;
exports.xml = xml;
exports.csv = csv;
exports.tsv = tsv;
}));

@@ -1,1 +0,1 @@

!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_request={},e.d3_collection,e.d3_dispatch,e.d3_dsv)}(this,function(e,n,t,r){"use strict";function o(e,r){function o(e){var n,t=d.status;if(!t&&s(d)||t>=200&&300>t||304===t){if(l)try{n=l.call(i,d)}catch(r){return void p.error.call(i,r)}else n=d;p.load.call(i,n)}else p.error.call(i,e)}var i,a,l,c,p=t.dispatch("beforesend","progress","load","error"),f=n.map(),d=new XMLHttpRequest,m=0;return"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){p.progress.call(i,e)},i={header:function(e,n){return e=(e+"").toLowerCase(),arguments.length<2?f.get(e):(null==n?f.remove(e):f.set(e,n+""),i)},mimeType:function(e){return arguments.length?(a=null==e?null:e+"",i):a},responseType:function(e){return arguments.length?(c=e,i):c},timeout:function(e){return arguments.length?(m=+e,i):m},response:function(e){return l=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 r||"function"!=typeof t||(r=t,t=null),r&&1===r.length&&(r=u(r)),d.open(n,e,!0),null==a||f.has("accept")||f.set("accept",a+",*/*"),d.setRequestHeader&&f.each(function(e,n){d.setRequestHeader(n,e)}),null!=a&&d.overrideMimeType&&d.overrideMimeType(a),null!=c&&(d.responseType=c),m>0&&(d.timeout=m),r&&i.on("error",r).on("load",function(e){r(null,e)}),p.beforesend.call(i,d),d.send(null==t?null:t),i},abort:function(){return d.abort(),i},on:function(){var e=p.on.apply(p,arguments);return e===p?i:e}},r?i.get(r):i}function u(e){return function(n,t){e(null==n?t:null)}}function s(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);return r?u.get(r):u}}function a(e,n){return function(t,r,u){arguments.length<3&&(u=r,r=null);var s=o(t).mimeType(e);return s.row=function(e){return arguments.length?s.response(l(n,r=e)):r},s.row(r),u?s.get(u):s}}function l(e,n){return function(t){return e.parse(t.responseText,n)}}var c=i("text/html",function(e){return document.createRange().createContextualFragment(e.responseText)}),p=i("application/json",function(e){return JSON.parse(e.responseText)}),f=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}),m=a("text/csv",r.csv),g=a("text/tab-separated-values",r.tsv),v="0.3.2";e.version=v,e.request=o,e.requestHtml=c,e.requestJson=p,e.requestText=f,e.requestXml=d,e.requestCsv=m,e.requestTsv=g});
!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_request={},e.d3_collection,e.d3_dispatch,e.d3_dsv)}(this,function(e,n,t,r){"use strict";function o(e,r){function o(e){var n,t=d.status;if(!t&&s(d)||t>=200&&300>t||304===t){if(l)try{n=l.call(i,d)}catch(r){return void p.error.call(i,r)}else n=d;p.load.call(i,n)}else p.error.call(i,e)}var i,a,l,c,p=t.dispatch("beforesend","progress","load","error"),f=n.map(),d=new XMLHttpRequest,m=0;return"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){p.progress.call(i,e)},i={header:function(e,n){return e=(e+"").toLowerCase(),arguments.length<2?f.get(e):(null==n?f.remove(e):f.set(e,n+""),i)},mimeType:function(e){return arguments.length?(a=null==e?null:e+"",i):a},responseType:function(e){return arguments.length?(c=e,i):c},timeout:function(e){return arguments.length?(m=+e,i):m},response:function(e){return l=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 r||"function"!=typeof t||(r=t,t=null),r&&1===r.length&&(r=u(r)),d.open(n,e,!0),null==a||f.has("accept")||f.set("accept",a+",*/*"),d.setRequestHeader&&f.each(function(e,n){d.setRequestHeader(n,e)}),null!=a&&d.overrideMimeType&&d.overrideMimeType(a),null!=c&&(d.responseType=c),m>0&&(d.timeout=m),r&&i.on("error",r).on("load",function(e){r(null,e)}),p.beforesend.call(i,d),d.send(null==t?null:t),i},abort:function(){return d.abort(),i},on:function(){var e=p.on.apply(p,arguments);return e===p?i:e}},r?i.get(r):i}function u(e){return function(n,t){e(null==n?t:null)}}function s(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);return r?u.get(r):u}}function a(e,n){return function(t,r,u){arguments.length<3&&(u=r,r=null);var s=o(t).mimeType(e);return s.row=function(e){return arguments.length?s.response(l(n,r=e)):r},s.row(r),u?s.get(u):s}}function l(e,n){return function(t){return e(t.responseText,n)}}var c=i("text/html",function(e){return document.createRange().createContextualFragment(e.responseText)}),p=i("application/json",function(e){return JSON.parse(e.responseText)}),f=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}),m=a("text/csv",r.csvParse),g=a("text/tab-separated-values",r.tsvParse),h="0.4.0";e.version=h,e.request=o,e.html=c,e.json=p,e.text=f,e.xml=d,e.csv=m,e.tsv=g});
export {default as request} from "./src/request";
export {default as requestHtml} from "./src/html";
export {default as requestJson} from "./src/json";
export {default as requestText} from "./src/text";
export {default as requestXml} from "./src/xml";
export {default as requestCsv} from "./src/csv";
export {default as requestTsv} from "./src/tsv";
export {default as html} from "./src/html";
export {default as json} from "./src/json";
export {default as text} from "./src/text";
export {default as xml} from "./src/xml";
export {default as csv} from "./src/csv";
export {default as tsv} from "./src/tsv";
{
"name": "d3-request",
"version": "0.3.2",
"version": "0.4.0",
"description": "A convenient alternative to XMLHttpRequest.",

@@ -27,3 +27,3 @@ "keywords": [

"prepublish": "npm run test && uglifyjs build/d3-request.js -c -m -o build/d3-request.min.js && rm -f build/d3-request.zip && zip -j build/d3-request.zip -- LICENSE README.md build/d3-request.js build/d3-request.min.js",
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git tag -am \"Release $VERSION.\" v${VERSION} && git push --tags && cp build/d3-request.js ../d3.github.com/d3-request.v0.3.js && cp build/d3-request.min.js ../d3.github.com/d3-request.v0.3.min.js && cd ../d3.github.com && git add d3-request.v0.3.js d3-request.v0.3.min.js && git commit -m \"d3-request ${VERSION}\" && git push"
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git tag -am \"Release $VERSION.\" v${VERSION} && git push --tags && cp build/d3-request.js ../d3.github.com/d3-request.v0.4.js && cp build/d3-request.min.js ../d3.github.com/d3-request.v0.4.min.js && cd ../d3.github.com && git add d3-request.v0.4.js d3-request.v0.4.min.js && git commit -m \"d3-request ${VERSION}\" && git push"
},

@@ -33,3 +33,3 @@ "dependencies": {

"d3-dispatch": "~0.2.6",
"d3-dsv": "~0.1.14"
"d3-dsv": "~0.2.0"
},

@@ -36,0 +36,0 @@ "devDependencies": {

@@ -6,3 +6,3 @@ # d3-request

```js
d3.requestText("/path/to/file.txt", function(error, text) {
d3.text("/path/to/file.txt", function(error, text) {
if (error) throw error;

@@ -16,3 +16,3 @@ console.log(text); // Hello, world!

```js
d3.requestCsv("/path/to/file.csv", function(error, data) {
d3.csv("/path/to/file.csv", function(error, data) {
if (error) throw error;

@@ -31,3 +31,3 @@ console.log(data); // [{"Hello": "world"}, …]

This module has built-in support for parsing [JSON](#requestJson), [XML](#requestXml), [CSV](#requestCsv) and [TSV](#requestTsv). You can parse additional formats by using [request](#request) or [requestText](#requestText) directly.
This module has built-in support for parsing [JSON](#json), [XML](#xml), [CSV](#csv) and [TSV](#tsv). You can parse additional formats by using [request](#request) or [text](#text) directly.

@@ -41,4 +41,4 @@ ## Installing

<script src="https://d3js.org/d3-dispatch.v0.2.min.js"></script>
<script src="https://d3js.org/d3-dsv.v0.1.min.js"></script>
<script src="https://d3js.org/d3-request.v0.3.min.js"></script>
<script src="https://d3js.org/d3-dsv.v0.2.min.js"></script>
<script src="https://d3js.org/d3-request.v0.4.min.js"></script>
```

@@ -95,3 +95,3 @@

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 [requestJson](#requestJson) and [requestText](#requestText) for examples.
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.

@@ -144,3 +144,3 @@ <a name="request_get" href="#request_get">#</a> <i>request</i>.<b>get</b>([<i>callback</i>])

<a name="requestCsv" href="#requestCsv">#</a> d3.<b>requestCsv</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>])

@@ -163,3 +163,3 @@ Creates a request for the [CSV](https://github.com/d3/d3-dsv#csv) 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:

```js
d3.requestCsv(url, row, callback);
d3.csv(url, row, callback);
```

@@ -170,3 +170,3 @@

```js
d3.requestCsv(url)
d3.csv(url)
.row(row)

@@ -185,3 +185,3 @@ .get(callback);

<a name="requestHtml" href="#requestHtml">#</a> d3.<b>requestHtml</b>(<i>url</i>[, <i>callback</i>])
<a name="html" href="#html">#</a> d3.<b>html</b>(<i>url</i>[, <i>callback</i>])

@@ -199,3 +199,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="requestJson" href="#requestJson">#</a> d3.<b>requestJson</b>(<i>url</i>[, <i>callback</i>])
<a name="json" href="#json">#</a> d3.<b>json</b>(<i>url</i>[, <i>callback</i>])

@@ -213,3 +213,3 @@ Creates a request for the [JSON](http://json.org) file at the specified *url* with the default mime type `"application/json"`.

<a name="requestText" href="#requestText">#</a> d3.<b>requestText</b>(<i>url</i>[, <i>callback</i>])
<a name="text" href="#text">#</a> d3.<b>text</b>(<i>url</i>[, <i>callback</i>])

@@ -227,3 +227,3 @@ Creates a request for the text file at the specified *url* with the default mime type `"text/plain"`.

<a name="requestTsv" href="#requestTsv">#</a> d3.<b>requestTsv</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>])

@@ -246,3 +246,3 @@ Creates a request for the [TSV](https://github.com/d3/d3-dsv#tsv) 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:

```js
d3.requestTsv(url, row, callback);
d3.tsv(url, row, callback);
```

@@ -253,3 +253,3 @@

```js
d3.requestTsv(url)
d3.tsv(url)
.row(row)

@@ -268,3 +268,3 @@ .get(callback);

<a name="requestXml" href="#requestXml">#</a> d3.<b>requestXml</b>(<i>url</i>[, <i>callback</i>])
<a name="xml" href="#xml">#</a> d3.<b>xml</b>(<i>url</i>[, <i>callback</i>])

@@ -271,0 +271,0 @@ Creates a request for the XML file at the specified *url* with the default mime type `"application/xml"`.

@@ -1,4 +0,4 @@

import {csv} from "d3-dsv";
import requestDsv from "./requestDsv";
import {csvParse} from "d3-dsv";
import dsv from "./dsv";
export default requestDsv("text/csv", csv);
export default dsv("text/csv", csvParse);

@@ -1,5 +0,5 @@

import requestType from "./requestType";
import type from "./type";
export default requestType("text/html", function(xhr) {
export default type("text/html", function(xhr) {
return document.createRange().createContextualFragment(xhr.responseText);
});

@@ -1,5 +0,5 @@

import requestType from "./requestType";
import type from "./type";
export default requestType("application/json", function(xhr) {
export default type("application/json", function(xhr) {
return JSON.parse(xhr.responseText);
});

@@ -1,5 +0,5 @@

import requestType from "./requestType";
import type from "./type";
export default requestType("text/plain", function(xhr) {
export default type("text/plain", function(xhr) {
return xhr.responseText;
});

@@ -1,4 +0,4 @@

import {tsv} from "d3-dsv";
import requestDsv from "./requestDsv";
import {tsvParse} from "d3-dsv";
import dsv from "./dsv";
export default requestDsv("text/tab-separated-values", tsv);
export default dsv("text/tab-separated-values", tsvParse);

@@ -1,4 +0,4 @@

import requestType from "./requestType";
import type from "./type";
export default requestType("application/xml", function(xhr) {
export default type("application/xml", function(xhr) {
var xml = xhr.responseXML;

@@ -5,0 +5,0 @@ if (!xml) throw new Error("parse error");

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc