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

@observablehq/stdlib

Package Overview
Dependencies
Maintainers
3
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@observablehq/stdlib - npm Package Compare versions

Comparing version 3.10.0 to 3.11.0

4

dist/stdlib.js

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

// @observablehq/stdlib v3.10.0 Copyright 2021 Observable, Inc.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).observablehq=e.observablehq||{})}(this,(function(e){"use strict";const t=new Map,n=[],r=n.map,o=n.some,i=n.hasOwnProperty,s="https://cdn.jsdelivr.net/npm/",a=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,u=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,l=/\.[^/]*$/,c=["unpkg","jsdelivr","browser","main"];class RequireError extends Error{constructor(e){super(e)}}function f(e){const t=a.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function d(e){const n=`${s}${e.name}${e.version?`@${e.version}`:""}/package.json`;let r=t.get(n);return r||t.set(n,r=fetch(n).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!t.has(e.url)&&t.set(e.url,r),e.json()}))),r}RequireError.prototype.name=RequireError.name;var h=m((async function(e,t){if(e.startsWith(s)&&(e=e.substring(s.length)),/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new RequireError("illegal name");const n=f(e);if(!n)return`${s}${e}`;if(!n.version&&null!=t&&t.startsWith(s)){const e=await d(f(t.substring(s.length)));n.version=e.dependencies&&e.dependencies[n.name]||e.peerDependencies&&e.peerDependencies[n.name]}if(n.path&&!l.test(n.path)&&(n.path+=".js"),n.path&&n.version&&u.test(n.version))return`${s}${n.name}@${n.version}/${n.path}`;const r=await d(n);return`${s}${r.name}@${r.version}/${n.path||function(e){for(const t of c){const n=e[t];if("string"==typeof n)return l.test(n)?n:`${n}.js`}}(r)||"index.js"}`}));function m(e){const t=new Map,o=s(null);function i(e){if("string"!=typeof e)return e;let r=t.get(e);return r||t.set(e,r=new Promise(((t,r)=>{const o=document.createElement("script");o.onload=()=>{try{t(n.pop()(s(e)))}catch(e){r(new RequireError("invalid module"))}o.remove()},o.onerror=()=>{r(new RequireError("unable to load module")),o.remove()},o.async=!0,o.src=e,window.define=y,document.head.appendChild(o)}))),r}function s(t){return n=>Promise.resolve(e(n,t)).then(i)}function a(e){return arguments.length>1?Promise.all(r.call(arguments,o)).then(p):o(e)}return a.alias=function(t){return m(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},a.resolve=e,a}function p(e){const t={};for(const n of e)for(const e in n)i.call(n,e)&&(null==n[e]?Object.defineProperty(t,e,{get:v(n,e)}):t[e]=n[e]);return t}function v(e,t){return()=>e[t]}function w(e){return"exports"===(e+="")||"module"===e}function y(e,t,i){const s=arguments.length;s<2?(i=e,t=[]):s<3&&(i=t,t="string"==typeof e?[]:e),n.push(o.call(t,w)?e=>{const n={},o={exports:n};return Promise.all(r.call(t,(t=>"exports"===(t+="")?n:"module"===t?o:e(t)))).then((e=>(i.apply(null,e),o.exports)))}:e=>Promise.all(r.call(t,e)).then((e=>"function"==typeof i?i.apply(null,e):i)))}function b(e,t,n){return{resolve:(r=n)=>`https://cdn.jsdelivr.net/npm/${e}@${t}/${r}`}}y.amd={};const g=b("d3","7.0.1","dist/d3.min.js"),x=b("d3-dsv","3.0.1","dist/d3-dsv.min.js"),j=b("@observablehq/inputs","0.9.0","dist/inputs.min.js"),E=b("@observablehq/plot","0.2.0","dist/plot.umd.min.js"),P=b("@observablehq/graphviz","0.2.1","dist/graphviz.min.js"),L=b("@observablehq/highlight.js","2.0.0","highlight.min.js"),O=b("@observablehq/katex","0.11.1","dist/katex.min.js"),$=b("lodash","4.17.21","lodash.min.js"),A=b("htl","0.3.0","dist/htl.min.js"),R=b("jszip","3.7.1","dist/jszip.min.js"),k=b("marked","0.3.12","marked.min.js"),N=b("sql.js","1.6.1","dist/sql-wasm.js"),q=b("vega","5.20.2","build/vega.min.js"),C=b("vega-lite","5.1.0","build/vega-lite.min.js"),_=b("vega-lite-api","5.0.0","build/vega-lite-api.min.js"),M=b("apache-arrow","4.0.1","Arrow.es2015.min.js"),U=b("topojson-client","3.1.0","dist/topojson-client.min.js");async function S(e){return(await e(N.resolve()))({locateFile:e=>N.resolve(`dist/${e}`)})}class SQLiteDatabaseClient{constructor(e){Object.defineProperties(this,{_db:{value:e}})}static async open(e){const[t,n]=await Promise.all([S(h),Promise.resolve(e).then(T)]);return new SQLiteDatabaseClient(new t.Database(n))}async query(e,t){return await async function(e,t,n){const[r]=await e.exec(t,n);if(!r)return[];const{columns:o,values:i}=r,s=i.map((e=>Object.fromEntries(e.map(((e,t)=>[o[t],e])))));return s.columns=o,s}(this._db,e,t)}async queryRow(e,t){return(await this.query(e,t))[0]||null}async explain(e,t){return F("pre",{className:"observablehq--inspect"},[D((await this.query(`EXPLAIN QUERY PLAN ${e}`,t)).map((e=>e.detail)).join("\n"))])}async describe(e){const t=await(void 0===e?this.query("SELECT name FROM sqlite_master WHERE type = 'table'"):this.query("SELECT * FROM pragma_table_info(?)",[e]));if(!t.length)throw new Error("Not found");const{columns:n}=t;return F("table",{value:t},[F("thead",[F("tr",n.map((e=>F("th",[D(e)]))))]),F("tbody",t.map((e=>F("tr",n.map((t=>F("td",[D(e[t])])))))))])}}function T(e){return"string"==typeof e?fetch(e).then(T):e instanceof Response||e instanceof Blob?e.arrayBuffer().then(T):e instanceof ArrayBuffer?new Uint8Array(e):e}function F(e,t,n){2===arguments.length&&(n=t,t=void 0);const r=document.createElement(e);if(void 0!==t)for(const e in t)r[e]=t[e];if(void 0!==n)for(const e of n)r.appendChild(e);return r}function D(e){return document.createTextNode(e)}async function z(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function B(e,t,{array:n=!1,typed:r=!1}={}){const[o,i]=await Promise.all([e.text(),h(x.resolve())]);return("\t"===t?n?i.tsvParseRows:i.tsvParse:n?i.csvParseRows:i.csvParse)(o,r&&i.autoType)}class W{constructor(e){Object.defineProperty(this,"name",{value:e,enumerable:!0})}async blob(){return(await z(this)).blob()}async arrayBuffer(){return(await z(this)).arrayBuffer()}async text(){return(await z(this)).text()}async json(){return(await z(this)).json()}async stream(){return(await z(this)).body}async csv(e){return B(this,",",e)}async tsv(e){return B(this,"\t",e)}async image(){const e=await this.url();return new Promise(((t,n)=>{const r=new Image;new URL(e,document.baseURI).origin!==new URL(location).origin&&(r.crossOrigin="anonymous"),r.onload=()=>t(r),r.onerror=()=>n(new Error(`Unable to load file: ${this.name}`)),r.src=e}))}async arrow(){const[e,t]=await Promise.all([h(M.resolve()),z(this)]);return e.Table.from(t)}async sqlite(){return SQLiteDatabaseClient.open(z(this))}async zip(){const[e,t]=await Promise.all([h(R.resolve()),this.arrayBuffer()]);return new ZipArchive(await e.loadAsync(t))}}class FileAttachment extends W{constructor(e,t){super(t),Object.defineProperty(this,"_url",{value:e})}async url(){return await this._url+""}}function H(e){throw new Error(`File not found: ${e}`)}class ZipArchive{constructor(e){Object.defineProperty(this,"_",{value:e}),this.filenames=Object.keys(e.files).filter((t=>!e.files[t].dir))}file(e){const t=this._.file(e+="");if(!t||t.dir)throw new Error(`file not found: ${e}`);return new ZipArchiveEntry(t)}}class ZipArchiveEntry extends W{constructor(e){super(e.name),Object.defineProperty(this,"_",{value:e}),Object.defineProperty(this,"_url",{writable:!0})}async url(){return this._url||(this._url=this.blob().then(URL.createObjectURL))}async blob(){return this._.async("blob")}async arrayBuffer(){return this._.async("arraybuffer")}async text(){return this._.async("text")}async json(){return JSON.parse(await this.text())}}var I={math:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};var Q=0;function V(e){this.id=e,this.href=new URL(`#${e}`,location)+""}V.prototype.toString=function(){return"url("+this.href+")"};var X={canvas:function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n},context2d:function(e,t,n){null==n&&(n=devicePixelRatio);var r=document.createElement("canvas");r.width=e*n,r.height=t*n,r.style.width=e+"px";var o=r.getContext("2d");return o.scale(n,n),o},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),o=r.appendChild(document.createElement("button"));async function i(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),o.textContent=n,o.disabled=!1}return o.textContent=n,r.download=t,r.onclick=async t=>{if(o.disabled=!0,r.href)return i();o.textContent="Saving…";try{const t=await("function"==typeof e?e():e);o.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){o.textContent=n}if(t.eventPhase)return i();o.disabled=!1},r},element:function(e,t){var n,r=e+="",o=r.indexOf(":");o>=0&&"xmlns"!==(r=e.slice(0,o))&&(e=e.slice(o+1));var i=I.hasOwnProperty(r)?document.createElementNS(I[r],e):document.createElement(e);if(t)for(var s in t)o=(r=s).indexOf(":"),n=t[s],o>=0&&"xmlns"!==(r=s.slice(0,o))&&(s=s.slice(o+1)),I.hasOwnProperty(r)?i.setAttributeNS(I[r],s,n):i.setAttribute(s,n);return i},input:function(e){var t=document.createElement("input");return null!=e&&(t.type=e),t},range:function(e,t,n){1===arguments.length&&(t=e,e=null);var r=document.createElement("input");return r.min=e=null==e?0:+e,r.max=t=null==t?1:+t,r.step=null==n?"any":n=+n,r.type="range",r},select:function(e){var t=document.createElement("select");return Array.prototype.forEach.call(e,(function(e){var n=document.createElement("option");n.value=n.textContent=e,t.appendChild(n)})),t},svg:function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox",[0,0,e,t]),n.setAttribute("width",e),n.setAttribute("height",t),n},text:function(e){return document.createTextNode(e)},uid:function(e){return new V("O-"+(null==e?"":e+"-")+ ++Q)}};var G={buffer:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsArrayBuffer(e)}))},text:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsText(e)}))},url:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsDataURL(e)}))}};function J(){return this}function Y(e,t){let n=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:J,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function K(e){let t,n,r=!1;const o=e((function(e){n?(n(e),n=null):r=!0;return t=e}));if(null!=o&&"function"!=typeof o)throw new Error("function"==typeof o.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:J,throw:()=>({done:!0}),return:()=>(null!=o&&o(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise((e=>n=e))}}}}function Z(e){switch(e.type){case"range":case"number":return e.valueAsNumber;case"date":return e.valueAsDate;case"checkbox":return e.checked;case"file":return e.multiple?e.files:e.files[0];case"select-multiple":return Array.from(e.selectedOptions,(e=>e.value));default:return e.value}}var ee={disposable:Y,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return K((function(t){var n=function(e){switch(e.type){case"button":case"submit":case"checkbox":return"click";case"file":return"change";default:return"input"}}(e),r=Z(e);function o(){t(Z(e))}return e.addEventListener(n,o),void 0!==r&&t(r),function(){e.removeEventListener(n,o)}}))},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:K,queue:function(e){let t;const n=[],r=e((function(e){n.push(e),t&&(t(n.shift()),t=null);return e}));if(null!=r&&"function"!=typeof r)throw new Error("function"==typeof r.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:J,throw:()=>({done:!0}),return:()=>(null!=r&&r(),{done:!0}),next:function(){return{done:!1,value:n.length?Promise.resolve(n.shift()):new Promise((e=>t=e))}}}},range:function*(e,t,n){e=+e,t=+t,n=(o=arguments.length)<2?(t=e,e=0,1):o<3?1:+n;for(var r=-1,o=0|Math.max(0,Math.ceil((t-e)/n));++r<o;)yield e+r*n},valueAt:function(e,t){if(!(!isFinite(t=+t)||t<0||t!=t|0))for(var n,r=-1;!(n=e.next()).done;)if(++r===t)return n.value},worker:function(e){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"})),n=new Worker(t);return Y(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}};function te(e,t){return function(n){var r,o,i,s,a,u,l,c,f=n[0],d=[],h=null,m=-1;for(a=1,u=arguments.length;a<u;++a){if((r=arguments[a])instanceof Node)d[++m]=r,f+="\x3c!--o:"+m+"--\x3e";else if(Array.isArray(r)){for(l=0,c=r.length;l<c;++l)(o=r[l])instanceof Node?(null===h&&(d[++m]=h=document.createDocumentFragment(),f+="\x3c!--o:"+m+"--\x3e"),h.appendChild(o)):(h=null,f+=o);h=null}else f+=r;f+=n[a]}if(h=e(f),++m>0){for(i=new Array(m),s=document.createTreeWalker(h,NodeFilter.SHOW_COMMENT,null,!1);s.nextNode();)o=s.currentNode,/^o:/.test(o.nodeValue)&&(i[+o.nodeValue.slice(2)]=o);for(a=0;a<m;++a)(o=i[a])&&o.parentNode.replaceChild(d[a],o)}return 1===h.childNodes.length?h.removeChild(h.firstChild):11===h.nodeType?((o=t()).appendChild(h),o):h}}var ne=te((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));function re(e){let t;Object.defineProperties(this,{generator:{value:K((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*oe(){for(;;)yield Date.now()}var ie=new Map;function se(e,t){var n;return(n=ie.get(e=+e))?n.then((()=>t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise((function(n){ie.delete(t);var r=t-e;if(!(r>0))throw new Error("invalid time");if(r>2147483647)throw new Error("too long to wait");setTimeout(n,r)}));return ie.set(t,n),n}(n,e).then((()=>t))}var ae={delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return se(Math.ceil((Date.now()+1)/e)*e,t)},when:se};function ue(e,t){if(/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new Error("illegal name");return"https://unpkg.com/"+e}function le(e){return null==e?h:m(e)}var ce=te((function(e){var t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.innerHTML=e.trim(),t}),(function(){return document.createElementNS("http://www.w3.org/2000/svg","g")})),fe=String.raw;function de(){return K((function(e){var t=e(document.body.clientWidth);function n(){var n=document.body.clientWidth;n!==t&&e(t=n)}return window.addEventListener("resize",n),function(){window.removeEventListener("resize",n)}}))}var he=Object.assign((function(e){const t=le(e);var n;Object.defineProperties(this,(n={FileAttachment:()=>H,Arrow:()=>t(M.resolve()),Inputs:()=>t(j.resolve()),Mutable:()=>re,Plot:()=>t(E.resolve()),SQLite:()=>S(t),SQLiteDatabaseClient:()=>SQLiteDatabaseClient,_:()=>t($.resolve()),d3:()=>t(g.resolve()),dot:()=>t(P.resolve()),htl:()=>t(A.resolve()),html:()=>ne,md:()=>function(e){return e(k.resolve()).then((function(t){return te((function(n){var r=document.createElement("div");r.innerHTML=t(n,{langPrefix:""}).trim();var o=r.querySelectorAll("pre code[class]");return o.length>0&&e(L.resolve()).then((function(t){o.forEach((function(n){function r(){t.highlightBlock(n),n.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(n.className)?r():e(L.resolve("async-languages/index.js")).then((r=>{if(r.has(n.className))return e(L.resolve("async-languages/"+r.get(n.className))).then((e=>{t.registerLanguage(n.className,e)}))})).then(r,r)}))})),r}),(function(){return document.createElement("div")}))}))}(t),now:oe,require:()=>t,resolve:()=>ue,svg:()=>ce,tex:()=>function(e){return Promise.all([e(O.resolve()),(t=O.resolve("dist/katex.min.css"),new Promise((function(e,n){var r=document.createElement("link");r.rel="stylesheet",r.href=t,r.onerror=n,r.onload=e,document.head.appendChild(r)})))]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(fe.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}));var t}(t),topojson:()=>t(U.resolve()),vl:()=>async function(e){const[t,n,r]=await Promise.all([q,C,_].map((t=>e(t.resolve()))));return r.register(t,n)}(t),width:de,DOM:X,Files:G,Generators:ee,Promises:ae},Object.fromEntries(Object.entries(n).map(me))))}),{resolve:h.resolve});function me([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}e.FileAttachments=function(e){return Object.assign((t=>{const n=e(t+="");if(null==n)throw new Error(`File not found: ${t}`);return new FileAttachment(n,t)}),{prototype:FileAttachment.prototype})},e.Library=he,Object.defineProperty(e,"__esModule",{value:!0})}));
// @observablehq/stdlib v3.11.0 Copyright 2021 Observable, Inc.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).observablehq=e.observablehq||{})}(this,(function(e){"use strict";var t={},n={};function r(e){return new Function("d","return {"+e.map((function(e,t){return JSON.stringify(e)+": d["+t+'] || ""'})).join(",")+"}")}function o(e){var t=Object.create(null),n=[];return e.forEach((function(e){for(var r in e)r in t||n.push(t[r]=r)})),n}function i(e,t){var n=e+"",r=n.length;return r<t?new Array(t-r+1).join(0)+n:n}function a(e){var t,n=e.getUTCHours(),r=e.getUTCMinutes(),o=e.getUTCSeconds(),a=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":((t=e.getUTCFullYear())<0?"-"+i(-t,6):t>9999?"+"+i(t,6):i(t,4))+"-"+i(e.getUTCMonth()+1,2)+"-"+i(e.getUTCDate(),2)+(a?"T"+i(n,2)+":"+i(r,2)+":"+i(o,2)+"."+i(a,3)+"Z":o?"T"+i(n,2)+":"+i(r,2)+":"+i(o,2)+"Z":r||n?"T"+i(n,2)+":"+i(r,2)+"Z":"")}function s(e){var i=new RegExp('["'+e+"\n\r]"),s=e.charCodeAt(0);function u(e,r){var o,i=[],a=e.length,u=0,l=0,c=a<=0,f=!1;function d(){if(c)return n;if(f)return f=!1,t;var r,o,i=u;if(34===e.charCodeAt(i)){for(;u++<a&&34!==e.charCodeAt(u)||34===e.charCodeAt(++u););return(r=u)>=a?c=!0:10===(o=e.charCodeAt(u++))?f=!0:13===o&&(f=!0,10===e.charCodeAt(u)&&++u),e.slice(i+1,r-1).replace(/""/g,'"')}for(;u<a;){if(10===(o=e.charCodeAt(r=u++)))f=!0;else if(13===o)f=!0,10===e.charCodeAt(u)&&++u;else if(o!==s)continue;return e.slice(i,r)}return c=!0,e.slice(i,a)}for(10===e.charCodeAt(a-1)&&--a,13===e.charCodeAt(a-1)&&--a;(o=d())!==n;){for(var h=[];o!==t&&o!==n;)h.push(o),o=d();r&&null==(h=r(h,l++))||i.push(h)}return i}function l(t,n){return t.map((function(t){return n.map((function(e){return f(t[e])})).join(e)}))}function c(t){return t.map(f).join(e)}function f(e){return null==e?"":e instanceof Date?a(e):i.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,o,i=u(e,(function(e,i){if(n)return n(e,i-1);o=e,n=t?function(e,t){var n=r(e);return function(r,o){return t(n(r),o,e)}}(e,t):r(e)}));return i.columns=o||[],i},parseRows:u,format:function(t,n){return null==n&&(n=o(t)),[n.map(f).join(e)].concat(l(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=o(e)),l(e,t).join("\n")},formatRows:function(e){return e.map(c).join("\n")},formatRow:c,formatValue:f}}var u=s(","),l=u.parse,c=u.parseRows,f=s("\t"),d=f.parse,h=f.parseRows;function m(e){for(var t in e){var n,r,o=e[t].trim();if(o)if("true"===o)o=!0;else if("false"===o)o=!1;else if("NaN"===o)o=NaN;else if(isNaN(n=+o)){if(!(r=o.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)))continue;p&&r[4]&&!r[7]&&(o=o.replace(/-/g,"/").replace(/T/," ")),o=new Date(o)}else o=n;else o=null;e[t]=o}return e}const p=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours(),v=new Map,w=[],y=w.map,g=w.some,b=w.hasOwnProperty,j="https://cdn.jsdelivr.net/npm/",x=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,E=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,P=/\.[^/]*$/,A=["unpkg","jsdelivr","browser","main"];class RequireError extends Error{constructor(e){super(e)}}function C(e){const t=x.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function O(e){const t=`${j}${e.name}${e.version?`@${e.version}`:""}/package.json`;let n=v.get(t);return n||v.set(t,n=fetch(t).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!v.has(e.url)&&v.set(e.url,n),e.json()}))),n}RequireError.prototype.name=RequireError.name;var N=L((async function(e,t){if(e.startsWith(j)&&(e=e.substring(j.length)),/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new RequireError("illegal name");const n=C(e);if(!n)return`${j}${e}`;if(!n.version&&null!=t&&t.startsWith(j)){const e=await O(C(t.substring(j.length)));n.version=e.dependencies&&e.dependencies[n.name]||e.peerDependencies&&e.peerDependencies[n.name]}if(n.path&&!P.test(n.path)&&(n.path+=".js"),n.path&&n.version&&E.test(n.version))return`${j}${n.name}@${n.version}/${n.path}`;const r=await O(n);return`${j}${r.name}@${r.version}/${n.path||function(e){for(const t of A){const n=e[t];if("string"==typeof n)return P.test(n)?n:`${n}.js`}}(r)||"index.js"}`}));function L(e){const t=new Map,n=o(null);function r(e){if("string"!=typeof e)return e;let n=t.get(e);return n||t.set(e,n=new Promise(((t,n)=>{const r=document.createElement("script");r.onload=()=>{try{t(w.pop()(o(e)))}catch(e){n(new RequireError("invalid module"))}r.remove()},r.onerror=()=>{n(new RequireError("unable to load module")),r.remove()},r.async=!0,r.src=e,window.define=k,document.head.appendChild(r)}))),n}function o(t){return n=>Promise.resolve(e(n,t)).then(r)}function i(e){return arguments.length>1?Promise.all(y.call(arguments,n)).then(R):n(e)}return i.alias=function(t){return L(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},i.resolve=e,i}function R(e){const t={};for(const n of e)for(const e in n)b.call(n,e)&&(null==n[e]?Object.defineProperty(t,e,{get:$(n,e)}):t[e]=n[e]);return t}function $(e,t){return()=>e[t]}function T(e){return"exports"===(e+="")||"module"===e}function k(e,t,n){const r=arguments.length;r<2?(n=e,t=[]):r<3&&(n=t,t="string"==typeof e?[]:e),w.push(g.call(t,T)?e=>{const r={},o={exports:r};return Promise.all(y.call(t,(t=>"exports"===(t+="")?r:"module"===t?o:e(t)))).then((e=>(n.apply(null,e),o.exports)))}:e=>Promise.all(y.call(t,e)).then((e=>"function"==typeof n?n.apply(null,e):n)))}function U(e,t,n){return{resolve:(r=n)=>`https://cdn.jsdelivr.net/npm/${e}@${t}/${r}`}}k.amd={};const q=U("d3","7.0.1","dist/d3.min.js"),M=U("@observablehq/inputs","0.9.1","dist/inputs.min.js"),S=U("@observablehq/plot","0.2.0","dist/plot.umd.min.js"),_=U("@observablehq/graphviz","0.2.1","dist/graphviz.min.js"),D=U("@observablehq/highlight.js","2.0.0","highlight.min.js"),F=U("@observablehq/katex","0.11.1","dist/katex.min.js"),B=U("lodash","4.17.21","lodash.min.js"),z=U("htl","0.3.0","dist/htl.min.js"),H=U("jszip","3.7.1","dist/jszip.min.js"),W=U("marked","0.3.12","marked.min.js"),I=U("sql.js","1.6.1","dist/sql-wasm.js"),Z=U("vega","5.20.2","build/vega.min.js"),Q=U("vega-lite","5.1.0","build/vega-lite.min.js"),V=U("vega-lite-api","5.0.0","build/vega-lite-api.min.js"),J=U("apache-arrow","4.0.1","Arrow.es2015.min.js"),X=U("arquero","4.8.4","dist/arquero.min.js"),Y=U("topojson-client","3.1.0","dist/topojson-client.min.js");async function G(e){return(await e(I.resolve()))({locateFile:e=>I.resolve(`dist/${e}`)})}class SQLiteDatabaseClient{constructor(e){Object.defineProperties(this,{_db:{value:e}})}static async open(e){const[t,n]=await Promise.all([G(N),Promise.resolve(e).then(K)]);return new SQLiteDatabaseClient(new t.Database(n))}async query(e,t){return await async function(e,t,n){const[r]=await e.exec(t,n);if(!r)return[];const{columns:o,values:i}=r,a=i.map((e=>Object.fromEntries(e.map(((e,t)=>[o[t],e])))));return a.columns=o,a}(this._db,e,t)}async queryRow(e,t){return(await this.query(e,t))[0]||null}async explain(e,t){return ee("pre",{className:"observablehq--inspect"},[te((await this.query(`EXPLAIN QUERY PLAN ${e}`,t)).map((e=>e.detail)).join("\n"))])}async describe(e){const t=await(void 0===e?this.query("SELECT name FROM sqlite_master WHERE type = 'table'"):this.query("SELECT * FROM pragma_table_info(?)",[e]));if(!t.length)throw new Error("Not found");const{columns:n}=t;return ee("table",{value:t},[ee("thead",[ee("tr",n.map((e=>ee("th",[te(e)]))))]),ee("tbody",t.map((e=>ee("tr",n.map((t=>ee("td",[te(e[t])])))))))])}}function K(e){return"string"==typeof e?fetch(e).then(K):e instanceof Response||e instanceof Blob?e.arrayBuffer().then(K):e instanceof ArrayBuffer?new Uint8Array(e):e}function ee(e,t,n){2===arguments.length&&(n=t,t=void 0);const r=document.createElement(e);if(void 0!==t)for(const e in t)r[e]=t[e];if(void 0!==n)for(const e of n)r.appendChild(e);return r}function te(e){return document.createTextNode(e)}async function ne(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function re(e,t,{array:n=!1,typed:r=!1}={}){const o=await e.text();return("\t"===t?n?h:d:n?c:l)(o,r&&m)}class oe{constructor(e){Object.defineProperty(this,"name",{value:e,enumerable:!0})}async blob(){return(await ne(this)).blob()}async arrayBuffer(){return(await ne(this)).arrayBuffer()}async text(){return(await ne(this)).text()}async json(){return(await ne(this)).json()}async stream(){return(await ne(this)).body}async csv(e){return re(this,",",e)}async tsv(e){return re(this,"\t",e)}async image(){const e=await this.url();return new Promise(((t,n)=>{const r=new Image;new URL(e,document.baseURI).origin!==new URL(location).origin&&(r.crossOrigin="anonymous"),r.onload=()=>t(r),r.onerror=()=>n(new Error(`Unable to load file: ${this.name}`)),r.src=e}))}async arrow(){const[e,t]=await Promise.all([N(J.resolve()),ne(this)]);return e.Table.from(t)}async sqlite(){return SQLiteDatabaseClient.open(ne(this))}async zip(){const[e,t]=await Promise.all([N(H.resolve()),this.arrayBuffer()]);return new ZipArchive(await e.loadAsync(t))}}class FileAttachment extends oe{constructor(e,t){super(t),Object.defineProperty(this,"_url",{value:e})}async url(){return await this._url+""}}function ie(e){throw new Error(`File not found: ${e}`)}class ZipArchive{constructor(e){Object.defineProperty(this,"_",{value:e}),this.filenames=Object.keys(e.files).filter((t=>!e.files[t].dir))}file(e){const t=this._.file(e+="");if(!t||t.dir)throw new Error(`file not found: ${e}`);return new ZipArchiveEntry(t)}}class ZipArchiveEntry extends oe{constructor(e){super(e.name),Object.defineProperty(this,"_",{value:e}),Object.defineProperty(this,"_url",{writable:!0})}async url(){return this._url||(this._url=this.blob().then(URL.createObjectURL))}async blob(){return this._.async("blob")}async arrayBuffer(){return this._.async("arraybuffer")}async text(){return this._.async("text")}async json(){return JSON.parse(await this.text())}}var ae={math:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};var se=0;function ue(e){this.id=e,this.href=new URL(`#${e}`,location)+""}ue.prototype.toString=function(){return"url("+this.href+")"};var le={canvas:function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n},context2d:function(e,t,n){null==n&&(n=devicePixelRatio);var r=document.createElement("canvas");r.width=e*n,r.height=t*n,r.style.width=e+"px";var o=r.getContext("2d");return o.scale(n,n),o},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),o=r.appendChild(document.createElement("button"));async function i(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),o.textContent=n,o.disabled=!1}return o.textContent=n,r.download=t,r.onclick=async t=>{if(o.disabled=!0,r.href)return i();o.textContent="Saving…";try{const t=await("function"==typeof e?e():e);o.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){o.textContent=n}if(t.eventPhase)return i();o.disabled=!1},r},element:function(e,t){var n,r=e+="",o=r.indexOf(":");o>=0&&"xmlns"!==(r=e.slice(0,o))&&(e=e.slice(o+1));var i=ae.hasOwnProperty(r)?document.createElementNS(ae[r],e):document.createElement(e);if(t)for(var a in t)o=(r=a).indexOf(":"),n=t[a],o>=0&&"xmlns"!==(r=a.slice(0,o))&&(a=a.slice(o+1)),ae.hasOwnProperty(r)?i.setAttributeNS(ae[r],a,n):i.setAttribute(a,n);return i},input:function(e){var t=document.createElement("input");return null!=e&&(t.type=e),t},range:function(e,t,n){1===arguments.length&&(t=e,e=null);var r=document.createElement("input");return r.min=e=null==e?0:+e,r.max=t=null==t?1:+t,r.step=null==n?"any":n=+n,r.type="range",r},select:function(e){var t=document.createElement("select");return Array.prototype.forEach.call(e,(function(e){var n=document.createElement("option");n.value=n.textContent=e,t.appendChild(n)})),t},svg:function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox",[0,0,e,t]),n.setAttribute("width",e),n.setAttribute("height",t),n},text:function(e){return document.createTextNode(e)},uid:function(e){return new ue("O-"+(null==e?"":e+"-")+ ++se)}};var ce={buffer:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsArrayBuffer(e)}))},text:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsText(e)}))},url:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsDataURL(e)}))}};function fe(){return this}function de(e,t){let n=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:fe,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function he(e){let t,n,r=!1;const o=e((function(e){n?(n(e),n=null):r=!0;return t=e}));if(null!=o&&"function"!=typeof o)throw new Error("function"==typeof o.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:fe,throw:()=>({done:!0}),return:()=>(null!=o&&o(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise((e=>n=e))}}}}function me(e){switch(e.type){case"range":case"number":return e.valueAsNumber;case"date":return e.valueAsDate;case"checkbox":return e.checked;case"file":return e.multiple?e.files:e.files[0];case"select-multiple":return Array.from(e.selectedOptions,(e=>e.value));default:return e.value}}var pe={disposable:de,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return he((function(t){var n=function(e){switch(e.type){case"button":case"submit":case"checkbox":return"click";case"file":return"change";default:return"input"}}(e),r=me(e);function o(){t(me(e))}return e.addEventListener(n,o),void 0!==r&&t(r),function(){e.removeEventListener(n,o)}}))},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:he,queue:function(e){let t;const n=[],r=e((function(e){n.push(e),t&&(t(n.shift()),t=null);return e}));if(null!=r&&"function"!=typeof r)throw new Error("function"==typeof r.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:fe,throw:()=>({done:!0}),return:()=>(null!=r&&r(),{done:!0}),next:function(){return{done:!1,value:n.length?Promise.resolve(n.shift()):new Promise((e=>t=e))}}}},range:function*(e,t,n){e=+e,t=+t,n=(o=arguments.length)<2?(t=e,e=0,1):o<3?1:+n;for(var r=-1,o=0|Math.max(0,Math.ceil((t-e)/n));++r<o;)yield e+r*n},valueAt:function(e,t){if(!(!isFinite(t=+t)||t<0||t!=t|0))for(var n,r=-1;!(n=e.next()).done;)if(++r===t)return n.value},worker:function(e){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"})),n=new Worker(t);return de(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}};function ve(e,t){return function(n){var r,o,i,a,s,u,l,c,f=n[0],d=[],h=null,m=-1;for(s=1,u=arguments.length;s<u;++s){if((r=arguments[s])instanceof Node)d[++m]=r,f+="\x3c!--o:"+m+"--\x3e";else if(Array.isArray(r)){for(l=0,c=r.length;l<c;++l)(o=r[l])instanceof Node?(null===h&&(d[++m]=h=document.createDocumentFragment(),f+="\x3c!--o:"+m+"--\x3e"),h.appendChild(o)):(h=null,f+=o);h=null}else f+=r;f+=n[s]}if(h=e(f),++m>0){for(i=new Array(m),a=document.createTreeWalker(h,NodeFilter.SHOW_COMMENT,null,!1);a.nextNode();)o=a.currentNode,/^o:/.test(o.nodeValue)&&(i[+o.nodeValue.slice(2)]=o);for(s=0;s<m;++s)(o=i[s])&&o.parentNode.replaceChild(d[s],o)}return 1===h.childNodes.length?h.removeChild(h.firstChild):11===h.nodeType?((o=t()).appendChild(h),o):h}}var we=ve((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));function ye(e){let t;Object.defineProperties(this,{generator:{value:he((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*ge(){for(;;)yield Date.now()}var be=new Map;function je(e,t){var n;return(n=be.get(e=+e))?n.then((()=>t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise((function(n){be.delete(t);var r=t-e;if(!(r>0))throw new Error("invalid time");if(r>2147483647)throw new Error("too long to wait");setTimeout(n,r)}));return be.set(t,n),n}(n,e).then((()=>t))}var xe={delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return je(Math.ceil((Date.now()+1)/e)*e,t)},when:je};function Ee(e,t){if(/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new Error("illegal name");return"https://unpkg.com/"+e}function Pe(e){return null==e?N:L(e)}var Ae=ve((function(e){var t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.innerHTML=e.trim(),t}),(function(){return document.createElementNS("http://www.w3.org/2000/svg","g")})),Ce=String.raw;function Oe(){return he((function(e){var t=e(document.body.clientWidth);function n(){var n=document.body.clientWidth;n!==t&&e(t=n)}return window.addEventListener("resize",n),function(){window.removeEventListener("resize",n)}}))}var Ne=Object.assign((function(e){const t=Pe(e);var n;Object.defineProperties(this,(n={FileAttachment:()=>ie,Arrow:()=>t(J.resolve()),Inputs:()=>t(M.resolve()),Mutable:()=>ye,Plot:()=>t(S.resolve()),SQLite:()=>G(t),SQLiteDatabaseClient:()=>SQLiteDatabaseClient,_:()=>t(B.resolve()),aq:()=>t.alias({"apache-arrow":J.resolve()})(X.resolve()),d3:()=>t(q.resolve()),dot:()=>t(_.resolve()),htl:()=>t(z.resolve()),html:()=>we,md:()=>function(e){return e(W.resolve()).then((function(t){return ve((function(n){var r=document.createElement("div");r.innerHTML=t(n,{langPrefix:""}).trim();var o=r.querySelectorAll("pre code[class]");return o.length>0&&e(D.resolve()).then((function(t){o.forEach((function(n){function r(){t.highlightBlock(n),n.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(n.className)?r():e(D.resolve("async-languages/index.js")).then((r=>{if(r.has(n.className))return e(D.resolve("async-languages/"+r.get(n.className))).then((e=>{t.registerLanguage(n.className,e)}))})).then(r,r)}))})),r}),(function(){return document.createElement("div")}))}))}(t),now:ge,require:()=>t,resolve:()=>Ee,svg:()=>Ae,tex:()=>function(e){return Promise.all([e(F.resolve()),(t=F.resolve("dist/katex.min.css"),new Promise((function(e,n){var r=document.createElement("link");r.rel="stylesheet",r.href=t,r.onerror=n,r.onload=e,document.head.appendChild(r)})))]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(Ce.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}));var t}(t),topojson:()=>t(Y.resolve()),vl:()=>async function(e){const[t,n,r]=await Promise.all([Z,Q,V].map((t=>e(t.resolve()))));return r.register(t,n)}(t),width:Oe,DOM:le,Files:ce,Generators:pe,Promises:xe},Object.fromEntries(Object.entries(n).map(Le))))}),{resolve:N.resolve});function Le([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}e.FileAttachments=function(e){return Object.assign((t=>{const n=e(t+="");if(null==n)throw new Error(`File not found: ${t}`);return new FileAttachment(n,t)}),{prototype:FileAttachment.prototype})},e.Library=Ne,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@observablehq/stdlib",
"version": "3.10.0",
"version": "3.11.0",
"license": "ISC",

