Socket
Socket
Sign inDemoInstall

mbta-client

Package Overview
Dependencies
5
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.2 to 0.4.0

4

dist/mbta-client.min.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["mbta-client.min"]=t():e["mbta-client.min"]=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=9)}([function(e,t,n){"use strict";var r=n(4),o=n(15),i=Object.prototype.toString;function s(e){return"[object Array]"===i.call(e)}function a(e){return null!==e&&"object"==typeof e}function u(e){return"[object Function]"===i.call(e)}function c(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),s(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:s,isArrayBuffer:function(e){return"[object ArrayBuffer]"===i.call(e)},isBuffer:o,isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===i.call(e)},isFile:function(e){return"[object File]"===i.call(e)},isBlob:function(e){return"[object Blob]"===i.call(e)},isFunction:u,isStream:function(e){return a(e)&&u(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:c,merge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]=n}for(var r=0,o=arguments.length;r<o;r++)c(arguments[r],n);return t},extend:function(e,t,n){return c(t,function(t,o){e[o]=n&&"function"==typeof t?r(t,n):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t,n){"use strict";(function(t){var r=n(0),o=n(18),i={"Content-Type":"application/x-www-form-urlencoded"};function s(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var a,u={adapter:("undefined"!=typeof XMLHttpRequest?a=n(5):void 0!==t&&(a=n(5)),a),transformRequest:[function(e,t){return o(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(s(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)?(s(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},r.forEach(["delete","get","head"],function(e){u.headers[e]={}}),r.forEach(["post","put","patch"],function(e){u.headers[e]=r.merge(i)}),e.exports=u}).call(this,n(17))},function(e,t,n){const{Attributes:r}=n(3),o=e=>t=>t&&t.data?t.data.map(t=>t.attributes[e]):(console.warn("No response data..."),[]),i=o(r.arrival_time),s=o(r.departure_time);e.exports={selectPage:(e,t)=>(e=>{if(!e)throw new Error("No response, fetch data before accessing this value");if(!e.links)throw new Error('response.links does not exist, "limit" must be in fetch options');return e.links})(t)[e],selectIncluded:(e,t)=>{if(!e)throw new Error("included() requires an MBTA response as an argument");return e.included?e.included.filter(e=>Array.isArray(t)?t.includes(e.type):t===e.type||null==t):(console.warn('response.included does not exist, "include" must be in fetch options'),[])},selectArrivalISOs:i,selectDepartureISOs:s}},function(e,t){e.exports={Attributes:{arrival_time:"arrival_time",departure_time:"departure_time"},Pagination:{first:"first",next:"next",prev:"prev",last:"last"}}},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t,n){"use strict";var r=n(0),o=n(19),i=n(21),s=n(22),a=n(23),u=n(6),c="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(24);e.exports=function(e){return new Promise(function(t,f){var l=e.data,p=e.headers;r.isFormData(l)&&delete p["Content-Type"];var d=new XMLHttpRequest,h="onreadystatechange",m=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in d||a(e.url)||(d=new window.XDomainRequest,h="onload",m=!0,d.onprogress=function(){},d.ontimeout=function(){}),e.auth){var y=e.auth.username||"",w=e.auth.password||"";p.Authorization="Basic "+c(y+":"+w)}if(d.open(e.method.toUpperCase(),i(e.url,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,d[h]=function(){if(d&&(4===d.readyState||m)&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in d?s(d.getAllResponseHeaders()):null,r={data:e.responseType&&"text"!==e.responseType?d.response:d.responseText,status:1223===d.status?204:d.status,statusText:1223===d.status?"No Content":d.statusText,headers:n,config:e,request:d};o(t,f,r),d=null}},d.onerror=function(){f(u("Network Error",e,null,d)),d=null},d.ontimeout=function(){f(u("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",d)),d=null},r.isStandardBrowserEnv()){var v=n(25),g=(e.withCredentials||a(e.url))&&e.xsrfCookieName?v.read(e.xsrfCookieName):void 0;g&&(p[e.xsrfHeaderName]=g)}if("setRequestHeader"in d&&r.forEach(p,function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete p[t]:d.setRequestHeader(t,e)}),e.withCredentials&&(d.withCredentials=!0),e.responseType)try{d.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&d.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){d&&(d.abort(),f(e),d=null)}),void 0===l&&(l=null),d.send(l)})}},function(e,t,n){"use strict";var r=n(20);e.exports=function(e,t,n,o,i){var s=new Error(e);return r(s,t,n,o,i)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function r(e){this.message=e}r.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},r.prototype.__CANCEL__=!0,e.exports=r},function(e,t,n){const r=n(10);e.exports=r},function(e,t,n){const{buildUrl:r,arrivalsWithConversion:o,departuresWithConversion:i}=n(11),{selectPage:s,selectIncluded:a}=n(2),u=n(12),{Pagination:c}=n(3);e.exports=class{constructor(e,t=u){this.apiKey=e,this.fetch=t}async fetchPredictions(e){return this.fetch(r("/predictions",e,this.apiKey))}async fetchStops(e){return this.fetch(r("/stops",e,this.apiKey))}async fetchTrips(e){return this.fetch(r("/trips",e,this.apiKey))}async fetchRoutes(e){return this.fetch(r("/routes",e,this.apiKey))}async fetchVehicles(e){return this.fetch(r("/vehicles",e,this.apiKey))}async fetchShapes(e){return this.fetch(r("/shapes",e,this.apiKey))}async fetchServices(e){return this.fetch(r("/services",e,this.apiKey))}async fetchSchedules(e){return this.fetch(r("/schedules",e,this.apiKey))}async fetchFacilities(e){return this.fetch(r("/facilities",e,this.apiKey))}async fetchAlerts(e){return this.fetch(r("/alerts",e,this.apiKey))}selectArrivals(e,{convertTo:t,now:n}={}){return o({response:e,convertTo:t,now:n})}selectDepartures(e,{convertTo:t,now:n}={}){return i({response:e,convertTo:t,now:n})}selectIncluded(e,t){return a(e,t)}async fetchFirstPage(e){return this.fetch(s(c.first,e))}async fetchNextPage(e){return this.fetch(s(c.next,e))}async fetchPrevPage(e){return this.fetch(s(c.prev,e))}async fetchLastPage(e){return this.fetch(s(c.last,e))}}},function(e,t,n){const{selectArrivalISOs:r,selectDepartureISOs:o}=n(2),i=e=>null!=e&&""!==e,s=e=>Array.isArray(e)&&!e.filter(Boolean).length,a="https://api-v3.mbta.com",u=e=>[].concat(e).filter(Boolean).join(",").replace(/,\s/g,","),c=(e,t)=>{if(!i(t))return e;const n={"hours|hrs":36e5,"minutes|mins":6e4,"seconds|secs":1e3,"ms|milliseconds":1},r=Object.keys(n).find(e=>new RegExp(t,"i").test(e));if(!i(r))throw new Error(`Invalid 'convertTo' value: ${t}`);return e/n[r]},f=e=>t=>{const{response:n,max:r,convertTo:o,now:i=Date.now()}=t;return e(n).slice(0,r).map(e=>{if(null==o||null==e)return e;const t=new Date(e).valueOf()-i,n=Math.floor(c(t,o));return n>=0?n:0})},l=f(r),p=f(o),d=e=>new Date(e).toISOString(),h=e=>{const t=["tram|light rail|streetcar|trolley","subway|metro|train","rail|commuter|commuter rail","bus|autobus","ferry|boat","cable car","gondola|suspended cable car","funicular"],n=Number(e);if(!i(e)||n>=t.length)return console.warn(`Invalid type: ${e}`),null;if(n==n)return n;const r=t.findIndex(t=>new RegExp(e,"i").test(t));return r>-1?r:null},m=(e,t)=>{if(!i(t))return console.warn("API key is missing. Keys available at https://api-v3.mbta.com"),`${e}`;const n=e.includes("?")?"&":"?";return`${e}${n}api_key=${t}`};e.exports={exists:i,buildUrl:function(e,t,n){const r=a+e;if(!e)throw new Error("Please provide an endpoint. See https://api-v3.mbta.com/docs/swagger/index.html");if(!t||!Object.keys(t).length)return m(r,n);const{limit:o,offset:c,latitude:f,longitude:l,descending:p,min_time:y,max_time:w,radius:v,route:g,stop:x,sort:b,trip:T}=t,E=t=>t===e;!E("/predictions")&&!E("/schedules")||i(x)||i(T)||i(g)||console.warn('Please include "stop", "trip", or "route"'),E("/shapes")&&!i(g)&&console.warn('Shape requires a "route" param'),i(c)&&!i(o)&&console.warn('"offset" will have no effect without "limit"'),(i(f)&&!i(l)||!i(f)&&i(l))&&console.warn("Latitude and longitude must both be present"),!i(v)||i(f)&&i(l)||console.warn("Radius requires latitude and longitude"),i(p)&&!i(b)&&console.warn('"descending" has no effect without "sort"'),[y,w].forEach(e=>{i(e)&&!/^\d{2}:\d{2}/.test(e)&&console.warn("min_time and max_time format should be HH:MM")});const S=Object.entries(t).map(([e,n])=>{let r;switch(e){case"sort":return t.descending?`sort=-${n}`:`sort=${n}`;case"limit":case"offset":return`page[${e}]=${n}`;case"date":r=[].concat(n).map(d);break;case"route_type":case"type":r=[].concat(n).map(h);break;default:r=n}return!i(r)||s(r)?null:`${e}=${u(r)}`}).filter(e=>!!e&&!/descending/.test(e)).join("&");return m(`${r}?${S}`,n)},convertMs:c,convertTimes:f,isEmptyArray:s,normalizeType:h,normalizeDate:d,arrivalsWithConversion:l,departuresWithConversion:p}},function(e,t,n){const r=n(13);e.exports=(async(e,t=r)=>{try{const n=await t.get(e);if(!n||!n.data)throw new Error("No data from MBTA");return n.data}catch(e){const{response:t}=e;if(t&&t.data&&t.data.errors){const[e]=t.data.errors;throw console.error(`Error ${e.status||e.code} fetching MBTA data: ${e.detail||"(no details)"}`),e}throw console.error("Error fetching MBTA data:",e.message),e}})},function(e,t,n){e.exports=n(14)},function(e,t,n){"use strict";var r=n(0),o=n(4),i=n(16),s=n(1);function a(e){var t=new i(e),n=o(i.prototype.request,t);return r.extend(n,i.prototype,t),r.extend(n,t),n}var u=a(s);u.Axios=i,u.create=function(e){return a(r.merge(s,e))},u.Cancel=n(8),u.CancelToken=n(31),u.isCancel=n(7),u.all=function(e){return Promise.all(e)},u.spread=n(32),e.exports=u,e.exports.default=u},function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["mbta-client.min"]=t():e["mbta-client.min"]=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=9)}([function(e,t,n){"use strict";var r=n(4),o=n(15),i=Object.prototype.toString;function s(e){return"[object Array]"===i.call(e)}function a(e){return null!==e&&"object"==typeof e}function c(e){return"[object Function]"===i.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),s(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:s,isArrayBuffer:function(e){return"[object ArrayBuffer]"===i.call(e)},isBuffer:o,isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===i.call(e)},isFile:function(e){return"[object File]"===i.call(e)},isBlob:function(e){return"[object Blob]"===i.call(e)},isFunction:c,isStream:function(e){return a(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:u,merge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]=n}for(var r=0,o=arguments.length;r<o;r++)u(arguments[r],n);return t},extend:function(e,t,n){return u(t,function(t,o){e[o]=n&&"function"==typeof t?r(t,n):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t,n){"use strict";(function(t){var r=n(0),o=n(18),i={"Content-Type":"application/x-www-form-urlencoded"};function s(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var a,c={adapter:("undefined"!=typeof XMLHttpRequest?a=n(5):void 0!==t&&(a=n(5)),a),transformRequest:[function(e,t){return o(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(s(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)?(s(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},r.forEach(["delete","get","head"],function(e){c.headers[e]={}}),r.forEach(["post","put","patch"],function(e){c.headers[e]=r.merge(i)}),e.exports=c}).call(this,n(17))},function(e,t,n){const{Attributes:r}=n(3),o=e=>t=>t&&t.data?t.data.map(t=>t.attributes[e]):(console.warn("No response data..."),[]),i=o(r.arrival_time),s=o(r.departure_time);e.exports={selectPage:(e,t)=>(e=>{if(!e)throw new Error("No response, fetch data before accessing this value");if(!e.links)throw new Error('response.links does not exist, "limit" must be in fetch options');return e.links})(t)[e],selectIncluded:(e,t)=>{if(!e)throw new Error("included() requires an MBTA response as an argument");return e.included?e.included.filter(e=>Array.isArray(t)?t.includes(e.type):t===e.type||null==t):(console.warn('response.included does not exist, "include" must be in fetch options'),[])},selectArrivalISOs:i,selectDepartureISOs:s}},function(e,t){e.exports={Attributes:{arrival_time:"arrival_time",departure_time:"departure_time"},Pagination:{first:"first",next:"next",prev:"prev",last:"last"}}},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t,n){"use strict";var r=n(0),o=n(19),i=n(21),s=n(22),a=n(23),c=n(6),u="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(24);e.exports=function(e){return new Promise(function(t,f){var l=e.data,p=e.headers;r.isFormData(l)&&delete p["Content-Type"];var d=new XMLHttpRequest,h="onreadystatechange",m=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in d||a(e.url)||(d=new window.XDomainRequest,h="onload",m=!0,d.onprogress=function(){},d.ontimeout=function(){}),e.auth){var y=e.auth.username||"",w=e.auth.password||"";p.Authorization="Basic "+u(y+":"+w)}if(d.open(e.method.toUpperCase(),i(e.url,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,d[h]=function(){if(d&&(4===d.readyState||m)&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in d?s(d.getAllResponseHeaders()):null,r={data:e.responseType&&"text"!==e.responseType?d.response:d.responseText,status:1223===d.status?204:d.status,statusText:1223===d.status?"No Content":d.statusText,headers:n,config:e,request:d};o(t,f,r),d=null}},d.onerror=function(){f(c("Network Error",e,null,d)),d=null},d.ontimeout=function(){f(c("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",d)),d=null},r.isStandardBrowserEnv()){var v=n(25),g=(e.withCredentials||a(e.url))&&e.xsrfCookieName?v.read(e.xsrfCookieName):void 0;g&&(p[e.xsrfHeaderName]=g)}if("setRequestHeader"in d&&r.forEach(p,function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete p[t]:d.setRequestHeader(t,e)}),e.withCredentials&&(d.withCredentials=!0),e.responseType)try{d.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&d.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){d&&(d.abort(),f(e),d=null)}),void 0===l&&(l=null),d.send(l)})}},function(e,t,n){"use strict";var r=n(20);e.exports=function(e,t,n,o,i){var s=new Error(e);return r(s,t,n,o,i)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function r(e){this.message=e}r.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},r.prototype.__CANCEL__=!0,e.exports=r},function(e,t,n){const r=n(10);e.exports=r},function(e,t,n){const{buildUrl:r,arrivalsWithConversion:o,departuresWithConversion:i}=n(11),{selectPage:s,selectIncluded:a}=n(2),c=n(12),{Pagination:u}=n(3);e.exports=class{constructor(e,t=c){this.apiKey=e,this.fetch=t}async fetchPredictions(e){return this.fetch(r("/predictions",e,this.apiKey))}async fetchStops(e){return this.fetch(r("/stops",e,this.apiKey))}async fetchTrips(e){return this.fetch(r("/trips",e,this.apiKey))}async fetchRoutes(e){return this.fetch(r("/routes",e,this.apiKey))}async fetchVehicles(e){return this.fetch(r("/vehicles",e,this.apiKey))}async fetchShapes(e){return this.fetch(r("/shapes",e,this.apiKey))}async fetchServices(e){return this.fetch(r("/services",e,this.apiKey))}async fetchSchedules(e){return this.fetch(r("/schedules",e,this.apiKey))}async fetchFacilities(e){return this.fetch(r("/facilities",e,this.apiKey))}async fetchLiveFacilities(e){return this.fetch(r("/live-facilities",e,this.apiKey))}async fetchAlerts(e){return this.fetch(r("/alerts",e,this.apiKey))}async fetchAllRoutes(e){return(await this.fetchRoutes(e)).data.map(e=>{const{short_name:t}=e.attributes;return{...t&&t!==e.id?{short_name:t}:{},id:e.id,long_name:e.attributes.long_name,direction_names:e.attributes.direction_names}})}async fetchStopsByRoute(e){return(await this.fetchStops({route:e})).data.map(e=>({name:e.attributes.name,id:e.id}))}async fetchStopsByName(e,{exact:t}={}){return(await this.fetchStops()).data.filter(n=>t?n.attributes.name===e:n.attributes.name.match(e))}selectArrivals(e,{convertTo:t,now:n}={}){return o({response:e,convertTo:t,now:n})}selectDepartures(e,{convertTo:t,now:n}={}){return i({response:e,convertTo:t,now:n})}selectIncluded(e,t){return a(e,t)}async fetchFirstPage(e){return this.fetch(s(u.first,e))}async fetchNextPage(e){return this.fetch(s(u.next,e))}async fetchPrevPage(e){return this.fetch(s(u.prev,e))}async fetchLastPage(e){return this.fetch(s(u.last,e))}}},function(e,t,n){const{selectArrivalISOs:r,selectDepartureISOs:o}=n(2),i=e=>null!=e&&""!==e,s=e=>Array.isArray(e)&&!e.filter(Boolean).length,a="https://api-v3.mbta.com",c=e=>[].concat(e).filter(Boolean).join(",").replace(/,\s/g,","),u=(e,t)=>{if(!i(t))return e;const n={"hours|hrs":36e5,"minutes|mins":6e4,"seconds|secs":1e3,"ms|milliseconds":1},r=Object.keys(n).find(e=>new RegExp(t,"i").test(e));if(!i(r))throw new Error(`Invalid 'convertTo' value: ${t}`);return e/n[r]},f=e=>t=>{const{response:n,max:r,convertTo:o,now:i=Date.now()}=t;return e(n).slice(0,r).map(e=>{if(null==o||null==e)return e;const t=new Date(e).valueOf()-i,n=Math.floor(u(t,o));return n>=0?n:0})},l=f(r),p=f(o),d=e=>new Date(e).toISOString(),h=e=>{const t=["tram|light rail|streetcar|trolley","subway|metro|train","rail|commuter|commuter rail","bus|autobus","ferry|boat","cable car","gondola|suspended cable car","funicular"],n=Number(e);if(!i(e)||n>=t.length)return console.warn(`Invalid type: ${e}`),null;if(n==n)return n;const r=t.findIndex(t=>new RegExp(e,"i").test(t));return r>-1?r:null},m=(e,t)=>{if(!i(t))return console.warn("API key is missing. Keys available at https://api-v3.mbta.com"),`${e}`;const n=e.includes("?")?"&":"?";return`${e}${n}api_key=${t}`};e.exports={exists:i,buildUrl:function(e,t,n){const r=a+e;if(!e)throw new Error("Please provide an endpoint. See https://api-v3.mbta.com/docs/swagger/index.html");if(!t||!Object.keys(t).length)return m(r,n);const{limit:o,offset:u,latitude:f,longitude:l,descending:p,min_time:y,max_time:w,radius:v,route:g,stop:x,sort:b,trip:T}=t,E=t=>t===e;!E("/predictions")&&!E("/schedules")||i(x)||i(T)||i(g)||console.warn('Please include "stop", "trip", or "route"'),E("/shapes")&&!i(g)&&console.warn('Shape requires a "route" param'),i(u)&&!i(o)&&console.warn('"offset" will have no effect without "limit"'),(i(f)&&!i(l)||!i(f)&&i(l))&&console.warn("Latitude and longitude must both be present"),!i(v)||i(f)&&i(l)||console.warn("Radius requires latitude and longitude"),i(p)&&!i(b)&&console.warn('"descending" has no effect without "sort"'),[y,w].forEach(e=>{i(e)&&!/^\d{2}:\d{2}/.test(e)&&console.warn("min_time and max_time format should be HH:MM")});const S=Object.entries(t).map(([e,n])=>{let r;switch(e){case"sort":return t.descending?`sort=-${n}`:`sort=${n}`;case"limit":case"offset":return`page[${e}]=${n}`;case"date":r=[].concat(n).map(d);break;case"route_type":case"type":r=[].concat(n).map(h);break;default:r=n}return!i(r)||s(r)?null:`${e}=${c(r)}`}).filter(e=>!!e&&!/descending/.test(e)).join("&");return m(`${r}?${S}`,n)},convertMs:u,convertTimes:f,isEmptyArray:s,normalizeType:h,normalizeDate:d,arrivalsWithConversion:l,departuresWithConversion:p}},function(e,t,n){const r=n(13);e.exports=(async(e,t=r)=>{try{const n=await t.get(e);if(!n||!n.data)throw new Error("No data from MBTA");return n.data}catch(e){const{response:t}=e;if(t&&t.data&&t.data.errors){const[e]=t.data.errors;throw console.error(`Error ${e.status||e.code} fetching MBTA data: ${e.detail||"(no details)"}`),e}throw console.error("Error fetching MBTA data:",e.message),e}})},function(e,t,n){e.exports=n(14)},function(e,t,n){"use strict";var r=n(0),o=n(4),i=n(16),s=n(1);function a(e){var t=new i(e),n=o(i.prototype.request,t);return r.extend(n,i.prototype,t),r.extend(n,t),n}var c=a(s);c.Axios=i,c.create=function(e){return a(r.merge(s,e))},c.Cancel=n(8),c.CancelToken=n(31),c.isCancel=n(7),c.all=function(e){return Promise.all(e)},c.spread=n(32),e.exports=c,e.exports.default=c},function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}
/*!

@@ -8,3 +8,3 @@ * Determine if an object is a Buffer

*/
e.exports=function(e){return null!=e&&(n(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}(e)||!!e._isBuffer)}},function(e,t,n){"use strict";var r=n(1),o=n(0),i=n(26),s=n(27);function a(e){this.defaults=e,this.interceptors={request:new i,response:new i}}a.prototype.request=function(e){"string"==typeof e&&(e=o.merge({url:arguments[0]},arguments[1])),(e=o.merge(r,{method:"get"},this.defaults,e)).method=e.method.toLowerCase();var t=[s,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},o.forEach(["delete","get","head","options"],function(e){a.prototype[e]=function(t,n){return this.request(o.merge(n||{},{method:e,url:t}))}}),o.forEach(["post","put","patch"],function(e){a.prototype[e]=function(t,n,r){return this.request(o.merge(r||{},{method:e,url:t,data:n}))}}),e.exports=a},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var u,c=[],f=!1,l=-1;function p(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&d())}function d(){if(!f){var e=a(p);f=!0;for(var t=c.length;t;){for(u=c,c=[];++l<t;)u&&u[l].run();l=-1,t=c.length}u=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function m(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new h(e,t)),1!==c.length||f||a(d)},h.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(6);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e}},function(e,t,n){"use strict";var r=n(0);function o(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(r.isURLSearchParams(t))i=t.toString();else{var s=[];r.forEach(t,function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),s.push(o(t)+"="+o(e))}))}),i=s.join("&")}return i&&(e+=(-1===e.indexOf("?")?"?":"&")+i),e}},function(e,t,n){"use strict";var r=n(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,s={};return e?(r.forEach(e.split("\n"),function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}}),s):s}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=o(window.location.href),function(t){var n=r.isString(t)?o(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function o(){this.message="String contains an invalid character"}o.prototype=new Error,o.prototype.code=5,o.prototype.name="InvalidCharacterError",e.exports=function(e){for(var t,n,i=String(e),s="",a=0,u=r;i.charAt(0|a)||(u="=",a%1);s+=u.charAt(63&t>>8-a%1*8)){if((n=i.charCodeAt(a+=.75))>255)throw new o;t=t<<8|n}return s}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,n){"use strict";var r=n(0);function o(){this.handlers=[]}o.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){r.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=o},function(e,t,n){"use strict";var r=n(0),o=n(28),i=n(7),s=n(1),a=n(29),u=n(30);function c(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return c(e),e.baseURL&&!a(e.url)&&(e.url=u(e.baseURL,e.url)),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),r.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||s.adapter)(e).then(function(t){return c(e),t.data=o(t.data,t.headers,e.transformResponse),t},function(t){return i(t)||(c(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(8);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new r(e),t(n.reason))})}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o(function(t){e=t}),cancel:e}},e.exports=o},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])});
e.exports=function(e){return null!=e&&(n(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}(e)||!!e._isBuffer)}},function(e,t,n){"use strict";var r=n(1),o=n(0),i=n(26),s=n(27);function a(e){this.defaults=e,this.interceptors={request:new i,response:new i}}a.prototype.request=function(e){"string"==typeof e&&(e=o.merge({url:arguments[0]},arguments[1])),(e=o.merge(r,{method:"get"},this.defaults,e)).method=e.method.toLowerCase();var t=[s,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},o.forEach(["delete","get","head","options"],function(e){a.prototype[e]=function(t,n){return this.request(o.merge(n||{},{method:e,url:t}))}}),o.forEach(["post","put","patch"],function(e){a.prototype[e]=function(t,n,r){return this.request(o.merge(r||{},{method:e,url:t,data:n}))}}),e.exports=a},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c,u=[],f=!1,l=-1;function p(){f&&c&&(f=!1,c.length?u=c.concat(u):l=-1,u.length&&d())}function d(){if(!f){var e=a(p);f=!0;for(var t=u.length;t;){for(c=u,u=[];++l<t;)c&&c[l].run();l=-1,t=u.length}c=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function m(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new h(e,t)),1!==u.length||f||a(d)},h.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(6);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e}},function(e,t,n){"use strict";var r=n(0);function o(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(r.isURLSearchParams(t))i=t.toString();else{var s=[];r.forEach(t,function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),s.push(o(t)+"="+o(e))}))}),i=s.join("&")}return i&&(e+=(-1===e.indexOf("?")?"?":"&")+i),e}},function(e,t,n){"use strict";var r=n(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,s={};return e?(r.forEach(e.split("\n"),function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}}),s):s}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=o(window.location.href),function(t){var n=r.isString(t)?o(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function o(){this.message="String contains an invalid character"}o.prototype=new Error,o.prototype.code=5,o.prototype.name="InvalidCharacterError",e.exports=function(e){for(var t,n,i=String(e),s="",a=0,c=r;i.charAt(0|a)||(c="=",a%1);s+=c.charAt(63&t>>8-a%1*8)){if((n=i.charCodeAt(a+=.75))>255)throw new o;t=t<<8|n}return s}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,n){"use strict";var r=n(0);function o(){this.handlers=[]}o.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){r.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=o},function(e,t,n){"use strict";var r=n(0),o=n(28),i=n(7),s=n(1),a=n(29),c=n(30);function u(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return u(e),e.baseURL&&!a(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),r.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||s.adapter)(e).then(function(t){return u(e),t.data=o(t.data,t.headers,e.transformResponse),t},function(t){return i(t)||(u(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(8);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new r(e),t(n.reason))})}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o(function(t){e=t}),cancel:e}},e.exports=o},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])});
//# sourceMappingURL=mbta-client.min.map
/* eslint-disable camelcase */
const { buildUrl, arrivalsWithConversion, departuresWithConversion } = require('./utils');
const {
buildUrl,
arrivalsWithConversion,
departuresWithConversion,
} = require('./utils');
const { selectPage, selectIncluded } = require('./selectors');

@@ -59,2 +63,6 @@ const fetchService = require('./fetchService');

async fetchLiveFacilities(queryParams) {
return this.fetch(buildUrl('/live-facilities', queryParams, this.apiKey));
}
async fetchAlerts(queryParams) {

@@ -64,29 +72,39 @@ return this.fetch(buildUrl('/alerts', queryParams, this.apiKey));

// async fetchAllRoutesBasic({ type } = {}) {
// const routes = await this.fetchRoutes({ type });
// return routes.data.map(ea => ({
// id: ea.id,
// abbr: ea.attributes.short_name,
// name: ea.attributes.long_name,
// directions: ea.attributes.direction_names,
// }));
// }
/**
* Fetch helper functions
*/
async fetchAllRoutes(filters) {
// Example: filter by { type: 3 } to get all bus routes
const routes = await this.fetchRoutes(filters);
return routes.data.map(route => {
const { short_name } = route.attributes;
// Only include short_name if it exists and is different from `id`
const maybeAbbr =
short_name && short_name !== route.id ? { short_name } : {};
return {
...maybeAbbr,
id: route.id,
long_name: route.attributes.long_name,
direction_names: route.attributes.direction_names,
};
});
}
// async fetchAllStopsByRoute(route) {
// const stops = await this.fetchStops({ route });
// return stops.data.map(stop => ({
// name: stop.attributes.name,
// id: stop.id,
// }));
// }
async fetchStopsByRoute(route) {
const stops = await this.fetchStops({ route });
return stops.data.map(stop => ({
name: stop.attributes.name,
id: stop.id,
}));
}
// async fetchStopByName(name, { exact } = {}) {
// const allStops = await this.fetchStops();
// return allStops.data.filter(stop => {
// if (exact) {
// return stop.attributes.name === name;
// }
// return stop.attributes.name.match(name);
// });
// }
async fetchStopsByName(name, { exact } = {}) {
const allStops = await this.fetchStops();
return allStops.data.filter(stop => {
if (exact) {
return stop.attributes.name === name;
}
return stop.attributes.name.match(name);
});
}

@@ -93,0 +111,0 @@ /**

{
"name": "mbta-client",
"version": "0.3.2",
"version": "0.4.0",
"description": "MBTA API v3 Node.js Client Library",

@@ -48,6 +48,3 @@ "main": "index.js",

"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"eslint-plugin-standard": "^4.0.0",
"husky": "^1.2.1",

@@ -54,0 +51,0 @@ "jest": "^23.6.0",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc