addsearch-js-client
Advanced tools
Comparing version 0.1.19 to 0.2.1
@@ -1,2 +0,2 @@ | ||
window.AddSearchClient=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=8)}([function(t,e,n){"use strict";t.exports={isFunction:function(t){return t&&"[object Function]"==={}.toString.call(t)}}},function(t,e,n){"use strict";t.exports=function(){this.settings={keyword:"*",callback:null,fuzzy:!0,paging:{page:1,pageSize:10,sortBy:"relevance",sortOrder:"desc"},customFieldFilters:[],userToken:null,suggestionsSize:10,facetFields:[]},this.getSettings=function(){return this.settings},this.setKeyword=function(t){this.settings.keyword=t||"*"},this.setCallback=function(t){this.settings.callback=t},this.setSuggestionsPrefix=function(t){this.settings.suggestionsPrefix=t},this.setSuggestionsSize=function(t){this.settings.suggestionsSize=t},this.setLanguage=function(t){if(t&&2!==t.length)throw'use 2-char language code (e.g. "en")';this.settings.lang=t},this.useFuzzyMatch=function(t){this.settings.fuzzy=t},this.setCategoryFilters=function(t){this.settings.categories=t},this.setFilterObject=function(t){this.settings.filterObject=t},this.setPriceRangeFilter=function(t,e){this.settings.priceFromCents=t,this.settings.priceToCents=e},this.addCustomFieldFilter=function(t,e){var n=encodeURIComponent(t+"="+e);-1===this.settings.customFieldFilters.indexOf(n)&&this.settings.customFieldFilters.push(n)},this.removeCustomFieldFilter=function(t,e){var n=!1,r=encodeURIComponent(t+"="+e);e||(n=!0,r=encodeURIComponent(t+"="));for(var i=this.settings.customFieldFilters.length;i>0;i--){var s=this.settings.customFieldFilters[i-1];n&&0===s.indexOf(r)?this.settings.customFieldFilters.splice(i-1,1):s===r&&this.settings.customFieldFilters.splice(i-1,1)}},this.setDateFilter=function(t,e){this.settings.dateFrom=t,this.settings.dateTo=e},this.setKeyword=function(t){this.settings.keyword=t||"*"},this.setJWT=function(t){this.settings.jwt=t},this.setUserToken=function(t){this.settings.userToken=t},this.setPersonalizationEvents=function(t){this.settings.personalizationEvents=t},this.setResultType=function(t){this.settings.resultType=t},this.addFacetField=function(t){-1===this.settings.facetFields.indexOf(t)&&this.settings.facetFields.push(t)},this.setNumberOfFacets=function(t){this.settings.numFacets=t},this.setPaging=function(t,e,n,r){if(t<1)throw"page must be 1 or bigger";if(e<1||e>300)throw"pageSize must be 1-300";if("asc"!==r&&"desc"!==r)throw"sortOrder must be asc or desc";this.settings.paging.page=t,this.settings.paging.pageSize=e,this.settings.paging.sortBy=n,this.settings.paging.sortOrder=r},this.setShuffleAndLimitTo=function(t){this.settings.shuffleAndLimitTo=t},this.nextPage=function(){this.settings.paging.page=this.settings.paging.page+1},this.previousPage=function(){this.settings.paging.page>0&&(this.settings.paging.page=this.settings.paging.page-1)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"Headers",function(){return c}),n.d(e,"Request",function(){return y}),n.d(e,"Response",function(){return b}),n.d(e,"DOMException",function(){return w}),n.d(e,"fetch",function(){return _});var r={searchParams:"URLSearchParams"in self,iterable:"Symbol"in self&&"iterator"in Symbol,blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in self,arrayBuffer:"ArrayBuffer"in self};if(r.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],s=ArrayBuffer.isView||function(t){return t&&i.indexOf(Object.prototype.toString.call(t))>-1};function o(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function a(t){return"string"!=typeof t&&(t=String(t)),t}function u(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r.iterable&&(e[Symbol.iterator]=function(){return e}),e}function c(t){this.map={},t instanceof c?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function f(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function h(t){return new Promise(function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}})}function l(t){var e=new FileReader,n=h(e);return e.readAsArrayBuffer(t),n}function d(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function p(){return this.bodyUsed=!1,this._initBody=function(t){this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:r.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():r.arrayBuffer&&r.blob&&function(t){return t&&DataView.prototype.isPrototypeOf(t)}(t)?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||s(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,n=h(e);return e.readAsText(t),n}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r<e.length;r++)n[r]=String.fromCharCode(e[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}c.prototype.append=function(t,e){t=o(t),e=a(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},c.prototype.delete=function(t){delete this.map[o(t)]},c.prototype.get=function(t){return t=o(t),this.has(t)?this.map[t]:null},c.prototype.has=function(t){return this.map.hasOwnProperty(o(t))},c.prototype.set=function(t,e){this.map[o(t)]=a(e)},c.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},c.prototype.keys=function(){var t=[];return this.forEach(function(e,n){t.push(n)}),u(t)},c.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),u(t)},c.prototype.entries=function(){var t=[];return this.forEach(function(e,n){t.push([n,e])}),u(t)},r.iterable&&(c.prototype[Symbol.iterator]=c.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function y(t,e){var n=(e=e||{}).body;if(t instanceof y){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new c(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new c(e.headers)),this.method=function(t){var e=t.toUpperCase();return g.indexOf(e)>-1?e:t}(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function m(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}}),e}function b(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new c(e.headers),this.url=e.url||"",this._initBody(t)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},p.call(y.prototype),p.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new c(this.headers),url:this.url})},b.error=function(){var t=new b(null,{status:0,statusText:""});return t.type="error",t};var v=[301,302,303,307,308];b.redirect=function(t,e){if(-1===v.indexOf(e))throw new RangeError("Invalid status code");return new b(null,{status:e,headers:{location:t}})};var w=self.DOMException;try{new w}catch(t){(w=function(t,e){this.message=t,this.name=e;var n=Error(t);this.stack=n.stack}).prototype=Object.create(Error.prototype),w.prototype.constructor=w}function _(t,e){return new Promise(function(n,i){var s=new y(t,e);if(s.signal&&s.signal.aborted)return i(new w("Aborted","AbortError"));var o=new XMLHttpRequest;function a(){o.abort()}o.onload=function(){var t={status:o.status,statusText:o.statusText,headers:function(t){var e=new c;return t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var n=t.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();e.append(r,i)}}),e}(o.getAllResponseHeaders()||"")};t.url="responseURL"in o?o.responseURL:t.headers.get("X-Request-URL");var e="response"in o?o.response:o.responseText;n(new b(e,t))},o.onerror=function(){i(new TypeError("Network request failed"))},o.ontimeout=function(){i(new TypeError("Network request failed"))},o.onabort=function(){i(new w("Aborted","AbortError"))},o.open(s.method,s.url,!0),"include"===s.credentials?o.withCredentials=!0:"omit"===s.credentials&&(o.withCredentials=!1),"responseType"in o&&r.blob&&(o.responseType="blob"),s.headers.forEach(function(t,e){o.setRequestHeader(e,t)}),s.signal&&(s.signal.addEventListener("abort",a),o.onreadystatechange=function(){4===o.readyState&&s.signal.removeEventListener("abort",a)}),o.send(void 0===s._bodyInit?null:s._bodyInit)})}_.polyfill=!0,self.fetch||(self.fetch=_,self.Headers=c,self.Request=y,self.Response=b)},function(t,e,n){n(2),t.exports=self.fetch.bind(self)},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e){var n,r,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(t){n=s}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var u,c=[],f=!1,h=-1;function l(){f&&u&&(f=!1,u.length?c=u.concat(c):h=-1,c.length&&d())}function d(){if(!f){var t=a(l);f=!0;for(var e=c.length;e;){for(u=c,c=[];++h<e;)u&&u[h].run();h=-1,e=c.length}u=null,f=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function g(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new p(t,e)),1!==c.length||f||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,n){(function(e,n){ | ||
window.AddSearchClient=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=8)}([function(t,e,n){"use strict";t.exports={isFunction:function(t){return t&&"[object Function]"==={}.toString.call(t)}}},function(t,e,n){"use strict";t.exports=function(){this.settings={keyword:"*",callback:null,fuzzy:"auto",paging:{page:1,pageSize:10,sortBy:"relevance",sortOrder:"desc"},customFieldFilters:[],userToken:null,suggestionsSize:10,facetFields:[]},this.getSettings=function(){return this.settings},this.setKeyword=function(t){this.settings.keyword=t||"*"},this.setCallback=function(t){this.settings.callback=t},this.setSuggestionsPrefix=function(t){this.settings.suggestionsPrefix=t},this.setSuggestionsSize=function(t){this.settings.suggestionsSize=t},this.setLanguage=function(t){if(t&&2!==t.length)throw'use 2-char language code (e.g. "en")';this.settings.lang=t},this.setFuzzyMatch=function(t){if(!0!==t&&!1!==t&&"auto"!==t)throw"fuzzy matching can be true, false, or 'auto'";this.settings.fuzzy=t},this.setCategoryFilters=function(t){this.settings.categories=t},this.setFilterObject=function(t){this.settings.filterObject=t},this.setPriceRangeFilter=function(t,e){this.settings.priceFromCents=t,this.settings.priceToCents=e},this.addCustomFieldFilter=function(t,e){var n=encodeURIComponent(t+"="+e);-1===this.settings.customFieldFilters.indexOf(n)&&this.settings.customFieldFilters.push(n)},this.removeCustomFieldFilter=function(t,e){var n=!1,r=encodeURIComponent(t+"="+e);e||(n=!0,r=encodeURIComponent(t+"="));for(var i=this.settings.customFieldFilters.length;i>0;i--){var s=this.settings.customFieldFilters[i-1];n&&0===s.indexOf(r)?this.settings.customFieldFilters.splice(i-1,1):s===r&&this.settings.customFieldFilters.splice(i-1,1)}},this.setDateFilter=function(t,e){this.settings.dateFrom=t,this.settings.dateTo=e},this.setKeyword=function(t){this.settings.keyword=t||"*"},this.setJWT=function(t){this.settings.jwt=t},this.setUserToken=function(t){this.settings.userToken=t},this.setPersonalizationEvents=function(t){this.settings.personalizationEvents=t},this.setResultType=function(t){this.settings.resultType=t},this.addFacetField=function(t){-1===this.settings.facetFields.indexOf(t)&&this.settings.facetFields.push(t)},this.setNumberOfFacets=function(t){this.settings.numFacets=t},this.setPaging=function(t,e,n,r){if(t<1)throw"page must be 1 or bigger";if(e<1||e>300)throw"pageSize must be 1-300";if("asc"!==r&&"desc"!==r)throw"sortOrder must be asc or desc";this.settings.paging.page=t,this.settings.paging.pageSize=e,this.settings.paging.sortBy=n,this.settings.paging.sortOrder=r},this.setShuffleAndLimitTo=function(t){this.settings.shuffleAndLimitTo=t},this.nextPage=function(){this.settings.paging.page=this.settings.paging.page+1},this.previousPage=function(){this.settings.paging.page>0&&(this.settings.paging.page=this.settings.paging.page-1)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"Headers",function(){return c}),n.d(e,"Request",function(){return y}),n.d(e,"Response",function(){return b}),n.d(e,"DOMException",function(){return w}),n.d(e,"fetch",function(){return _});var r={searchParams:"URLSearchParams"in self,iterable:"Symbol"in self&&"iterator"in Symbol,blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in self,arrayBuffer:"ArrayBuffer"in self};if(r.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],s=ArrayBuffer.isView||function(t){return t&&i.indexOf(Object.prototype.toString.call(t))>-1};function o(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function a(t){return"string"!=typeof t&&(t=String(t)),t}function u(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r.iterable&&(e[Symbol.iterator]=function(){return e}),e}function c(t){this.map={},t instanceof c?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function h(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function f(t){return new Promise(function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}})}function l(t){var e=new FileReader,n=f(e);return e.readAsArrayBuffer(t),n}function d(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function p(){return this.bodyUsed=!1,this._initBody=function(t){this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:r.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():r.arrayBuffer&&r.blob&&function(t){return t&&DataView.prototype.isPrototypeOf(t)}(t)?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||s(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,n=f(e);return e.readAsText(t),n}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r<e.length;r++)n[r]=String.fromCharCode(e[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}c.prototype.append=function(t,e){t=o(t),e=a(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},c.prototype.delete=function(t){delete this.map[o(t)]},c.prototype.get=function(t){return t=o(t),this.has(t)?this.map[t]:null},c.prototype.has=function(t){return this.map.hasOwnProperty(o(t))},c.prototype.set=function(t,e){this.map[o(t)]=a(e)},c.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},c.prototype.keys=function(){var t=[];return this.forEach(function(e,n){t.push(n)}),u(t)},c.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),u(t)},c.prototype.entries=function(){var t=[];return this.forEach(function(e,n){t.push([n,e])}),u(t)},r.iterable&&(c.prototype[Symbol.iterator]=c.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function y(t,e){var n=(e=e||{}).body;if(t instanceof y){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new c(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new c(e.headers)),this.method=function(t){var e=t.toUpperCase();return g.indexOf(e)>-1?e:t}(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function m(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}}),e}function b(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new c(e.headers),this.url=e.url||"",this._initBody(t)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},p.call(y.prototype),p.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new c(this.headers),url:this.url})},b.error=function(){var t=new b(null,{status:0,statusText:""});return t.type="error",t};var v=[301,302,303,307,308];b.redirect=function(t,e){if(-1===v.indexOf(e))throw new RangeError("Invalid status code");return new b(null,{status:e,headers:{location:t}})};var w=self.DOMException;try{new w}catch(t){(w=function(t,e){this.message=t,this.name=e;var n=Error(t);this.stack=n.stack}).prototype=Object.create(Error.prototype),w.prototype.constructor=w}function _(t,e){return new Promise(function(n,i){var s=new y(t,e);if(s.signal&&s.signal.aborted)return i(new w("Aborted","AbortError"));var o=new XMLHttpRequest;function a(){o.abort()}o.onload=function(){var t={status:o.status,statusText:o.statusText,headers:function(t){var e=new c;return t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var n=t.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();e.append(r,i)}}),e}(o.getAllResponseHeaders()||"")};t.url="responseURL"in o?o.responseURL:t.headers.get("X-Request-URL");var e="response"in o?o.response:o.responseText;n(new b(e,t))},o.onerror=function(){i(new TypeError("Network request failed"))},o.ontimeout=function(){i(new TypeError("Network request failed"))},o.onabort=function(){i(new w("Aborted","AbortError"))},o.open(s.method,s.url,!0),"include"===s.credentials?o.withCredentials=!0:"omit"===s.credentials&&(o.withCredentials=!1),"responseType"in o&&r.blob&&(o.responseType="blob"),s.headers.forEach(function(t,e){o.setRequestHeader(e,t)}),s.signal&&(s.signal.addEventListener("abort",a),o.onreadystatechange=function(){4===o.readyState&&s.signal.removeEventListener("abort",a)}),o.send(void 0===s._bodyInit?null:s._bodyInit)})}_.polyfill=!0,self.fetch||(self.fetch=_,self.Headers=c,self.Request=y,self.Response=b)},function(t,e,n){n(2),t.exports=self.fetch.bind(self)},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e){var n,r,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(t){n=s}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var u,c=[],h=!1,f=-1;function l(){h&&u&&(h=!1,u.length?c=u.concat(c):f=-1,c.length&&d())}function d(){if(!h){var t=a(l);h=!0;for(var e=c.length;e;){for(u=c,c=[];++f<e;)u&&u[f].run();f=-1,e=c.length}u=null,h=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function g(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new p(t,e)),1!==c.length||h||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,n){(function(e,n){ | ||
/*! | ||
@@ -9,2 +9,2 @@ * @overview es6-promise - a tiny implementation of Promises/A+. | ||
*/ | ||
!function(e,n){t.exports=n()}(0,function(){"use strict";function t(t){return"function"==typeof t}var r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,s=void 0,o=void 0,a=function(t,e){p[i]=t,p[i+1]=e,2===(i+=2)&&(o?o(g):y())};var u="undefined"!=typeof window?window:void 0,c=u||{},f=c.MutationObserver||c.WebKitMutationObserver,h="undefined"==typeof self&&void 0!==e&&"[object process]"==={}.toString.call(e),l="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var t=setTimeout;return function(){return t(g,1)}}var p=new Array(1e3);function g(){for(var t=0;t<i;t+=2){(0,p[t])(p[t+1]),p[t]=void 0,p[t+1]=void 0}i=0}var y=void 0;function m(t,e){var n=this,r=new this.constructor(w);void 0===r[v]&&U(r);var i=n._state;if(i){var s=arguments[i-1];a(function(){return k(i,r,s,n._result)})}else B(n,r,t,e);return r}function b(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(w);return x(e,t),e}y=h?function(){return e.nextTick(g)}:f?function(){var t=0,e=new f(g),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}():l?function(){var t=new MessageChannel;return t.port1.onmessage=g,function(){return t.port2.postMessage(0)}}():void 0===u?function(){try{var t=Function("return this")().require("vertx");return void 0!==(s=t.runOnLoop||t.runOnContext)?function(){s(g)}:d()}catch(t){return d()}}():d();var v=Math.random().toString(36).substring(2);function w(){}var _=void 0,F=1,T=2,A={error:null};function S(t){try{return t.then}catch(t){return A.error=t,A}}function E(e,n,r){n.constructor===e.constructor&&r===m&&n.constructor.resolve===b?function(t,e){e._state===F?O(t,e._result):e._state===T?j(t,e._result):B(e,void 0,function(e){return x(t,e)},function(e){return j(t,e)})}(e,n):r===A?(j(e,A.error),A.error=null):void 0===r?O(e,n):t(r)?function(t,e,n){a(function(t){var r=!1,i=function(t,e,n,r){try{t.call(e,n,r)}catch(t){return t}}(n,e,function(n){r||(r=!0,e!==n?x(t,n):O(t,n))},function(e){r||(r=!0,j(t,e))},t._label);!r&&i&&(r=!0,j(t,i))},t)}(e,n,r):O(e,n)}function x(t,e){t===e?j(t,new TypeError("You cannot resolve a promise with itself")):!function(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}(e)?O(t,e):E(t,e,S(e))}function P(t){t._onerror&&t._onerror(t._result),C(t)}function O(t,e){t._state===_&&(t._result=e,t._state=F,0!==t._subscribers.length&&a(C,t))}function j(t,e){t._state===_&&(t._state=T,t._result=e,a(P,t))}function B(t,e,n,r){var i=t._subscribers,s=i.length;t._onerror=null,i[s]=e,i[s+F]=n,i[s+T]=r,0===s&&t._state&&a(C,t)}function C(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,i=void 0,s=t._result,o=0;o<e.length;o+=3)r=e[o],i=e[o+n],r?k(n,r,i,s):i(s);t._subscribers.length=0}}function k(e,n,r,i){var s=t(r),o=void 0,a=void 0,u=void 0,c=void 0;if(s){if((o=function(t,e){try{return t(e)}catch(t){return A.error=t,A}}(r,i))===A?(c=!0,a=o.error,o.error=null):u=!0,n===o)return void j(n,new TypeError("A promises callback cannot return that same promise."))}else o=i,u=!0;n._state!==_||(s&&u?x(n,o):c?j(n,a):e===F?O(n,o):e===T&&j(n,o))}var z=0;function U(t){t[v]=z++,t._state=void 0,t._result=void 0,t._subscribers=[]}var R=function(){function t(t,e){this._instanceConstructor=t,this.promise=new t(w),this.promise[v]||U(this.promise),r(e)?(this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?O(this.promise,this._result):(this.length=this.length||0,this._enumerate(e),0===this._remaining&&O(this.promise,this._result))):j(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;this._state===_&&e<t.length;e++)this._eachEntry(t[e],e)},t.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===b){var i=S(t);if(i===m&&t._state!==_)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(n===L){var s=new n(w);E(s,t,i),this._willSettleAt(s,e)}else this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},t.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===_&&(this._remaining--,t===T?j(r,n):this._result[e]=n),0===this._remaining&&O(r,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;B(t,void 0,function(t){return n._settledAt(F,e,t)},function(t){return n._settledAt(T,e,t)})},t}();var L=function(){function e(t){this[v]=z++,this._result=this._state=void 0,this._subscribers=[],w!==t&&("function"!=typeof t&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof e?function(t,e){try{e(function(e){x(t,e)},function(e){j(t,e)})}catch(e){j(t,e)}}(this,t):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return e.prototype.catch=function(t){return this.then(null,t)},e.prototype.finally=function(e){var n=this.constructor;return t(e)?this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){throw t})}):this.then(e,e)},e}();return L.prototype.then=m,L.all=function(t){return new R(this,t).promise},L.race=function(t){var e=this;return r(t)?new e(function(n,r){for(var i=t.length,s=0;s<i;s++)e.resolve(t[s]).then(n,r)}):new e(function(t,e){return e(new TypeError("You must pass an array to race."))})},L.resolve=b,L.reject=function(t){var e=new this(w);return j(e,t),e},L._setScheduler=function(t){o=t},L._setAsap=function(t){a=t},L._asap=a,L.polyfill=function(){var t=void 0;if(void 0!==n)t=n;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;if(e){var r=null;try{r=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===r&&!e.cast)return}t.Promise=L},L.Promise=L,L})}).call(this,n(5),n(4))},function(t,e,n){"use strict";n(6).polyfill(),n(3);t.exports=function(t,e,n,r){var i=function(t,e){return t?"&"+e+"="+t:""};if("search"===e||"suggest"===e){var s="",o="";if("search"===e){if(s=(s=n.keyword).replace(/ and /g," AND ").replace(/ or /g," OR ").replace(/ not /g," NOT "),s=encodeURIComponent(s),"search"===e){if(o=i(n.lang,"lang")+i(n.fuzzy,"fuzzy")+i(n.categories,"categories")+i(n.priceFromCents,"priceFromCents")+i(n.priceToCents,"priceToCents")+i(n.dateFrom,"dateFrom")+i(n.dateTo,"dateTo")+i(n.paging.page,"page")+i(n.paging.pageSize,"limit")+i(n.paging.sortBy,"sort")+i(n.paging.sortOrder,"order")+i(n.shuffleAndLimitTo,"shuffleAndLimitTo")+i(n.jwt,"jwt")+i(n.resultType,"resultType")+i(n.userToken,"userToken")+i(n.numFacets,"numFacets"),n.customFieldFilters)for(var a=0;a<n.customFieldFilters.length;a++)o=o+"&customField="+n.customFieldFilters[a];if(n.facetFields)for(a=0;a<n.facetFields.length;a++)o=o+"&facet="+n.facetFields[a];if(n.personalizationEvents&&Array.isArray(n.personalizationEvents))for(a=0;a<n.personalizationEvents.length;a++){var u=n.personalizationEvents[a],c=Object.keys(u);o=o+"&personalizationEvent="+encodeURIComponent(c+"="+u[c])}n.filterObject&&(o=o+"&filter="+JSON.stringify(n.filterObject))}}else"suggest"===e&&(o=i(n.suggestionsSize,"size"),s=n.suggestionsPrefix);fetch("https://api.addsearch.com/v1/"+e+"/"+t+"?term="+s+o).then(function(t){return t.json()}).then(function(t){r(t)}).catch(function(t){console.log(t),r({error:{response:500,message:"invalid server response"}})})}else r({error:{response:400,message:"invalid query type"}})}},function(t,e,n){"use strict";var r=n(7),i=n(1),s=n(0);t.exports=function(t){this.sitekey=t,this.settings=new i,this.search=function(t,e){var n=null,i=null;if(t&&s.isFunction(e))n=t,i=e;else if(!e&&s.isFunction(t))n=this.settings.getSettings().keyword,i=t;else{if(!this.settings.getSettings().callback)throw"Illegal search parameters. Should be (keyword, callbackFunction) or (callbackFunction)";n=this.settings.getSettings().keyword,i=this.settings.getSettings().callback}this.settings.setCallback(i),this.settings.setKeyword(n),r(this.sitekey,"search",this.settings.getSettings(),i)},this.suggestions=function(t,e){if(!t||!e||!s.isFunction(e))throw"Illegal suggestions parameters. Should be (prefix, callbackFunction)";this.settings.setSuggestionsPrefix(t),r(this.sitekey,"suggest",this.settings.getSettings(),e)},this.getSettings=function(){return this.settings.getSettings()},this.setLanguage=function(t){this.settings.setLanguage(t)},this.useFuzzyMatch=function(t){this.settings.useFuzzyMatch(t)},this.setCategoryFilters=function(t){this.settings.setCategoryFilters(t)},this.addCustomFieldFilter=function(t,e){this.settings.addCustomFieldFilter(t,e)},this.removeCustomFieldFilter=function(t,e){this.settings.removeCustomFieldFilter(t,e)},this.setPriceRangeFilter=function(t,e){this.settings.setPriceRangeFilter(t,e)},this.setDateFilter=function(t,e){this.settings.setDateFilter(t,e)},this.setJWT=function(t){this.settings.setJWT(t)},this.setUserToken=function(t){this.settings.setUserToken(t)},this.setPaging=function(t,e,n,r){this.settings.setPaging(t,e,n,r)},this.nextPage=function(){this.settings.nextPage()},this.previousPage=function(){this.settings.previousPage()},this.setSuggestionsSize=function(t){this.settings.setSuggestionsSize(t)},this.addFacetField=function(t){this.settings.addFacetField(t)},this.setNumberOfFacets=function(t){this.settings.setNumberOfFacets(t)},this.setResultType=function(t){this.settings.setResultType(t)},this.setPersonalizationEvents=function(t){this.settings.setPersonalizationEvents(t)},this.setFilterObject=function(t){this.settings.setFilterObject(t)},this.setShuffleAndLimitTo=function(t){this.settings.setShuffleAndLimitTo(t)}}}]); | ||
!function(e,n){t.exports=n()}(0,function(){"use strict";function t(t){return"function"==typeof t}var r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=0,s=void 0,o=void 0,a=function(t,e){p[i]=t,p[i+1]=e,2===(i+=2)&&(o?o(g):y())};var u="undefined"!=typeof window?window:void 0,c=u||{},h=c.MutationObserver||c.WebKitMutationObserver,f="undefined"==typeof self&&void 0!==e&&"[object process]"==={}.toString.call(e),l="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var t=setTimeout;return function(){return t(g,1)}}var p=new Array(1e3);function g(){for(var t=0;t<i;t+=2){(0,p[t])(p[t+1]),p[t]=void 0,p[t+1]=void 0}i=0}var y=void 0;function m(t,e){var n=this,r=new this.constructor(w);void 0===r[v]&&U(r);var i=n._state;if(i){var s=arguments[i-1];a(function(){return C(i,r,s,n._result)})}else z(n,r,t,e);return r}function b(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(w);return x(e,t),e}y=f?function(){return e.nextTick(g)}:h?function(){var t=0,e=new h(g),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}():l?function(){var t=new MessageChannel;return t.port1.onmessage=g,function(){return t.port2.postMessage(0)}}():void 0===u?function(){try{var t=Function("return this")().require("vertx");return void 0!==(s=t.runOnLoop||t.runOnContext)?function(){s(g)}:d()}catch(t){return d()}}():d();var v=Math.random().toString(36).substring(2);function w(){}var _=void 0,F=1,T=2,A={error:null};function S(t){try{return t.then}catch(t){return A.error=t,A}}function E(e,n,r){n.constructor===e.constructor&&r===m&&n.constructor.resolve===b?function(t,e){e._state===F?O(t,e._result):e._state===T?j(t,e._result):z(e,void 0,function(e){return x(t,e)},function(e){return j(t,e)})}(e,n):r===A?(j(e,A.error),A.error=null):void 0===r?O(e,n):t(r)?function(t,e,n){a(function(t){var r=!1,i=function(t,e,n,r){try{t.call(e,n,r)}catch(t){return t}}(n,e,function(n){r||(r=!0,e!==n?x(t,n):O(t,n))},function(e){r||(r=!0,j(t,e))},t._label);!r&&i&&(r=!0,j(t,i))},t)}(e,n,r):O(e,n)}function x(t,e){t===e?j(t,new TypeError("You cannot resolve a promise with itself")):!function(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}(e)?O(t,e):E(t,e,S(e))}function P(t){t._onerror&&t._onerror(t._result),B(t)}function O(t,e){t._state===_&&(t._result=e,t._state=F,0!==t._subscribers.length&&a(B,t))}function j(t,e){t._state===_&&(t._state=T,t._result=e,a(P,t))}function z(t,e,n,r){var i=t._subscribers,s=i.length;t._onerror=null,i[s]=e,i[s+F]=n,i[s+T]=r,0===s&&t._state&&a(B,t)}function B(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,i=void 0,s=t._result,o=0;o<e.length;o+=3)r=e[o],i=e[o+n],r?C(n,r,i,s):i(s);t._subscribers.length=0}}function C(e,n,r,i){var s=t(r),o=void 0,a=void 0,u=void 0,c=void 0;if(s){if((o=function(t,e){try{return t(e)}catch(t){return A.error=t,A}}(r,i))===A?(c=!0,a=o.error,o.error=null):u=!0,n===o)return void j(n,new TypeError("A promises callback cannot return that same promise."))}else o=i,u=!0;n._state!==_||(s&&u?x(n,o):c?j(n,a):e===F?O(n,o):e===T&&j(n,o))}var k=0;function U(t){t[v]=k++,t._state=void 0,t._result=void 0,t._subscribers=[]}var R=function(){function t(t,e){this._instanceConstructor=t,this.promise=new t(w),this.promise[v]||U(this.promise),r(e)?(this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?O(this.promise,this._result):(this.length=this.length||0,this._enumerate(e),0===this._remaining&&O(this.promise,this._result))):j(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;this._state===_&&e<t.length;e++)this._eachEntry(t[e],e)},t.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===b){var i=S(t);if(i===m&&t._state!==_)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(n===L){var s=new n(w);E(s,t,i),this._willSettleAt(s,e)}else this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},t.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===_&&(this._remaining--,t===T?j(r,n):this._result[e]=n),0===this._remaining&&O(r,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;z(t,void 0,function(t){return n._settledAt(F,e,t)},function(t){return n._settledAt(T,e,t)})},t}();var L=function(){function e(t){this[v]=k++,this._result=this._state=void 0,this._subscribers=[],w!==t&&("function"!=typeof t&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof e?function(t,e){try{e(function(e){x(t,e)},function(e){j(t,e)})}catch(e){j(t,e)}}(this,t):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return e.prototype.catch=function(t){return this.then(null,t)},e.prototype.finally=function(e){var n=this.constructor;return t(e)?this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){throw t})}):this.then(e,e)},e}();return L.prototype.then=m,L.all=function(t){return new R(this,t).promise},L.race=function(t){var e=this;return r(t)?new e(function(n,r){for(var i=t.length,s=0;s<i;s++)e.resolve(t[s]).then(n,r)}):new e(function(t,e){return e(new TypeError("You must pass an array to race."))})},L.resolve=b,L.reject=function(t){var e=new this(w);return j(e,t),e},L._setScheduler=function(t){o=t},L._setAsap=function(t){a=t},L._asap=a,L.polyfill=function(){var t=void 0;if(void 0!==n)t=n;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;if(e){var r=null;try{r=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===r&&!e.cast)return}t.Promise=L},L.Promise=L,L})}).call(this,n(5),n(4))},function(t,e,n){"use strict";n(6).polyfill(),n(3);t.exports=function(t,e,n,r){var i=function(t,e){return t?"&"+e+"="+t:""};if("search"===e||"suggest"===e){var s="",o="";if("search"===e){if(s=(s=n.keyword).replace(/ and /g," AND ").replace(/ or /g," OR ").replace(/ not /g," NOT "),s=encodeURIComponent(s),"search"===e){if(o=i(n.lang,"lang")+i(n.fuzzy,"fuzzy")+i(n.categories,"categories")+i(n.priceFromCents,"priceFromCents")+i(n.priceToCents,"priceToCents")+i(n.dateFrom,"dateFrom")+i(n.dateTo,"dateTo")+i(n.paging.page,"page")+i(n.paging.pageSize,"limit")+i(n.paging.sortBy,"sort")+i(n.paging.sortOrder,"order")+i(n.shuffleAndLimitTo,"shuffleAndLimitTo")+i(n.jwt,"jwt")+i(n.resultType,"resultType")+i(n.userToken,"userToken")+i(n.numFacets,"numFacets"),n.customFieldFilters)for(var a=0;a<n.customFieldFilters.length;a++)o=o+"&customField="+n.customFieldFilters[a];if(n.facetFields)for(a=0;a<n.facetFields.length;a++)o=o+"&facet="+n.facetFields[a];if(n.personalizationEvents&&Array.isArray(n.personalizationEvents))for(a=0;a<n.personalizationEvents.length;a++){var u=n.personalizationEvents[a],c=Object.keys(u);o=o+"&personalizationEvent="+encodeURIComponent(c+"="+u[c])}n.filterObject&&(o=o+"&filter="+JSON.stringify(n.filterObject))}}else"suggest"===e&&(o=i(n.suggestionsSize,"size"),s=n.suggestionsPrefix);fetch("https://api.addsearch.com/v1/"+e+"/"+t+"?term="+s+o).then(function(t){return t.json()}).then(function(t){r(t)}).catch(function(t){console.log(t),r({error:{response:500,message:"invalid server response"}})})}else r({error:{response:400,message:"invalid query type"}})}},function(t,e,n){"use strict";var r=n(7),i=n(1),s=n(0);t.exports=function(t){this.sitekey=t,this.settings=new i,this.search=function(t,e){var n=null,i=null;if(t&&s.isFunction(e))n=t,i=e;else if(!e&&s.isFunction(t))n=this.settings.getSettings().keyword,i=t;else{if(!this.settings.getSettings().callback)throw"Illegal search parameters. Should be (keyword, callbackFunction) or (callbackFunction)";n=this.settings.getSettings().keyword,i=this.settings.getSettings().callback}this.settings.setCallback(i),this.settings.setKeyword(n),r(this.sitekey,"search",this.settings.getSettings(),i)},this.suggestions=function(t,e){if(!t||!e||!s.isFunction(e))throw"Illegal suggestions parameters. Should be (prefix, callbackFunction)";this.settings.setSuggestionsPrefix(t),r(this.sitekey,"suggest",this.settings.getSettings(),e)},this.getSettings=function(){return this.settings.getSettings()},this.setLanguage=function(t){this.settings.setLanguage(t)},this.setCategoryFilters=function(t){this.settings.setCategoryFilters(t)},this.addCustomFieldFilter=function(t,e){this.settings.addCustomFieldFilter(t,e)},this.removeCustomFieldFilter=function(t,e){this.settings.removeCustomFieldFilter(t,e)},this.setPriceRangeFilter=function(t,e){this.settings.setPriceRangeFilter(t,e)},this.setDateFilter=function(t,e){this.settings.setDateFilter(t,e)},this.setJWT=function(t){this.settings.setJWT(t)},this.setUserToken=function(t){this.settings.setUserToken(t)},this.setPaging=function(t,e,n,r){this.settings.setPaging(t,e,n,r)},this.nextPage=function(){this.settings.nextPage()},this.previousPage=function(){this.settings.previousPage()},this.setSuggestionsSize=function(t){this.settings.setSuggestionsSize(t)},this.addFacetField=function(t){this.settings.addFacetField(t)},this.setNumberOfFacets=function(t){this.settings.setNumberOfFacets(t)},this.setResultType=function(t){this.settings.setResultType(t)},this.setPersonalizationEvents=function(t){this.settings.setPersonalizationEvents(t)},this.setFilterObject=function(t){this.settings.setFilterObject(t)},this.setShuffleAndLimitTo=function(t){this.settings.setShuffleAndLimitTo(t)},this.setFuzzyMatch=function(t){this.settings.setFuzzyMatch(t)},this.useFuzzyMatch=function(t){this.settings.setFuzzyMatch(t)}}}]); |
{ | ||
"name": "addsearch-js-client", | ||
"version": "0.1.19", | ||
"version": "0.2.1", | ||
"description": "AddSearch API JavaScript client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -74,4 +74,4 @@ # AddSearch Search API Client for JavaScript | ||
```js | ||
// Enable/disable fuzzy matching for typo tolerance (default "true") | ||
client.useFuzzyMatch(false); | ||
// Enable/disable fuzzy matching. Possible values true/false/"auto" (default: "auto") | ||
client.setFuzzyMatch(false); | ||
``` | ||
@@ -153,6 +153,14 @@ | ||
#### Manage paging | ||
Set page number, page size and sorting parameters. It's possible to order results by: | ||
- relevance (descending) | ||
- date (ascending or descending) | ||
- custom field value (ascending or descending. E.g. *custom_fields.price*) | ||
```js | ||
// Defaults: page "1", pageSize "10", sortBy "relevance", sortOrder "desc" | ||
client.setPaging(page, pageSize, sortBy, sortOrder); | ||
``` | ||
Other functions. | ||
```js | ||
// Next page (call search function to fetch results) | ||
@@ -159,0 +167,0 @@ client.nextPage(); |
@@ -69,3 +69,2 @@ 'use strict'; | ||
this.setLanguage = function(lang) { this.settings.setLanguage(lang); } | ||
this.useFuzzyMatch = function(use) { this.settings.useFuzzyMatch(use); } | ||
this.setCategoryFilters = function(categories) { this.settings.setCategoryFilters(categories); } | ||
@@ -88,5 +87,9 @@ this.addCustomFieldFilter = function(fieldName, value) { this.settings.addCustomFieldFilter(fieldName, value); } | ||
this.setShuffleAndLimitTo = function(shuffleAndLimitTo) { this.settings.setShuffleAndLimitTo(shuffleAndLimitTo); } | ||
this.setFuzzyMatch = function(fuzzy) { this.settings.setFuzzyMatch(fuzzy); } | ||
//this.hitClicked = function(docid, position) { sendClickHit(this.sitekey, this.settings.getSettings().keyword, docid, position); } | ||
// Deprecated | ||
this.useFuzzyMatch = function(use) { this.settings.setFuzzyMatch(use); } | ||
} | ||
module.exports = client; |
@@ -7,3 +7,3 @@ 'use strict'; | ||
callback: null, | ||
fuzzy: true, | ||
fuzzy: 'auto', | ||
paging: { | ||
@@ -48,3 +48,6 @@ page: 1, | ||
this.useFuzzyMatch = function(fuzzy) { | ||
this.setFuzzyMatch = function(fuzzy) { | ||
if (fuzzy !== true && fuzzy !== false && fuzzy !== 'auto') { | ||
throw "fuzzy matching can be true, false, or 'auto'"; | ||
} | ||
this.settings.fuzzy = fuzzy; | ||
@@ -51,0 +54,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48256
479
222