@@ -30,2 +30,3 @@ "main": "dist/stdlib.js",

"dependencies": {
"d3-dsv": "^2.0.0",
"d3-require": "^1.2.4"

@@ -32,0 +33,0 @@ },

import dependency from "./dependency.js";
export const d3 = dependency("d3", "7.0.1", "dist/d3.min.js");
export const d3Dsv = dependency("d3-dsv", "3.0.1", "dist/d3-dsv.min.js");
export const inputs = dependency("@observablehq/inputs", "0.9.0", "dist/inputs.min.js");
export const inputs = dependency("@observablehq/inputs", "0.9.1", "dist/inputs.min.js");
export const plot = dependency("@observablehq/plot", "0.2.0", "dist/plot.umd.min.js");

@@ -18,2 +17,3 @@ export const graphviz = dependency("@observablehq/graphviz", "0.2.1", "dist/graphviz.min.js");

export const arrow = dependency("apache-arrow", "4.0.1", "Arrow.es2015.min.js");
export const arquero = dependency("arquero", "4.8.4", "dist/arquero.min.js");
export const topojson = dependency("topojson-client", "3.1.0", "dist/topojson-client.min.js");

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

import {autoType, csvParse, csvParseRows, tsvParse, tsvParseRows} from "d3-dsv";
import {require as requireDefault} from "d3-require";
import {arrow, d3Dsv, jszip} from "./dependencies.js";
import {arrow, jszip} from "./dependencies.js";
import {SQLiteDatabaseClient} from "./sqlite.js";

@@ -12,6 +13,6 @@

async function dsv(file, delimiter, {array = false, typed = false} = {}) {
const [text, d3] = await Promise.all([file.text(), requireDefault(d3Dsv.resolve())]);
const text = await file.text();
return (delimiter === "\t"
? (array ? d3.tsvParseRows : d3.tsvParse)
: (array ? d3.csvParseRows : d3.csvParse))(text, typed && d3.autoType);
? (array ? tsvParseRows : tsvParse)
: (array ? csvParseRows : csvParse))(text, typed && autoType);
}

@@ -18,0 +19,0 @@

@@ -18,3 +18,3 @@ import {require as requireDefault} from "d3-require";

import width from "./width.js";
import {arrow, d3, graphviz, htl, inputs, lodash, plot, topojson} from "./dependencies.js";
import {arquero, arrow, d3, graphviz, htl, inputs, lodash, plot, topojson} from "./dependencies.js";

@@ -32,2 +32,3 @@ export default Object.assign(function Library(resolver) {

_: () => require(lodash.resolve()),
aq: () => require.alias({"apache-arrow": arrow.resolve()})(arquero.resolve()),
d3: () => require(d3.resolve()),

@@ -34,0 +35,0 @@ dot: () => require(graphviz.resolve()),

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