Skip to content

Instantly share code, notes, and snippets.

@max-mapper
Last active December 19, 2015 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save max-mapper/5952100 to your computer and use it in GitHub Desktop.
Save max-mapper/5952100 to your computer and use it in GitHub Desktop.
made with requirebin.com
var term = require('hypernal')()
var tablify = require('tablify').tablify
var jsonp = require('jsonp')
term.appendTo(document.body)
// style fake terminal
var termEl = term.term.element
termEl.style['font'] = '13px Monaco'
termEl.style.height = '100%'
termEl.style.padding = '5px'
termEl.style['white-space'] = 'pre'
term.write('BOSTON PUBLIC LIBRARIES\n')
// fetch libraries in Boston
jsonp('http://civicapi.com/v1/bos_public_libraries/all', function(err, data) {
var rows = []
data.features.map(function(row){
if (row.properties && row.properties.properties) rows.push(row.properties.properties)
})
term.write(tablify(rows))
})
require=function(t,e,s){function r(s,n){if(!e[s]){if(!t[s]){var o="function"==typeof require&&require;if(!n&&o)return o(s,!0);if(i)return i(s,!0);throw Error("Cannot find module '"+s+"'")}var a=e[s]={exports:{}};t[s][0].call(a.exports,function(e){var i=t[s][1][e];return r(i?i:e)},a,a.exports)}return e[s].exports}for(var i="function"==typeof require&&require,n=0;s.length>n;n++)r(s[n]);return r}({tablify:[function(t,e){e.exports=t("edlOOd")},{}],edlOOd:[function(t,e){(function(){var t,s,r;t=e.exports=function(e,r){return s(e)?t.tablifyArrays(e,r):t.tablifyDicts(e,r)},t.tablify=t,t.tablifyArrays=function(t,e){var s,i,n,o;for(s=new r(e),n=0,o=t.length;o>n;n++)i=t[n],s.push(i);return s.stringify()},t.tablifyDicts=function(t,e){var s,i,n,o,a,h,c,u,l,p,f,d,b;if(e=e||{},null==e.has_header&&(e.has_header=!0),null==e.show_index&&(e.show_index=!0),!e.keys){for(a={},c=0,p=t.length;p>c;c++){i=t[c];for(o in i)a[o]=!0}e.keys=function(){var t;t=[];for(o in a)t.push(o);return t}(),e.keys.sort()}for(s=new r(e),e.has_header&&(h=function(){var t,s,r,i;for(r=e.keys,i=[],t=0,s=r.length;s>t;t++)o=r[t],i.push(o);return i}(),s.push(h)),n=u=0,f=t.length;f>u;n=++u){for(i=t[n],h=[],b=e.keys,l=0,d=b.length;d>l;l++)o=b[l],h.push(null!=i[o]?i[o]:null);s.push(h)}return s.stringify()},r=function(){function t(t){this.opts=t||{},this.opts.spacer=null!=this.opts.spacer?this.opts.spacer:" | ",this.opts.row_start=null!=this.opts.row_start?this.opts.spaces:"| ",this.opts.row_end=null!=this.opts.row_end?this.opts.row_end:" |",this.opts.row_sep_char=this.opts.row_sep_char?this.opts.row_sep_char:"-",this.opts.has_header=null!=this.opts.has_header?this.opts.has_header:!1,this.opts.show_index=null!=this.opts.show_index?this.opts.show_index:!1,this.rows=[],this.col_widths=[],this.opts.border===!1&&(t.spacer=" ",this.opts.row_start=this.opts.row_end=this.opts.row_sep_char="")}return t.prototype.push=function(t){var e,s,r,i,n,o,a;for(r=function(){var s,r,i;for(i=[],s=0,r=t.length;r>s;s++)e=t[s],i.push(e);return i}(),this.opts.show_index&&(i=this.rows.length,this.opts.has_header&&i--,0>i?r.splice(0,0,"#"):r.splice(0,0,i)),this.rows.push(r),a=[],s=n=0,o=r.length;o>n;s=++n)e=r[s],null==this.col_widths[s]||this.col_widths[s]<this.len(e)?a.push(this.col_widths[s]=this.len(e)):a.push(void 0);return a},t.prototype.stringify=function(){var t,e,s,r,i,n,o,a,h,c,u,l,p,f,d,b;for(i=[],n=this.opts.row_start.length+this.opts.row_end.length,f=this.col_widths,a=0,u=f.length;u>a;a++)o=f[a],n+=o;for(n+=this.opts.spacer.length*(this.col_widths.length-1),null!=this.opts.row_sep_char&&i.push(this.chars(this.opts.row_sep_char,n)),d=this.rows,e=h=0,l=d.length;l>h;e=++h){for(r=d[e],s=this.opts.row_start,b=this.col_widths,t=c=0,p=b.length;p>c;t=++c)o=b[t],s+=this.ljust(null!=r[t]?r[t]:"",o),this.col_widths.length-1>t&&(s+=this.opts.spacer);s+=this.opts.row_end,i.push(s),this.opts.row_sep_char&&0===e&&this.opts.has_header&&i.push(this.chars(this.opts.row_sep_char,n))}return null!=this.opts.row_sep_char&&i.push(this.chars(this.opts.row_sep_char,n)),i.join("\n")},t.prototype.toStr=function(t){if(null===t)return"null";if(t===void 0)return"";if("object"!=typeof t)return""+t;try{return JSON.stringify(t)}catch(e){return"["+e.message+"]"}},t.prototype.len=function(t){return this.toStr(t).length},t.prototype.chars=function(t,e){var s;return function(){var r,i;for(i=[],s=r=0;e>=0?e>r:r>e;s=e>=0?++r:--r)i.push(t);return i}().join("")},t.prototype.ljust=function(t,e){return""+this.toStr(t)+this.chars(" ",e-this.len(t))},t.prototype.rjust=function(t,e){return""+this.chars(" ",e-this.len(t))+this.toStr(t)},t}(),s=function(t){var e,s,r;for(s=0,r=t.length;r>s;s++)if(e=t[s],!Array.isArray(e))return!1;return!0}}).call(this)},{}]},{},[]),require=function(t,e,s){function r(s,n){if(!e[s]){if(!t[s]){var o="function"==typeof require&&require;if(!n&&o)return o(s,!0);if(i)return i(s,!0);throw Error("Cannot find module '"+s+"'")}var a=e[s]={exports:{}};t[s][0].call(a.exports,function(e){var i=t[s][1][e];return r(i?i:e)},a,a.exports)}return e[s].exports}for(var i="function"==typeof require&&require,n=0;s.length>n;n++)r(s[n]);return r}({hypernal:[function(t,e){e.exports=t("y4/znu")},{}],"y4/znu":[function(t,e){"use strict";function s(t){t&&(t.scrollTop=t.scrollHeight)}var r=t("./term"),i=t("through");e.exports=function(t){var e=new r(t);e.open();var n=i(e.write.bind(e));return n.appendTo=function(t){"string"==typeof t&&(t=document.querySelector(t)),t.appendChild(e.element),t.setAttribute("style","overflow-y : auto;"),n.container=t,e.element.style.position="relative"},n.writeln=function(t){e.writeln(t),n.tail&&s(n.container)},n.write=function(t){e.write(t),n.tail&&s(n.container)},n.reset=e.reset.bind(e),n.element=e.element,n.term=e,n}},{"./term":1,through:2}],1:[function(t,e){"use strict";function s(t){if(t=t||{},!(this instanceof s))return new s(t);this.cols=t.cols||500,this.rows=t.rows||100,this.ybase=0,this.ydisp=0,this.x=0,this.y=0,this.cursorState=0,this.cursorHidden=!1,this.convertEol=!1,this.state=r.normal,this.queue="",this.scrollTop=0,this.scrollBottom=this.rows-1,this.applicationKeypad=!1,this.originMode=!1,this.insertMode=!1,this.wraparoundMode=!1,this.normal=null,this.charset=null,this.gcharset=null,this.glevel=0,this.charsets=[null],this.element,this.children,this.refreshStart,this.refreshEnd,this.savedX,this.savedY,this.savedCols,this.readable=!0,this.writable=!0,this.defAttr=131840,this.curAttr=this.defAttr,this.params=[],this.currentParam=0,this.prefix="",this.postfix="",this.lines=[];for(var e=this.rows;e--;)this.lines.push(this.blankLine());this.tabs,this.setupStops()}var r=t("./lib/states");e.exports=s,t("./lib/colors")(s),t("./lib/options")(s),t("./lib/open")(s),t("./lib/destroy")(s),t("./lib/refresh")(s),t("./lib/write")(s),t("./lib/setgLevel"),t("./lib/setgCharset"),t("./lib/debug")(s),t("./lib/stops")(s),t("./lib/erase")(s),t("./lib/blankLine")(s),t("./lib/range")(s),t("./lib/util")(s),t("./lib/esc/index.js")(s),t("./lib/esc/reset.js")(s),t("./lib/esc/tabSet.js")(s),t("./lib/csi/charAttributes")(s),t("./lib/csi/insert-delete")(s),t("./lib/csi/position")(s),t("./lib/csi/cursor")(s),t("./lib/csi/repeatPrecedingCharacter")(s),t("./lib/csi/tabClear")(s),t("./lib/csi/softReset")(s),t("./lib/charsets.js")(s)},{"./lib/esc/index.js":3,"./lib/esc/reset.js":4,"./lib/esc/tabSet.js":5,"./lib/charsets.js":6,"./lib/colors":7,"./lib/states":8,"./lib/options":9,"./lib/open":10,"./lib/destroy":11,"./lib/refresh":12,"./lib/write":13,"./lib/setgLevel":14,"./lib/setgCharset":15,"./lib/debug":16,"./lib/stops":17,"./lib/erase":18,"./lib/blankLine":19,"./lib/range":20,"./lib/util":21,"./lib/csi/charAttributes":22,"./lib/csi/insert-delete":23,"./lib/csi/position":24,"./lib/csi/cursor":25,"./lib/csi/repeatPrecedingCharacter":26,"./lib/csi/softReset":27,"./lib/csi/tabClear":28}],4:[function(t,e){"use strict";e.exports=function(t){t.prototype.reset=function(){t.call(this,this.cols,this.rows),this.refresh(0,this.rows-1)}}},{}],6:[function(t,e){"use strict";e.exports=function(t){t.charsets={},t.charsets.SCLD={"`":"◆",a:"▒",b:" ",c:"\f",d:"\r",e:"\n",f:"°",g:"±",h:"␤",i:" ",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},t.charsets.UK=null,t.charsets.US=null,t.charsets.Dutch=null,t.charsets.Finnish=null,t.charsets.French=null,t.charsets.FrenchCanadian=null,t.charsets.German=null,t.charsets.Italian=null,t.charsets.NorwegianDanish=null,t.charsets.Spanish=null,t.charsets.Swedish=null,t.charsets.Swiss=null,t.charsets.ISOLatin=null}},{}],7:[function(t,e){"use strict";e.exports=function(t){t.colors=["#2e3436","#cc0000","#4e9a06","#c4a000","#3465a4","#75507b","#06989a","#d3d7cf","#555753","#ef2929","#8ae234","#fce94f","#729fcf","#ad7fa8","#34e2e2","#eeeeec"],t.colors=function(){function e(t,e,r){i.push("#"+s(t)+s(e)+s(r))}function s(t){return t=t.toString(16),2>t.length?"0"+t:t}var r,i=t.colors,n=[0,95,135,175,215,255];for(r=0;216>r;r++)e(n[0|r/36%6],n[0|r/6%6],n[r%6]);for(r=0;24>r;r++)n=8+10*r,e(n,n,n);return i}(),t.defaultColors={bg:"#000000",fg:"#f0f0f0"},t.colors[256]=t.defaultColors.bg,t.colors[257]=t.defaultColors.fg}},{}],9:[function(t,e){"use strict";e.exports=function(t){t.termName="xterm",t.geometry=[80,24],t.cursorBlink=!0,t.visualBell=!1,t.popOnBell=!1,t.scrollback=1e3,t.screenKeys=!1,t.programFeatures=!1,t.debug=!1}},{}],8:[function(t,e){"use strict";e.exports={normal:0,escaped:1,csi:2,osc:3,charset:4,dcs:5,ignore:6}},{}],10:[function(t,e){"use strict";function s(){var t=document.createElement("span");t.innerHTML="hello world",document.body.appendChild(t);var e=t.scrollWidth;t.style.fontWeight="bold";var s=t.scrollWidth;return document.body.removeChild(t),e!==s}e.exports=function(t){t.prototype.open=function(){var e,r=0;for(this.element=document.createElement("div"),this.element.className="terminal",this.children=[];this.rows>r;r++)e=document.createElement("div"),this.element.appendChild(e),this.children.push(e);this.refresh(0,this.rows-1),null===t.brokenBold&&(t.brokenBold=s()),this.element.style.backgroundColor=t.defaultColors.bg,this.element.style.color=t.defaultColors.fg}}},{}],11:[function(t,e){"use strict";e.exports=function(t){t.prototype.destroy=function(){this.readable=!1,this.writable=!1,this._events={},this.handler=function(){},this.write=function(){}}}},{}],12:[function(t,e){"use strict";e.exports=function(t){t.prototype.refresh=function(e,s){var r,i,n,o,a,h,c,u,l,p,f,d,b,y;for(c=this.cols,i=e;s>=i;i++){if(b=i+this.ydisp,o=this.lines[b],!o)return this.reset();for(a="",r=i===this.y&&this.cursorState&&this.ydisp===this.ybase&&!this.cursorHidden?this.x:-1,l=this.defAttr,n=0;c>n;n++){switch(u=o[n][0],h=o[n][1],n===r&&(u=-1),u!==l&&(l!==this.defAttr&&(a+="</span>"),u!==this.defAttr&&(-1===u?a+='<span class="reverse-video">':(a+='<span style="',f=511&u,p=511&u>>9,d=u>>18,1&d&&(t.brokenBold||(a+="font-weight:bold;"),8>p&&(p+=8)),2&d&&(a+="text-decoration:underline;"),256!==f&&(a+="background-color:"+t.colors[f]+";"),257!==p&&(a+="color:"+t.colors[p]+";"),a+='">'))),h){case"&":a+="&";break;case"<":a+="<";break;case">":a+=">";break;default:a+=" ">=h?" ":h}l=u}l!==this.defAttr&&(a+="</span>"),this.children[i].innerHTML=a}y&&y.appendChild(this.element)}}},{}],14:[function(t,e){"use strict";e.exports=function(t){t.prototype.setgLevel=function(t){this.glevel=t,this.charset=this.charsets[t]}}},{}],15:[function(t,e){"use strict";e.exports=function(t){t.prototype.setgCharset=function(t,e){this.charsets[t]=e,this.glevel===t&&(this.charset=e)}}},{}],16:[function(t,e){"use strict";e.exports=function(t){t.prototype.log=function(){if(t.debug&&window.console&&window.console.log){var e=Array.prototype.slice.call(arguments);window.console.log.apply(window.console,e)}},t.prototype.error=function(){if(t.debug&&window.console&&window.console.error){var e=Array.prototype.slice.call(arguments);window.console.error.apply(window.console,e)}}}},{}],17:[function(t,e){"use strict";e.exports=function(t){t.prototype.setupStops=function(t){for(null!=t?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);this.cols>t;t+=8)this.tabs[t]=!0},t.prototype.prevStop=function(t){for(null==t&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this.cols?this.cols-1:0>t?0:t},t.prototype.nextStop=function(t){for(null==t&&(t=this.x);!this.tabs[++t]&&this.cols>t;);return t>=this.cols?this.cols-1:0>t?0:t}}},{}],18:[function(t,e){"use strict";e.exports=function(t){t.prototype.eraseRight=function(t,e){for(var s=this.lines[this.ybase+e],r=[this.curAttr," "];this.cols>t;t++)s[t]=r;this.updateRange(e)},t.prototype.eraseLeft=function(t,e){var s=this.lines[this.ybase+e],r=[this.curAttr," "];for(t++;t--;)s[t]=r;this.updateRange(e)},t.prototype.eraseLine=function(t){this.eraseRight(0,t)},t.prototype.eraseInDisplay=function(t){var e;switch(t[0]){case 0:for(this.eraseRight(this.x,this.y),e=this.y+1;this.rows>e;e++)this.eraseLine(e);break;case 1:for(this.eraseLeft(this.x,this.y),e=this.y;e--;)this.eraseLine(e);break;case 2:for(e=this.rows;e--;)this.eraseLine(e);break;case 3:}},t.prototype.eraseInLine=function(t){switch(t[0]){case 0:this.eraseRight(this.x,this.y);break;case 1:this.eraseLeft(this.x,this.y);break;case 2:this.eraseLine(this.y)}}}},{}],19:[function(t,e){"use strict";e.exports=function(t){t.prototype.blankLine=function(t){for(var e=t?this.curAttr:this.defAttr,s=[e," "],r=[],i=0;this.cols>i;i++)r[i]=s;return r}}},{}],20:[function(t,e){"use strict";function s(){for(;this.y>=this.rows;){this.lines.push(this.blankLine());var t=document.createElement("div");this.element.appendChild(t),this.children.push(t),this.rows++}}e.exports=function(t){t.prototype.updateRange=function(t){this.refreshStart>t&&(this.refreshStart=t),t>this.refreshEnd&&(this.refreshEnd=t),s.bind(this)()},t.prototype.maxRange=function(){this.refreshStart=0,this.refreshEnd=this.rows-1}}},{}],21:[function(t,e){"use strict";e.exports=function(t){t.prototype.ch=function(t){return t?[this.curAttr," "]:[this.defAttr," "]},t.prototype.is=function(e){var s=this.termName||t.termName;return 0===(s+"").indexOf(e)}}},{}],22:[function(t,e){"use strict";e.exports=function(t){t.prototype.charAttributes=function(t){for(var e,s,r,i=t.length,n=0;i>n;n++)if(r=t[n],r>=30&&37>=r)this.curAttr=-261633&this.curAttr|r-30<<9;else if(r>=40&&47>=r)this.curAttr=-512&this.curAttr|r-40;else if(r>=90&&97>=r)r+=8,this.curAttr=-261633&this.curAttr|r-90<<9;else if(r>=100&&107>=r)r+=8,this.curAttr=-512&this.curAttr|r-100;else if(0===r)this.curAttr=this.defAttr;else if(1===r)this.curAttr=this.curAttr|1<<18;else if(4===r)this.curAttr=this.curAttr|2<<18;else if(7===r||27===r){if(7===r){if(4&this.curAttr>>18)continue;this.curAttr=this.curAttr|4<<18}else if(27===r){if(4&~(this.curAttr>>18))continue;this.curAttr=-1048577&this.curAttr}e=511&this.curAttr,s=511&this.curAttr>>9,this.curAttr=-262144&this.curAttr|(e<<9|s)}else if(22===r)this.curAttr=-262145&this.curAttr;else if(24===r)this.curAttr=-524289&this.curAttr;else if(39===r)this.curAttr=-261633&this.curAttr,this.curAttr=this.curAttr|(511&this.defAttr>>9)<<9;else if(49===r)this.curAttr=-512&this.curAttr,this.curAttr=this.curAttr|511&this.defAttr;else if(38===r){if(5!==t[n+1])continue;n+=2,r=255&t[n],this.curAttr=-261633&this.curAttr|r<<9}else if(48===r){if(5!==t[n+1])continue;n+=2,r=255&t[n],this.curAttr=-512&this.curAttr|r}}}},{}],23:[function(t,e){"use strict";e.exports=function(t){t.prototype.insertChars=function(t){var e,s,r,i;for(e=t[0],1>e&&(e=1),s=this.y+this.ybase,r=this.x,i=[this.curAttr," "];e--&&this.cols>r;)this.lines[s].splice(r++,0,i),this.lines[s].pop()},t.prototype.insertLines=function(t){var e,s,r;for(e=t[0],1>e&&(e=1),s=this.y+this.ybase,r=this.rows-1-this.scrollBottom,r=this.rows-1+this.ybase-r+1;e--;)this.lines.splice(s,0,this.blankLine(!0)),this.lines.splice(r,1);this.updateRange(this.y),this.updateRange(this.scrollBottom)},t.prototype.deleteLines=function(t){var e,s,r;for(e=t[0],1>e&&(e=1),s=this.y+this.ybase,r=this.rows-1-this.scrollBottom,r=this.rows-1+this.ybase-r;e--;)this.lines.splice(r+1,0,this.blankLine(!0)),this.lines.splice(s,1);this.updateRange(this.y),this.updateRange(this.scrollBottom)},t.prototype.deleteChars=function(t){var e,s,r;for(e=t[0],1>e&&(e=1),s=this.y+this.ybase,r=[this.curAttr," "];e--;)this.lines[s].splice(this.x,1),this.lines[s].push(r)},t.prototype.eraseChars=function(t){var e,s,r,i;for(e=t[0],1>e&&(e=1),s=this.y+this.ybase,r=this.x,i=[this.curAttr," "];e--&&this.cols>r;)this.lines[s][r++]=i}}},{}],24:[function(t,e){"use strict";e.exports=function(t){t.prototype.charPosAbsolute=function(t){var e=t[0];1>e&&(e=1),this.x=e-1,this.x>=this.cols&&(this.x=this.cols-1)},t.prototype.HPositionRelative=function(t){var e=t[0];1>e&&(e=1),this.x+=e,this.x>=this.cols&&(this.x=this.cols-1)},t.prototype.linePosAbsolute=function(t){var e=t[0];1>e&&(e=1),this.y=e-1,this.y>=this.rows&&(this.y=this.rows-1)},t.prototype.VPositionRelative=function(t){var e=t[0];1>e&&(e=1),this.y+=e,this.y>=this.rows&&(this.y=this.rows-1)},t.prototype.HVPosition=function(t){1>t[0]&&(t[0]=1),1>t[1]&&(t[1]=1),this.y=t[0]-1,this.y>=this.rows&&(this.y=this.rows-1),this.x=t[1]-1,this.x>=this.cols&&(this.x=this.cols-1)}}},{}],25:[function(t,e){"use strict";e.exports=function(t){t.prototype.saveCursor=function(){this.savedX=this.x,this.savedY=this.y},t.prototype.restoreCursor=function(){this.x=this.savedX||0,this.y=this.savedY||0},t.prototype.cursorUp=function(t){var e=t[0];1>e&&(e=1),this.y-=e,0>this.y&&(this.y=0)},t.prototype.cursorDown=function(t){var e=t[0];1>e&&(e=1),this.y+=e,this.y>=this.rows&&(this.y=this.rows-1)},t.prototype.cursorForward=function(t){var e=t[0];1>e&&(e=1),this.x+=e,this.x>=this.cols&&(this.x=this.cols-1)},t.prototype.cursorBackward=function(t){var e=t[0];1>e&&(e=1),this.x-=e,0>this.x&&(this.x=0)},t.prototype.cursorPos=function(t){var e,s;e=t[0]-1,s=t.length>=2?t[1]-1:0,0>e?e=0:e>=this.rows&&(e=this.rows-1),0>s?s=0:s>=this.cols&&(s=this.cols-1),this.x=s,this.y=e},t.prototype.cursorNextLine=function(t){var e=t[0];1>e&&(e=1),this.y+=e,this.y>=this.rows&&(this.y=this.rows-1),this.x=0},t.prototype.cursorPrecedingLine=function(t){var e=t[0];1>e&&(e=1),this.y-=e,0>this.y&&(this.y=0),this.x=0},t.prototype.cursorCharAbsolute=function(t){var e=t[0];1>e&&(e=1),this.x=e-1},t.prototype.cursorForwardTab=function(t){for(var e=t[0]||1;e--;)this.x=this.nextStop()},t.prototype.cursorBackwardTab=function(t){for(var e=t[0]||1;e--;)this.x=this.prevStop()}}},{}],26:[function(t,e){"use strict";e.exports=function(t){t.prototype.repeatPrecedingCharacter=function(t){for(var e=t[0]||1,s=this.lines[this.ybase+this.y],r=s[this.x-1]||[this.defAttr," "];e--;)s[this.x++]=r}}},{}],27:[function(t,e){"use strict";e.exports=function(t){t.prototype.softReset=function(){this.cursorHidden=!1,this.insertMode=!1,this.originMode=!1,this.wraparoundMode=!1,this.applicationKeypad=!1,this.scrollTop=0,this.scrollBottom=this.rows-1,this.curAttr=this.defAttr,this.x=this.y=0,this.charset=null,this.glevel=0,this.charsets=[null]}}},{}],28:[function(t,e){"use strict";e.exports=function(t){t.prototype.tabClear=function(t){var e=t[0];0>=e?delete this.tabs[this.x]:3===e&&(this.tabs={})}}},{}],29:[function(t,e){var s=e.exports={};s.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var s=[];return window.addEventListener("message",function(t){if(t.source===window&&"process-tick"===t.data&&(t.stopPropagation(),s.length>0)){var e=s.shift();e()}},!0),function(t){s.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),s.title="browser",s.browser=!0,s.env={},s.argv=[],s.binding=function(){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(){throw Error("process.chdir is not supported")}},{}],2:[function(t,e,s){(function(r){function i(t,e){function s(){for(;h.length&&!c.paused;){var t=h.shift();if(null===t)return c.emit("end");c.emit("data",t)}}function i(){c.writable=!1,e.call(c),c.readable||c.destroy()}t=t||function(t){this.queue(t)},e=e||function(){this.queue(null)};var o=!1,a=!1,h=[],c=new n;return c.readable=c.writable=!0,c.paused=!1,c.write=function(e){return t.call(this,e),!c.paused},c.queue=c.push=function(t){return h.push(t),s(),c},c.on("end",function(){c.readable=!1,c.writable||r.nextTick(function(){c.destroy()})}),c.end=function(t){return o?void 0:(o=!0,arguments.length&&c.write(t),i(),c)},c.destroy=function(){return a?void 0:(a=!0,o=!0,h.length=0,c.writable=c.readable=!1,c.emit("close"),c)},c.pause=function(){return c.paused?void 0:(c.paused=!0,c.emit("pause"),c)},c.resume=function(){return c.paused&&(c.paused=!1),s(),c.paused||c.emit("drain"),c},c}var n=t("stream");s=e.exports=i,i.through=i})(t("__browserify_process"))},{stream:30,__browserify_process:29}],30:[function(t,e){function s(){r.EventEmitter.call(this)}var r=t("events"),i=t("util");i.inherits(s,r.EventEmitter),e.exports=s,s.Stream=s,s.prototype.pipe=function(t,e){function s(e){t.writable&&!1===t.write(e)&&h.pause&&h.pause()}function r(){h.readable&&h.resume&&h.resume()}function i(){c||(c=!0,t._pipeCount--,a(),t._pipeCount>0||t.end())}function n(){c||(c=!0,t._pipeCount--,a(),t._pipeCount>0||t.destroy())}function o(t){if(a(),0===this.listeners("error").length)throw t}function a(){h.removeListener("data",s),t.removeListener("drain",r),h.removeListener("end",i),h.removeListener("close",n),h.removeListener("error",o),t.removeListener("error",o),h.removeListener("end",a),h.removeListener("close",a),t.removeListener("end",a),t.removeListener("close",a)}var h=this;h.on("data",s),t.on("drain",r),t._isStdio||e&&e.end===!1||(t._pipeCount=t._pipeCount||0,t._pipeCount++,h.on("end",i),h.on("close",n));var c=!1;return h.on("error",o),t.on("error",o),h.on("end",a),h.on("close",a),t.on("end",a),t.on("close",a),t.emit("pipe",h),t}},{events:31,util:32}],13:[function(t,e){"use strict";function s(t){return t.replace(/([^\r])\n/g,"$1\r\n")}function r(t){return/(^|\n) /.test(t)?t.split("\n").map(function(t){for(var e=0;" "===t.charAt(0);)t=t.slice(1),e++;for(;e--;)t="&nbsp;"+t;return t}).join("\r\n"):t}var i=t("./states");e.exports=function(t){t.prototype.write=function(e){e=s(e),e=r(e);var n,o,a=e.length,h=0;for(this.refreshStart=this.y,this.refreshEnd=this.y,this.ybase!==this.ydisp&&(this.ydisp=this.ybase,this.maxRange());a>h;h++)switch(o=e[h],this.state){case i.normal:switch(o){case"":this.bell();break;case"\n":case" ":case"\f":this.convertEol&&(this.x=0),this.y++;break;case"\r":this.x=0;break;case"\b":this.x>0&&this.x--;break;case" ":this.x=this.nextStop();break;case"":this.setgLevel(1);break;case"":this.setgLevel(0);break;case"":this.state=i.escaped;break;default:o>=" "&&(this.charset&&this.charset[o]&&(o=this.charset[o]),this.x>=this.cols&&(this.x=0,this.y++),this.lines[this.y+this.ybase]&&(this.lines[this.y+this.ybase][this.x]=[this.curAttr,o]),this.x++,this.updateRange(this.y))}break;case i.escaped:switch(o){case"[":this.params=[],this.currentParam=0,this.state=i.csi;break;case"]":this.params=[],this.currentParam=0,this.state=i.osc;break;case"P":this.params=[],this.currentParam=0,this.state=i.dcs;break;case"_":this.stateType="apc",this.state=i.ignore;break;case"^":this.stateType="pm",this.state=i.ignore;break;case"c":this.reset();break;case"E":this.x=0;break;case"D":this.index();break;case"M":this.reverseIndex();break;case"%":this.setgLevel(0),this.setgCharset(0,t.charsets.US),this.state=i.normal,h++;break;case"(":case")":case"*":case"+":case"-":case".":switch(o){case"(":this.gcharset=0;break;case")":this.gcharset=1;break;case"*":this.gcharset=2;break;case"+":this.gcharset=3;break;case"-":this.gcharset=1;break;case".":this.gcharset=2}this.state=i.charset;break;case"/":this.gcharset=3,this.state=i.charset,h--;break;case"N":break;case"O":break;case"n":this.setgLevel(2);break;case"o":this.setgLevel(3);break;case"|":this.setgLevel(3);break;case"}":this.setgLevel(2);break;case"~":this.setgLevel(1);break;case"7":this.saveCursor(),this.state=i.normal;break;case"8":this.restoreCursor(),this.state=i.normal;break;case"#":this.state=i.normal,h++;break;case"H":this.tabSet();break;case"=":this.log("Serial port requested application keypad."),this.applicationKeypad=!0,this.state=i.normal;break;case">":this.log("Switching back to normal keypad."),this.applicationKeypad=!1,this.state=i.normal;break;default:this.state=i.normal,this.error("Unknown ESC control: %s.",o)}break;case i.charset:switch(o){case"0":n=t.charsets.SCLD;break;case"A":n=t.charsets.UK;break;case"B":n=t.charsets.US;break;case"4":n=t.charsets.Dutch;break;case"C":case"5":n=t.charsets.Finnish;break;case"R":n=t.charsets.French;break;case"Q":n=t.charsets.FrenchCanadian;break;case"K":n=t.charsets.German;break;case"Y":n=t.charsets.Italian;break;case"E":case"6":n=t.charsets.NorwegianDanish;break;case"Z":n=t.charsets.Spanish;break;case"H":case"7":n=t.charsets.Swedish;break;case"=":n=t.charsets.Swiss;break;case"/":n=t.charsets.ISOLatin,h++;break;default:n=t.charsets.US}this.setgCharset(this.gcharset,n),this.gcharset=null,this.state=i.normal;break;case i.osc:if(""===o||""===o){switch(""===o&&h++,this.params.push(this.currentParam),this.params[0]){case 0:case 1:case 2:this.params[1]&&(this.title=this.params[1],this.handleTitle(this.title));break;case 3:break;case 4:case 5:break;case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:break;case 46:break;case 50:break;case 51:break;case 52:break;case 104:case 105:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:}this.params=[],this.currentParam=0,this.state=i.normal}else this.params.length?this.currentParam+=o:o>="0"&&"9">=o?this.currentParam=10*this.currentParam+o.charCodeAt(0)-48:";"===o&&(this.params.push(this.currentParam),this.currentParam="");break;case i.csi:if("?"===o||">"===o||"!"===o){this.prefix=o;break}if(o>="0"&&"9">=o){this.currentParam=10*this.currentParam+o.charCodeAt(0)-48;break}if("$"===o||'"'===o||" "===o||"'"===o){this.postfix=o;break}if(this.params.push(this.currentParam),this.currentParam=0,";"===o)break;switch(this.state=i.normal,o){case"A":this.cursorUp(this.params);break;case"B":this.cursorDown(this.params);break;case"C":this.cursorForward(this.params);break;case"D":this.cursorBackward(this.params);break;case"H":this.cursorPos(this.params);break;case"J":this.eraseInDisplay(this.params);break;case"K":this.eraseInLine(this.params);break;case"m":this.charAttributes(this.params);break;case"n":this.deviceStatus(this.params);break;case"@":this.insertChars(this.params);break;case"E":this.cursorNextLine(this.params);break;case"F":this.cursorPrecedingLine(this.params);break;case"G":this.cursorCharAbsolute(this.params);break;case"L":this.insertLines(this.params);break;case"M":this.deleteLines(this.params);break;case"P":this.deleteChars(this.params);break;case"X":this.eraseChars(this.params);break;case"`":this.charPosAbsolute(this.params);break;case"a":this.HPositionRelative(this.params);break;case"c":break;case"d":this.linePosAbsolute(this.params);break;case"e":this.VPositionRelative(this.params);break;case"f":this.HVPosition(this.params);break;case"h":break;case"l":break;case"r":break;case"s":this.saveCursor(this.params);break;case"u":this.restoreCursor(this.params);break;case"I":this.cursorForwardTab(this.params);break;case"S":break;case"T":2>this.params.length&&!this.prefix;break;case"Z":this.cursorBackwardTab(this.params);break;case"b":this.repeatPrecedingCharacter(this.params);break;case"g":this.tabClear(this.params);break;case"p":switch(this.prefix){case"!":this.softReset(this.params)}break;default:this.error("Unknown CSI code: %s.",o)}this.prefix="",this.postfix="";break;case i.dcs:if(""===o||""===o){switch(""===o&&h++,this.prefix){case"":break;case"$q":var c=this.currentParam;switch(c){case'"q':c='0"q';break;case'"p':c='61"p';break;case"r":c=""+(this.scrollTop+1)+";"+(this.scrollBottom+1)+"r";break;case"m":c="0m";break;default:this.error("Unknown DCS Pt: %s.",c),c=""}break;case"+p":break;default:this.error("Unknown DCS prefix: %s.",this.prefix)}this.currentParam=0,this.prefix="",this.state=i.normal}else this.currentParam?this.currentParam+=o:this.prefix||"$"===o||"+"===o?2===this.prefix.length?this.currentParam=o:this.prefix+=o:this.currentParam=o;break;case i.ignore:""===o||""===o?(""===o&&h++,this.stateData="",this.state=i.normal):(this.stateData||(this.stateData=""),this.stateData+=o)}this.updateRange(this.y),this.refresh(this.refreshStart,this.refreshEnd)},t.prototype.writeln=function(t){t=t.replace(/ /g,"&nbsp;"),this.write(t+" \r\n")}}},{"./states":8}],3:[function(t,e){"use strict";var s=t("../states");e.exports=function(t){t.prototype.index=function(){this.y++,this.y>this.scrollBottom&&(this.y--,this.scroll()),this.state=s.normal},t.prototype.reverseIndex=function(){var t;this.y--,this.y<this.scrollTop&&(this.y++,this.lines.splice(this.y+this.ybase,0,this.blankLine(!0)),t=this.rows-1-this.scrollBottom,this.lines.splice(this.rows-1+this.ybase-t+1,1),this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)),this.state=s.normal}}},{"../states":8}],5:[function(t,e){"use strict";var s=t("../states");e.exports=function(t){t.prototype.tabSet=function(){this.tabs[this.x]=!0,this.state=s.normal}}},{"../states":8}],31:[function(t,e,s){(function(t){function e(t,e){if(t.indexOf)return t.indexOf(e);for(var s=0;t.length>s;s++)if(e===t[s])return s;return-1}t.EventEmitter||(t.EventEmitter=function(){});var r=s.EventEmitter=t.EventEmitter,i="function"==typeof Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},n=10;r.prototype.setMaxListeners=function(t){this._events||(this._events={}),this._events.maxListeners=t},r.prototype.emit=function(t){if("error"===t&&(!this._events||!this._events.error||i(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var e=this._events[t];if(!e)return!1;if("function"==typeof e){switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:var s=Array.prototype.slice.call(arguments,1);e.apply(this,s)}return!0}if(i(e)){for(var s=Array.prototype.slice.call(arguments,1),r=e.slice(),n=0,o=r.length;o>n;n++)r[n].apply(this,s);return!0}return!1},r.prototype.addListener=function(t,e){if("function"!=typeof e)throw Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",t,e),this._events[t])if(i(this._events[t])){if(!this._events[t].warned){var s;s=void 0!==this._events.maxListeners?this._events.maxListeners:n,s&&s>0&&this._events[t].length>s&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace())}this._events[t].push(e)}else this._events[t]=[this._events[t],e];else this._events[t]=e;return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){var s=this;return s.on(t,function r(){s.removeListener(t,r),e.apply(this,arguments)}),this},r.prototype.removeListener=function(t,s){if("function"!=typeof s)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var r=this._events[t];if(i(r)){var n=e(r,s);if(0>n)return this;r.splice(n,1),0==r.length&&delete this._events[t]}else this._events[t]===s&&delete this._events[t];return this},r.prototype.removeAllListeners=function(t){return 0===arguments.length?(this._events={},this):(t&&this._events&&this._events[t]&&(this._events[t]=null),this)},r.prototype.listeners=function(t){return this._events||(this._events={}),this._events[t]||(this._events[t]=[]),i(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]}})(t("__browserify_process"))},{__browserify_process:29}],32:[function(t,e,s){function r(t){return t instanceof Array||Array.isArray(t)||t&&t!==Object.prototype&&r(t.__proto__)}function i(t){return t instanceof RegExp||"object"==typeof t&&"[object RegExp]"===Object.prototype.toString.call(t)}function n(t){if(t instanceof Date)return!0;if("object"!=typeof t)return!1;var e=Date.prototype&&a(Date.prototype),s=t.__proto__&&a(t.__proto__);return JSON.stringify(s)===JSON.stringify(e)}t("events"),s.isArray=r,s.isDate=function(t){return"[object Date]"===Object.prototype.toString.call(t)},s.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},s.print=function(){},s.puts=function(){},s.debug=function(){},s.inspect=function(t,e,h,c){function u(t,h){if(t&&"function"==typeof t.inspect&&t!==s&&(!t.constructor||t.constructor.prototype!==t))return t.inspect(h);switch(typeof t){case"undefined":return p("undefined","undefined");case"string":var c="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";
return p(c,"string");case"number":return p(""+t,"number");case"boolean":return p(""+t,"boolean")}if(null===t)return p("null","null");var f=o(t),d=e?a(t):f;if("function"==typeof t&&0===d.length){if(i(t))return p(""+t,"regexp");var b=t.name?": "+t.name:"";return p("[Function"+b+"]","special")}if(n(t)&&0===d.length)return p(t.toUTCString(),"date");var y,m,v;if(r(t)?(m="Array",v=["[","]"]):(m="Object",v=["{","}"]),"function"==typeof t){var g=t.name?": "+t.name:"";y=i(t)?" "+t:" [Function"+g+"]"}else y="";if(n(t)&&(y=" "+t.toUTCString()),0===d.length)return v[0]+y+v[1];if(0>h)return i(t)?p(""+t,"regexp"):p("[Object]","special");l.push(t);var w=d.map(function(e){var s,i;if(t.__lookupGetter__&&(t.__lookupGetter__(e)?i=t.__lookupSetter__(e)?p("[Getter/Setter]","special"):p("[Getter]","special"):t.__lookupSetter__(e)&&(i=p("[Setter]","special"))),0>f.indexOf(e)&&(s="["+e+"]"),i||(0>l.indexOf(t[e])?(i=null===h?u(t[e]):u(t[e],h-1),i.indexOf("\n")>-1&&(i=r(t)?i.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+i.split("\n").map(function(t){return" "+t}).join("\n"))):i=p("[Circular]","special")),s===void 0){if("Array"===m&&e.match(/^\d+$/))return i;s=JSON.stringify(""+e),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=p(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=p(s,"string"))}return s+": "+i});l.pop();var k=0,_=w.reduce(function(t,e){return k++,e.indexOf("\n")>=0&&k++,t+e.length+1},0);return w=_>50?v[0]+(""===y?"":y+"\n ")+" "+w.join(",\n ")+" "+v[1]:v[0]+y+" "+w.join(", ")+" "+v[1]}var l=[],p=function(t,e){var s={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},r={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[e];return r?"["+s[r][0]+"m"+t+"["+s[r][1]+"m":t};return c||(p=function(t){return t}),u(t,h===void 0?2:h)},s.log=function(){},s.pump=null;var o=Object.keys||function(t){var e=[];for(var s in t)e.push(s);return e},a=Object.getOwnPropertyNames||function(t){var e=[];for(var s in t)Object.hasOwnProperty.call(t,s)&&e.push(s);return e},h=Object.create||function(t,e){var s;if(null===t)s={__proto__:null};else{if("object"!=typeof t)throw new TypeError("typeof prototype["+typeof t+"] != 'object'");var r=function(){};r.prototype=t,s=new r,s.__proto__=t}return e!==void 0&&Object.defineProperties&&Object.defineProperties(s,e),s};s.inherits=function(t,e){t.super_=e,t.prototype=h(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})};var c=/%[sdj%]/g;s.format=function(t){if("string"!=typeof t){for(var e=[],r=0;arguments.length>r;r++)e.push(s.inspect(arguments[r]));return e.join(" ")}for(var r=1,i=arguments,n=i.length,o=(t+"").replace(c,function(t){if("%%"===t)return"%";if(r>=n)return t;switch(t){case"%s":return i[r++]+"";case"%d":return Number(i[r++]);case"%j":return JSON.stringify(i[r++]);default:return t}}),a=i[r];n>r;a=i[++r])o+=null===a||"object"!=typeof a?" "+a:" "+s.inspect(a);return o}},{events:31}]},{},[]),require=function(t,e,s){function r(s,n){if(!e[s]){if(!t[s]){var o="function"==typeof require&&require;if(!n&&o)return o(s,!0);if(i)return i(s,!0);throw Error("Cannot find module '"+s+"'")}var a=e[s]={exports:{}};t[s][0].call(a.exports,function(e){var i=t[s][1][e];return r(i?i:e)},a,a.exports)}return e[s].exports}for(var i="function"==typeof require&&require,n=0;s.length>n;n++)r(s[n]);return r}({jsonp:[function(t,e){e.exports=t("MHg1EC")},{}],MHg1EC:[function(t,e){function s(){}function r(t,e,r){function o(){p.parentNode.removeChild(a),window["__jp"+f]=s}"function"==typeof e&&(r=e,e={});var a,h,e=e||{},c=e.param||"callback",u=null!=e.timeout?e.timeout:6e4,l=encodeURIComponent,p=document.getElementsByTagName("script")[0],f=n++;u&&(h=setTimeout(function(){o(),r&&r(Error("Timeout"))},u)),window["__jp"+f]=function(t){i("jsonp got",t),h&&clearTimeout(h),o(),r&&r(null,t)},t+=(~t.indexOf("?")?"&":"?")+c+"="+l("__jp"+f),t=t.replace("?&","?"),i('jsonp req "%s"',t),a=document.createElement("script"),a.src=t,p.parentNode.insertBefore(a,p)}var i=t("debug")("jsonp");e.exports=r;var n=0},{debug:1}],1:[function(t,e){function s(t){return s.enabled(t)?function(e){var r=new Date,i=r-(s[t]||r);s[t]=r,e=t+" "+e+" +"+s.humanize(i),window.console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}:function(){}}e.exports=s,s.names=[],s.skips=[],s.enable=function(t){try{localStorage.debug=t}catch(e){}for(var r=(t||"").split(/[\s,]+/),i=r.length,n=0;i>n;n++)t=r[n].replace("*",".*?"),"-"===t[0]?s.skips.push(RegExp("^"+t.substr(1)+"$")):s.names.push(RegExp("^"+t+"$"))},s.disable=function(){s.enable("")},s.humanize=function(t){var e=1e3,s=6e4,r=60*s;return t>=r?(t/r).toFixed(1)+"h":t>=s?(t/s).toFixed(1)+"m":t>=e?(0|t/e)+"s":t+"ms"},s.enabled=function(t){for(var e=0,r=s.skips.length;r>e;e++)if(s.skips[e].test(t))return!1;for(var e=0,r=s.names.length;r>e;e++)if(s.names[e].test(t))return!0;return!1},window.localStorage&&s.enable(localStorage.debug)},{}]},{},[]);var term=require("hypernal")(),tablify=require("tablify").tablify,jsonp=require("jsonp");term.appendTo(document.body);var termEl=term.term.element;termEl.style.font="13px Monaco",termEl.style.height="100%",termEl.style.padding="5px",termEl.style["white-space"]="pre",term.write("BOSTON PUBLIC LIBRARIES\n"),jsonp("http://civicapi.ic.ht/bos_public_libraries/_all_docs?include_docs=true",function(t,e){var s=[];e.rows.map(function(t){t.doc&&t.doc.properties&&s.push(t.doc.properties)}),term.write(tablify(s))});
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; }
body, html { height: 100%; width: 100%; }</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment