vega-loader
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -286,18 +286,14 @@ (function (global, factory) { | ||
var topojson = function(data, format) { | ||
var object, property; | ||
var method, object, property; | ||
data = json(data, format); | ||
if (format && (property = format.feature)) { | ||
return (object = data.objects[property]) | ||
? topojsonClient.feature(data, object).features | ||
: vegaUtil.error('Invalid TopoJSON object: ' + property); | ||
} | ||
method = (format && (property = format.feature)) ? topojsonClient.feature | ||
: (format && (property = format.mesh)) ? topojsonClient.mesh | ||
: vegaUtil.error('Missing TopoJSON feature or mesh parameter.'); | ||
else if (format && (property = format.mesh)) { | ||
return (object = data.objects[property]) | ||
? [topojsonClient.mesh(data, object)] | ||
: vegaUtil.error('Invalid TopoJSON object: ' + property); | ||
} | ||
object = (object = data.objects[property]) | ||
? method(data, object) | ||
: vegaUtil.error('Invalid TopoJSON object: ' + property); | ||
vegaUtil.error('Missing TopoJSON feature or mesh parameter.'); | ||
return object && object.features || [object]; | ||
}; | ||
@@ -304,0 +300,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("d3-request"),require("d3-dsv"),require("topojson-client"),require("d3-time-format")):"function"==typeof define&&define.amd?define(["exports","vega-util","d3-request","d3-dsv","topojson-client","d3-time-format"],t):t(e.vega=e.vega||{},e.vega,e.d3,e.d3,e.topojson,e.d3)}(this,function(e,t,r,n,o,i){"use strict";function u(e,r){return t.extend({},e.options,r)}function f(e,t){var r=this;return r.sanitize(e,t).then(function(e){var n=e.href;return e.localFile?r.file(n):r.http(n,t)})}function s(e,r){return r=u(this,r),new Promise(function(n,o){var i,u,f,s,a={href:null};null!=e&&"string"==typeof e?(u=y.test(e),(s=r.baseURL)&&!u&&(d(e,"/")||"/"===s[s.length-1]||(e="/"+e),e=s+e),f=(i=d(e,b))||"file"===r.mode||"http"!==r.mode&&!u&&c(),i?e=e.slice(b.length):d(e,"//")&&("file"===r.defaultProtocol?(e=e.slice(2),f=!0):e=(r.defaultProtocol||"http")+":"+e),Object.defineProperty(a,"localFile",{value:!!f}),a.href=e,n(a)):o("Sanitize failure, invalid URI: "+t.stringValue(e))})}function a(e,t){return t=u(this,t),new Promise(function(n,o){var i,u=r.request(e);for(i in t.headers)u.header(i,t.headers[i]);j.forEach(function(e){t[e]&&u[e](t[e])}),u.on("error",function(t){o(t||"Error loading URL: "+e)}).on("load",function(e){var t=e&&e.responseText;e&&0!==e.status?n(t):o(t||"Error")}).get()})}function l(e){return new Promise(function(t,r){var n=c();n?n.readFile(e,function(e,n){e?r(e):t(n)}):r("No file system access for "+e)})}function c(){var e="function"==typeof require&&require("fs");return e&&t.isFunction(e.readFile)?e:null}function d(e,t){return null!=e&&0===e.lastIndexOf(t,0)}function p(e,t){if(!e||!e.length)return"unknown";var r,n,o,i,u=N.slice();for(n=0,o=e.length;n<o;++n){for(r=t?e[n][t]:e[n],i=0;i<u.length;++i)(function(e){return null!=e&&e==e})(r)&&!u[i](r)&&(u.splice(i,1),--i);if(0===u.length)return"string"}return P[N.indexOf(u[0])]}function h(e,t){return t.reduce(function(t,r){return t[r]=p(e,r),t},{})}function m(e){return!(isNaN(+e)||e instanceof Date)}function v(e){return function(r,n){var o={delimiter:e};return g(r,n?t.extend(n,o):o)}}function g(e,r){return r.header&&(e=r.header.map(t.stringValue).join(r.delimiter)+"\n"+e),n.dsvFormat(r.delimiter).parse(e+"")}var y=/^([A-Za-z]+:)?\/\//,b="file://",j=["mimeType","responseType","user","password"],O={boolean:t.toBoolean,integer:t.toNumber,number:t.toNumber,date:t.toDate,string:t.toString,unknown:t.identity},N=[function(e){return"true"===e||"false"===e||!0===e||!1===e},function(e){return m(e)&&(e=+e)==~~e},m,function(e){return!isNaN(Date.parse(e))}],P=["boolean","integer","number","date"],q=function(e,r){var n=r&&r.property?t.field(r.property):t.identity;return t.isObject(e)&&!function(e){return!("function"!=typeof Buffer||!t.isFunction(Buffer.isBuffer))&&Buffer.isBuffer(e)}(e)?function(e,t){return t&&t.copy?JSON.parse(JSON.stringify(e)):e}(n(e)):n(JSON.parse(e))},w={dsv:g,csv:v(","),tsv:v("\t"),json:q,topojson:function(e,r){var n,i;return e=q(e,r),r&&(i=r.feature)?(n=e.objects[i])?o.feature(e,n).features:t.error("Invalid TopoJSON object: "+i):r&&(i=r.mesh)?(n=e.objects[i])?[o.mesh(e,n)]:t.error("Invalid TopoJSON object: "+i):void t.error("Missing TopoJSON feature or mesh parameter.")}},x=function(e,t){return arguments.length>1?(w[e]=t,this):w.hasOwnProperty(e)?w[e]:null};e.loader=function(e){return{options:e||{},sanitize:s,load:f,file:l,http:a}},e.read=function(e,r,n){var o=x((r=r||{}).type||"json");return o||t.error("Unknown data format type: "+r.type),e=o(e,r),r.parse&&function(e,t,r){if(e.length){r=r||i.timeParse;var n,o,u,f,s,a,l,c=e.columns||Object.keys(e[0]);for("auto"===t&&(t=h(e,c)),n=(c=Object.keys(t)).map(function(e){var n,o,u=t[e];if(u&&(0===u.indexOf("date:")||0===u.indexOf("utc:")))return n=u.split(/:(.+)?/,2),("'"===(o=n[1])[0]&&"'"===o[o.length-1]||'"'===o[0]&&'"'===o[o.length-1])&&(o=o.slice(1,-1)),"utc"===n[0]?i.utcParse(o):r(o);if(!O[u])throw Error("Illegal format pattern: "+e+":"+u);return O[u]}),f=0,a=e.length,l=c.length;f<a;++f)for(o=e[f],s=0;s<l;++s)o[u=c[s]]=n[s](o[u])}}(e,r.parse,n),e.hasOwnProperty("columns")&&delete e.columns,e},e.inferType=p,e.inferTypes=h,e.typeParsers=O,e.formats=x,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("d3-request"),require("d3-dsv"),require("topojson-client"),require("d3-time-format")):"function"==typeof define&&define.amd?define(["exports","vega-util","d3-request","d3-dsv","topojson-client","d3-time-format"],t):t(e.vega=e.vega||{},e.vega,e.d3,e.d3,e.topojson,e.d3)}(this,function(e,t,r,n,o,i){"use strict";var u=/^([A-Za-z]+:)?\/\//,f="file://",a=["mimeType","responseType","user","password"];function s(e,r){return t.extend({},e.options,r)}function l(e,t){var r=this;return r.sanitize(e,t).then(function(e){var n=e.href;return e.localFile?r.file(n):r.http(n,t)})}function c(e,r){return r=s(this,r),new Promise(function(n,o){var i,a,s,l,c={href:null};null!=e&&"string"==typeof e?(a=u.test(e),(l=r.baseURL)&&!a&&(m(e,"/")||"/"===l[l.length-1]||(e="/"+e),e=l+e),s=(i=m(e,f))||"file"===r.mode||"http"!==r.mode&&!a&&h(),i?e=e.slice(f.length):m(e,"//")&&("file"===r.defaultProtocol?(e=e.slice(2),s=!0):e=(r.defaultProtocol||"http")+":"+e),Object.defineProperty(c,"localFile",{value:!!s}),c.href=e,n(c)):o("Sanitize failure, invalid URI: "+t.stringValue(e))})}function d(e,t){return t=s(this,t),new Promise(function(n,o){var i,u=r.request(e);for(i in t.headers)u.header(i,t.headers[i]);a.forEach(function(e){t[e]&&u[e](t[e])}),u.on("error",function(t){o(t||"Error loading URL: "+e)}).on("load",function(e){var t=e&&e.responseText;e&&0!==e.status?n(t):o(t||"Error")}).get()})}function p(e){return new Promise(function(t,r){var n=h();n?n.readFile(e,function(e,n){e?r(e):t(n)}):r("No file system access for "+e)})}function h(){var e="function"==typeof require&&require("fs");return e&&t.isFunction(e.readFile)?e:null}function m(e,t){return null!=e&&0===e.lastIndexOf(t,0)}var v={boolean:t.toBoolean,integer:t.toNumber,number:t.toNumber,date:t.toDate,string:t.toString,unknown:t.identity},g=[function(e){return"true"===e||"false"===e||!0===e||!1===e},function(e){return j(e)&&(e=+e)==~~e},j,function(e){return!isNaN(Date.parse(e))}],y=["boolean","integer","number","date"];function O(e,t){if(!e||!e.length)return"unknown";var r,n,o,i,u,f=g.slice();for(n=0,o=e.length;n<o;++n){for(r=t?e[n][t]:e[n],i=0;i<f.length;++i)null==(u=r)||u!=u||f[i](r)||(f.splice(i,1),--i);if(0===f.length)return"string"}return y[g.indexOf(f[0])]}function b(e,t){return t.reduce(function(t,r){return t[r]=O(e,r),t},{})}function j(e){return!(isNaN(+e)||e instanceof Date)}function N(e){return function(r,n){var o={delimiter:e};return P(r,n?t.extend(n,o):o)}}function P(e,r){return r.header&&(e=r.header.map(t.stringValue).join(r.delimiter)+"\n"+e),n.dsvFormat(r.delimiter).parse(e+"")}var q=function(e,r){var n,o,i,u=r&&r.property?t.field(r.property):t.identity;return!t.isObject(e)||(i=e,"function"==typeof Buffer&&t.isFunction(Buffer.isBuffer)&&Buffer.isBuffer(i))?u(JSON.parse(e)):(n=u(e),o&&o.copy?JSON.parse(JSON.stringify(n)):n)};var w={dsv:P,csv:N(","),tsv:N("\t"),json:q,topojson:function(e,r){var n,i,u;return e=q(e,r),n=r&&(u=r.feature)?o.feature:r&&(u=r.mesh)?o.mesh:t.error("Missing TopoJSON feature or mesh parameter."),(i=(i=e.objects[u])?n(e,i):t.error("Invalid TopoJSON object: "+u))&&i.features||[i]}},x=function(e,t){return arguments.length>1?(w[e]=t,this):w.hasOwnProperty(e)?w[e]:null};e.loader=function(e){return{options:e||{},sanitize:c,load:l,file:p,http:d}},e.read=function(e,r,n){var o=x((r=r||{}).type||"json");return o||t.error("Unknown data format type: "+r.type),e=o(e,r),r.parse&&function(e,t,r){if(e.length){r=r||i.timeParse;var n,o,u,f,a,s,l,c=e.columns||Object.keys(e[0]);for("auto"===t&&(t=b(e,c)),c=Object.keys(t),n=c.map(function(e){var n,o,u=t[e];if(u&&(0===u.indexOf("date:")||0===u.indexOf("utc:")))return("'"===(o=(n=u.split(/:(.+)?/,2))[1])[0]&&"'"===o[o.length-1]||'"'===o[0]&&'"'===o[o.length-1])&&(o=o.slice(1,-1)),"utc"===n[0]?i.utcParse(o):r(o);if(!v[u])throw Error("Illegal format pattern: "+e+":"+u);return v[u]}),f=0,s=e.length,l=c.length;f<s;++f)for(o=e[f],a=0;a<l;++a)u=c[a],o[u]=n[a](o[u])}}(e,r.parse,n),e.hasOwnProperty("columns")&&delete e.columns,e},e.inferType=O,e.inferTypes=b,e.typeParsers=v,e.formats=x,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "vega-loader", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Network request and file loading utilities.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -6,18 +6,14 @@ import json from './json'; | ||
export default function(data, format) { | ||
var object, property; | ||
var method, object, property; | ||
data = json(data, format); | ||
if (format && (property = format.feature)) { | ||
return (object = data.objects[property]) | ||
? feature(data, object).features | ||
: error('Invalid TopoJSON object: ' + property); | ||
} | ||
method = (format && (property = format.feature)) ? feature | ||
: (format && (property = format.mesh)) ? mesh | ||
: error('Missing TopoJSON feature or mesh parameter.'); | ||
else if (format && (property = format.mesh)) { | ||
return (object = data.objects[property]) | ||
? [mesh(data, object)] | ||
: error('Invalid TopoJSON object: ' + property); | ||
} | ||
object = (object = data.objects[property]) | ||
? method(data, object) | ||
: error('Invalid TopoJSON object: ' + property); | ||
error('Missing TopoJSON feature or mesh parameter.'); | ||
return object && object.features || [object]; | ||
} |
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
39481
655