UNPKG

documenu

Version:

Package to easily use Documenu API. US restaurant menu API With Over 600,000 Restaurants: www.Documenu.com

37 lines (36 loc) 14.9 kB
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(a){return a.raw=a};$jscomp.createTemplateTagFirstArgWithRaw=function(a,b){a.raw=b;return a};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.makeIterator=function(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):$jscomp.arrayIterator(a)}; $jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a}; $jscomp.getGlobal=function(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={}; $jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(a,b){var c=$jscomp.propertyToPolyfillSymbol[b];if(null==c)return a[b];c=a[c];return void 0!==c?c:a[b]};$jscomp.polyfill=function(a,b,c,e){b&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(a,b,c,e):$jscomp.polyfillUnisolated(a,b,c,e))}; $jscomp.polyfillUnisolated=function(a,b,c,e){c=$jscomp.global;a=a.split(".");for(e=0;e<a.length-1;e++){var d=a[e];if(!(d in c))return;c=c[d]}a=a[a.length-1];e=c[a];b=b(e);b!=e&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}; $jscomp.polyfillIsolated=function(a,b,c,e){var d=a.split(".");a=1===d.length;e=d[0];e=!a&&e in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var f=0;f<d.length-1;f++){var g=d[f];if(!(g in e))return;e=e[g]}d=d[d.length-1];c=$jscomp.IS_SYMBOL_NATIVE&&"es6"===c?e[d]:null;b=b(c);null!=b&&(a?$jscomp.defineProperty($jscomp.polyfills,d,{configurable:!0,writable:!0,value:b}):b!==c&&($jscomp.propertyToPolyfillSymbol[d]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(d):$jscomp.POLYFILL_PREFIX+d,d= $jscomp.propertyToPolyfillSymbol[d],$jscomp.defineProperty(e,d,{configurable:!0,writable:!0,value:b})))};$jscomp.underscoreProtoCanBeSet=function(){var a={a:!0},b={};try{return b.__proto__=a,b.a}catch(c){}return!1};$jscomp.setPrototypeOf=$jscomp.TRUST_ES6_POLYFILLS&&"function"==typeof Object.setPrototypeOf?Object.setPrototypeOf:$jscomp.underscoreProtoCanBeSet()?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null;$jscomp.generator={}; $jscomp.generator.ensureIteratorResultIsObject_=function(a){if(!(a instanceof Object))throw new TypeError("Iterator result "+a+" is not an object");};$jscomp.generator.Context=function(){this.isRunning_=!1;this.yieldAllIterator_=null;this.yieldResult=void 0;this.nextAddress=1;this.finallyAddress_=this.catchAddress_=0;this.finallyContexts_=this.abruptCompletion_=null}; $jscomp.generator.Context.prototype.start_=function(){if(this.isRunning_)throw new TypeError("Generator is already running");this.isRunning_=!0};$jscomp.generator.Context.prototype.stop_=function(){this.isRunning_=!1};$jscomp.generator.Context.prototype.jumpToErrorHandler_=function(){this.nextAddress=this.catchAddress_||this.finallyAddress_};$jscomp.generator.Context.prototype.next_=function(a){this.yieldResult=a}; $jscomp.generator.Context.prototype.throw_=function(a){this.abruptCompletion_={exception:a,isException:!0};this.jumpToErrorHandler_()};$jscomp.generator.Context.prototype["return"]=function(a){this.abruptCompletion_={"return":a};this.nextAddress=this.finallyAddress_};$jscomp.generator.Context.prototype.jumpThroughFinallyBlocks=function(a){this.abruptCompletion_={jumpTo:a};this.nextAddress=this.finallyAddress_};$jscomp.generator.Context.prototype.yield=function(a,b){this.nextAddress=b;return{value:a}}; $jscomp.generator.Context.prototype.yieldAll=function(a,b){var c=$jscomp.makeIterator(a),e=c.next();$jscomp.generator.ensureIteratorResultIsObject_(e);if(e.done)this.yieldResult=e.value,this.nextAddress=b;else return this.yieldAllIterator_=c,this.yield(e.value,b)};$jscomp.generator.Context.prototype.jumpTo=function(a){this.nextAddress=a};$jscomp.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0}; $jscomp.generator.Context.prototype.setCatchFinallyBlocks=function(a,b){this.catchAddress_=a;void 0!=b&&(this.finallyAddress_=b)};$jscomp.generator.Context.prototype.setFinallyBlock=function(a){this.catchAddress_=0;this.finallyAddress_=a||0};$jscomp.generator.Context.prototype.leaveTryBlock=function(a,b){this.nextAddress=a;this.catchAddress_=b||0}; $jscomp.generator.Context.prototype.enterCatchBlock=function(a){this.catchAddress_=a||0;a=this.abruptCompletion_.exception;this.abruptCompletion_=null;return a};$jscomp.generator.Context.prototype.enterFinallyBlock=function(a,b,c){c?this.finallyContexts_[c]=this.abruptCompletion_:this.finallyContexts_=[this.abruptCompletion_];this.catchAddress_=a||0;this.finallyAddress_=b||0}; $jscomp.generator.Context.prototype.leaveFinallyBlock=function(a,b){var c=this.finallyContexts_.splice(b||0)[0];if(c=this.abruptCompletion_=this.abruptCompletion_||c){if(c.isException)return this.jumpToErrorHandler_();void 0!=c.jumpTo&&this.finallyAddress_<c.jumpTo?(this.nextAddress=c.jumpTo,this.abruptCompletion_=null):this.nextAddress=this.finallyAddress_}else this.nextAddress=a};$jscomp.generator.Context.prototype.forIn=function(a){return new $jscomp.generator.Context.PropertyIterator(a)}; $jscomp.generator.Context.PropertyIterator=function(a){this.object_=a;this.properties_=[];for(var b in a)this.properties_.push(b);this.properties_.reverse()};$jscomp.generator.Context.PropertyIterator.prototype.getNext=function(){for(;0<this.properties_.length;){var a=this.properties_.pop();if(a in this.object_)return a}return null};$jscomp.generator.Engine_=function(a){this.context_=new $jscomp.generator.Context;this.program_=a}; $jscomp.generator.Engine_.prototype.next_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_.next,a,this.context_.next_);this.context_.next_(a);return this.nextStep_()}; $jscomp.generator.Engine_.prototype.return_=function(a){this.context_.start_();var b=this.context_.yieldAllIterator_;if(b)return this.yieldAllStep_("return"in b?b["return"]:function(c){return{value:c,done:!0}},a,this.context_["return"]);this.context_["return"](a);return this.nextStep_()}; $jscomp.generator.Engine_.prototype.throw_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_["throw"],a,this.context_.next_);this.context_.throw_(a);return this.nextStep_()}; $jscomp.generator.Engine_.prototype.yieldAllStep_=function(a,b,c){try{var e=a.call(this.context_.yieldAllIterator_,b);$jscomp.generator.ensureIteratorResultIsObject_(e);if(!e.done)return this.context_.stop_(),e;var d=e.value}catch(f){return this.context_.yieldAllIterator_=null,this.context_.throw_(f),this.nextStep_()}this.context_.yieldAllIterator_=null;c.call(this.context_,d);return this.nextStep_()}; $jscomp.generator.Engine_.prototype.nextStep_=function(){for(;this.context_.nextAddress;)try{var a=this.program_(this.context_);if(a)return this.context_.stop_(),{value:a.value,done:!1}}catch(b){this.context_.yieldResult=void 0,this.context_.throw_(b)}this.context_.stop_();if(this.context_.abruptCompletion_){a=this.context_.abruptCompletion_;this.context_.abruptCompletion_=null;if(a.isException)throw a.exception;return{value:a["return"],done:!0}}return{value:void 0,done:!0}}; $jscomp.generator.Generator_=function(a){this.next=function(b){return a.next_(b)};this["throw"]=function(b){return a.throw_(b)};this["return"]=function(b){return a.return_(b)};this[Symbol.iterator]=function(){return this}};$jscomp.generator.createGenerator=function(a,b){var c=new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(b));$jscomp.setPrototypeOf&&a.prototype&&$jscomp.setPrototypeOf(c,a.prototype);return c}; $jscomp.asyncExecutePromiseGenerator=function(a){function b(e){return a.next(e)}function c(e){return a["throw"](e)}return new Promise(function(e,d){function f(g){g.done?e(g.value):Promise.resolve(g.value).then(b,c).then(f,d)}f(a.next())})};$jscomp.asyncExecutePromiseGeneratorFunction=function(a){return $jscomp.asyncExecutePromiseGenerator(a())};$jscomp.asyncExecutePromiseGeneratorProgram=function(a){return $jscomp.asyncExecutePromiseGenerator(new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(a)))}; var Documenu={},axios=require("axios"),APIURL="https://api.documenu.com/v2";Documenu.Restaurants={};Documenu.MenuItems={}; var createQueryString=function(a,b){b=void 0===b?!1:b;var c,e,d,f,g,h;return $jscomp.asyncExecutePromiseGeneratorProgram(function(l){c=Object.keys(a);if(0==c.length)return l["return"]("");if(b)for(e=$jscomp.makeIterator(b),d=e.next();!d.done;d=e.next())if(r=d.value,-1==c.indexOf(r))return l["return"](!1);f="?";g=$jscomp.makeIterator(c);for(h=g.next();!h.done;h=g.next())k=h.value,f+=c.indexOf(k)<c.length-1?k+"="+a[k]+"&":k+"="+a[k];return l["return"](f)})}; Documenu.configure=function(a){Documenu.apikey=a;Documenu.headers={"x-api-key":a}};Documenu.Restaurants.get=function(a){var b,c;return $jscomp.asyncExecutePromiseGeneratorProgram(function(e){if(1==e.nextAddress)return b={method:"get",url:APIURL+"/restaurant/"+a,headers:Documenu.headers},e.yield(axios(b)["catch"](function(d){console.log(d);return d}),2);c=e.yieldResult;return e["return"](c.data)})}; Documenu.Restaurants.getMenuItems=function(a,b){b=void 0===b?{}:b;var c,e,d;return $jscomp.asyncExecutePromiseGeneratorProgram(function(f){if(1==f.nextAddress)return f.yield(createQueryString(b),2);if(3!=f.nextAddress)return c=f.yieldResult,e={method:"get",url:APIURL+"/restaurant/"+a+"/menuitems"+c,headers:Documenu.headers},f.yield(axios(e)["catch"](function(g){console.log(g);return g}),3);d=f.yieldResult;return f["return"](d.data)})}; Documenu.Restaurants.searchFields=function(a){var b,c,e;return $jscomp.asyncExecutePromiseGeneratorProgram(function(d){if(1==d.nextAddress)return d.yield(createQueryString(a),2);if(3!=d.nextAddress)return b=d.yieldResult,c={method:"get",url:APIURL+"/restaurants/search/fields"+b,headers:Documenu.headers},d.yield(axios(c)["catch"](function(f){console.log(f);return f}),3);e=d.yieldResult;return d["return"](e.data)})}; Documenu.Restaurants.searchGeo=function(a){var b,c,e;return $jscomp.asyncExecutePromiseGeneratorProgram(function(d){if(1==d.nextAddress)return d.yield(createQueryString(a,["lat","lon"],["distance"]),2);if(3!=d.nextAddress){b=d.yieldResult;if(0==b)return d["return"]("Missing Parameters");c={method:"get",url:APIURL+"/restaurants/search/geo"+b,headers:Documenu.headers};return d.yield(axios(c)["catch"](function(f){console.log(f);return f}),3)}e=d.yieldResult;return d["return"](e.data)})}; Documenu.Restaurants.getByState=function(a,b){b=void 0===b?{}:b;var c,e,d;return $jscomp.asyncExecutePromiseGeneratorProgram(function(f){if(1==f.nextAddress)return f.yield(createQueryString(b),2);if(3!=f.nextAddress){c=f.yieldResult;if(void 0==a||null==a)return f["return"]("Missing Parameters");e={method:"get",url:APIURL+"/restaurants/state/"+a+c,headers:Documenu.headers};return f.yield(axios(e)["catch"](function(g){console.log(g);return g}),3)}d=f.yieldResult;return f["return"](d.data)})}; Documenu.Restaurants.getByZipCode=function(a,b){b=void 0===b?{}:b;var c,e,d;return $jscomp.asyncExecutePromiseGeneratorProgram(function(f){if(1==f.nextAddress)return f.yield(createQueryString(b),2);if(3!=f.nextAddress){c=f.yieldResult;if(void 0==a||null==a)return f["return"]("Missing Parameters");e={method:"get",url:APIURL+"/restaurants/zip_code/"+a+c,headers:Documenu.headers};return f.yield(axios(e)["catch"](function(g){console.log(g);return g}),3)}d=f.yieldResult;return f["return"](d.data)})}; Documenu.Restaurants.geoBoundingBox=function(a){var b,c,e;return $jscomp.asyncExecutePromiseGeneratorProgram(function(d){if(1==d.nextAddress)return d.yield(createQueryString(a,["top_left","bottom_right"]),2);if(3!=d.nextAddress){b=d.yieldResult;if(0==b)return d["return"]("Missing Parameters");c={method:"get",url:APIURL+"/restaurants/geobbox"+b,headers:Documenu.headers};return d.yield(axios(c)["catch"](function(f){console.log(f);return f}),3)}e=d.yieldResult;return d["return"](e.data)})}; Documenu.Restaurants.withinGeoPolygon=function(a,b){b=void 0===b?[]:b;var c,e,d,f,g;return $jscomp.asyncExecutePromiseGeneratorProgram(function(h){if(1==h.nextAddress)return h.yield(createQueryString(b),2);if(3!=h.nextAddress){c=h.yieldResult;if(void 0==a||"object"!=typeof a)return h["return"]("Missing Parameters");e=JSON.stringify({points:a});d=Documenu.headers;d["Content-Type"]="application/json";f={method:"post",url:APIURL+"/restaurants/geopolygon"+c,headers:d,data:e};console.log(APIURL+"/restaurants/geopolygon"+ c);return h.yield(axios(f)["catch"](function(l){console.log(l);return l}),3)}g=h.yieldResult;return h["return"](g.data)})}; Documenu.Restaurants.withinTravelRadius=function(a){var b,c,e;return $jscomp.asyncExecutePromiseGeneratorProgram(function(d){if(1==d.nextAddress)return d.yield(createQueryString(a,["lon","lat","mode","minutes"]),2);if(3!=d.nextAddress){b=d.yieldResult;if(0==b)return d["return"]("Missing Parameters");c={method:"get",url:APIURL+"/restaurants/distance"+b,headers:Documenu.headers};return d.yield(axios(c)["catch"](function(f){console.log(f);return f}),3)}e=d.yieldResult;return d["return"](e.data)})}; Documenu.MenuItems.get=function(a){var b,c;return $jscomp.asyncExecutePromiseGeneratorProgram(function(e){if(1==e.nextAddress)return b={method:"get",url:APIURL+"/menuitem/"+a,headers:Documenu.headers},e.yield(axios(b)["catch"](function(d){console.log(d);return d}),2);c=e.yieldResult;return e["return"](c.data)})}; Documenu.MenuItems.searchGeo=function(a){var b,c,e;return $jscomp.asyncExecutePromiseGeneratorProgram(function(d){if(1==d.nextAddress)return d.yield(createQueryString(a,["lon","lat","distance"]),2);if(3!=d.nextAddress){b=d.yieldResult;if(0==b)return d["return"]("Missing Parameters");c={method:"get",url:APIURL+"/menuitems/search/geo"+b,headers:Documenu.headers};return d.yield(axios(c)["catch"](function(f){console.log(f);return f}),3)}e=d.yieldResult;return d["return"](e.data)})};module.exports=Documenu;