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