diff --git a/packages/utils/browser.js b/packages/utils/browser.js index 62a6e0473fc60c3681039482333fede26127b6b0..7378b780fa5af2fb187a919c9d23bb076a7c15d6 100644 --- a/packages/utils/browser.js +++ b/packages/utils/browser.js @@ -1,2 +1,2 @@ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t=t||self).jsonqlUtils={})}(this,(function(t){"use strict";var r=Array.isArray,e="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},n="object"==typeof e&&e&&e.Object===Object&&e,o="object"==typeof self&&self&&self.Object===Object&&self,u=n||o||Function("return this")(),i=u.Symbol,a=Object.prototype,c=a.hasOwnProperty,f=a.toString,s=i?i.toStringTag:void 0;var l=Object.prototype.toString;var p=i?i.toStringTag:void 0;function v(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":p&&p in Object(t)?function(t){var r=c.call(t,s),e=t[s];try{t[s]=void 0;var n=!0}catch(t){}var o=f.call(t);return n&&(r?t[s]=e:delete t[s]),o}(t):function(t){return l.call(t)}(t)}var d,y,h=(d=Object.getPrototypeOf,y=Object,function(t){return d(y(t))});function g(t){return null!=t&&"object"==typeof t}var b=Function.prototype,_=Object.prototype,j=b.toString,m=_.hasOwnProperty,O=j.call(Object);function w(t){if(!g(t)||"[object Object]"!=v(t))return!1;var r=h(t);if(null===r)return!0;var e=m.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&j.call(e)==O}var S=i?i.prototype:void 0,P=S?S.toString:void 0;function A(t){if("string"==typeof t)return t;if(r(t))return function(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var u=Array(o);++n-1;);return e}(o,u),function(t,r){for(var e=t.length;e--&&T(r,t[e],0)>-1;);return e}(o,u)+1).join("")}var Q=function(t,r){return!!t.filter((function(t){return t===r})).length},G=function(t){return r(t)?t:[t]},L=function(t,r){void 0===r&&(r=!0);try{return JSON.parse(t)}catch(e){if(r)return t;throw new Error(e)}},V=function(t,r){try{var e=Object.keys(t);return Q(e,r)}catch(t){return!1}};function H(t,r){return t===r||t!=t&&r!=r}function K(t,r){for(var e=t.length;e--;)if(H(t[e][0],r))return e;return-1}var W=Array.prototype.splice;function Z(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1},Z.prototype.set=function(t,r){var e=this.__data__,n=K(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};function Y(t){if(!X(t))return!1;var r=v(t);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}var tt,rt=u["__core-js_shared__"],et=(tt=/[^.]+$/.exec(rt&&rt.keys&&rt.keys.IE_PROTO||""))?"Symbol(src)_1."+tt:"";var nt=Function.prototype.toString;var ot=/^\[object .+?Constructor\]$/,ut=Function.prototype,it=Object.prototype,at=ut.toString,ct=it.hasOwnProperty,ft=RegExp("^"+at.call(ct).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function st(t){return!(!X(t)||function(t){return!!et&&et in t}(t))&&(Y(t)?ft:ot).test(function(t){if(null!=t){try{return nt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function lt(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return st(e)?e:void 0}var pt=lt(u,"Map"),vt=lt(Object,"create");var dt=Object.prototype.hasOwnProperty;var yt=Object.prototype.hasOwnProperty;function ht(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1&&t%1==0&&t<=9007199254740991}function Dt(t){return null!=t&&Bt(t.length)&&!Y(t)}var $t="object"==typeof t&&t&&!t.nodeType&&t,It=$t&&"object"==typeof module&&module&&!module.nodeType&&module,Qt=It&&It.exports===$t?u.Buffer:void 0,Gt=(Qt?Qt.isBuffer:void 0)||function(){return!1},Lt={};Lt["[object Float32Array]"]=Lt["[object Float64Array]"]=Lt["[object Int8Array]"]=Lt["[object Int16Array]"]=Lt["[object Int32Array]"]=Lt["[object Uint8Array]"]=Lt["[object Uint8ClampedArray]"]=Lt["[object Uint16Array]"]=Lt["[object Uint32Array]"]=!0,Lt["[object Arguments]"]=Lt["[object Array]"]=Lt["[object ArrayBuffer]"]=Lt["[object Boolean]"]=Lt["[object DataView]"]=Lt["[object Date]"]=Lt["[object Error]"]=Lt["[object Function]"]=Lt["[object Map]"]=Lt["[object Number]"]=Lt["[object Object]"]=Lt["[object RegExp]"]=Lt["[object Set]"]=Lt["[object String]"]=Lt["[object WeakMap]"]=!1;var Vt="object"==typeof t&&t&&!t.nodeType&&t,Ht=Vt&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Ht&&Ht.exports===Vt&&n.process,Wt=function(){try{var t=Ht&&Ht.require&&Ht.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Zt=Wt&&Wt.isTypedArray,Xt=Zt?function(t){return function(r){return t(r)}}(Zt):function(t){return g(t)&&Bt(t.length)&&!!Lt[v(t)]};function Yt(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var tr=Object.prototype.hasOwnProperty;function rr(t,r,e){var n=t[r];tr.call(t,r)&&H(n,e)&&(void 0!==e||r in t)||mt(t,r,e)}var er=/^(?:0|[1-9]\d*)$/;function nr(t,r){var e=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==e||"symbol"!=e&&er.test(t))&&t>-1&&t%1==0&&t0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(yr);function br(t,r){return gr(function(t,r,e){return r=dr(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,u=dr(n.length-r,0),i=Array(u);++o1?r[n-1]:void 0,u=n>2?r[2]:void 0;for(o=_r.length>3&&"function"==typeof o?(n--,o):void 0,u&&function(t,r,e){if(!X(e))return!1;var n=typeof r;return!!("number"==n?Dt(e)&&nr(r,e.length):"string"==n&&r in e)&&H(e[r],t)}(r[0],r[1],u)&&(o=n<3?void 0:o,n=1),t=Object(t);++e0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return Reflect.apply(r,null,G(t))}),Reflect.apply(t,null,e))}},t.chainProcessPromises=function(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return t.then((function(t){return r(t)}))}),Reflect.apply(t,null,e))}},t.chainPromises=function(t,r){return void 0===r&&(r=!1),t.reduce((function(t,e){return t.then((function(t){return e.then((function(e){return!1===r?t.concat([e]):jr(t,e)}))}))}),Promise.resolve(!1===r?[]:w(r)?r:{}))},t.createEvt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return t.join("_")},t.createMutation=qr,t.createMutationStr=function(t,r,e,n){return void 0===e&&(e={}),void 0===n&&(n=!1),JSON.stringify(qr(t,r,e,n))},t.createQuery=Cr,t.createQueryStr=function(t,r,e){return void 0===r&&(r=[]),void 0===e&&(e=!1),JSON.stringify(Cr(t,r,e))},t.dasherize=function(t){return I(t).replace(/([A-Z])/g,"-$1").replace(/[-_\s]+/g,"-").toLowerCase()},t.extractArgsFromPayload=function(t,r){switch(r){case"query":return t.args;case"mutation":return[t.payload,t.condition];default:throw new Pr("Unknown "+r+" to extract argument from!")}},t.extractParamsFromContract=function(t,r,e){try{var n=t[r][e];if(!n)throw new wr(e,r);return n}catch(t){throw new wr(e,t)}},t.extractSocketPart=Ar,t.formatPayload=kr,t.getCallMethod=function(t){switch(!0){case t===Or[0]:return"query";case t===Or[1]:return"mutation";default:return!1}},t.getConfigValue=function(t,r){return r&&w(r)&&t in r?r[t]:void 0},t.getLogger=function(t){var r=[t];return function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.JSONQL_DEBUG&&Reflect.apply(console.info,console,r.concat(t))}catch(t){}}},t.getMutationFromArgs=Br,t.getMutationFromPayload=function(t){var r=Ur(t,Br);if(!1!==r)return r;throw new Sr("[getMutationArgs] Payload is malformed!",t)},t.getNameFromPayload=Rr,t.getNamespace=Ir,t.getNamespaceInOrder=function(t,r){var e=[];for(var n in t)n===r?e[1]=n:e[0]=n;return e},t.getNspInfoByConfig=function(t){var r=t.contract;if(t.enableAuth)return $r(r);var e=Ir(t);return function(t,r){var e,n={};for(var o in t){var u=t[o];n[o]=u}return{size:1,nspGroup:(e={},e[r]=n,e),publicNamespace:r}}(r.socket,e[0])},t.getQueryFromArgs=Mr,t.getQueryFromPayload=function(t){var r=Ur(t,Mr);if(!1!==r)return r;throw new Sr("[getQueryArgs] Payload is malformed!",t)},t.getRegex=function(t){switch(!0){case!0===Qr(t):return t;case!0===xr(t):return new RegExp(t);default:return!1}},t.groupByNamespace=$r,t.inArray=Q,t.injectToFn=function(t,r,e,n){void 0===n&&(n=!1);var o=mr(t,r);return!1===n&&void 0!==o||Object.defineProperty(t,r,{value:e,writable:n}),t},t.isContract=function(t){return!!function(t){return w(t)&&(V(t,"query")||V(t,"mutation")||V(t,"socket"))}(t)&&t},t.isFunc=function(t){if("function"==typeof t)return!0;console.error("Expect to be Function type! Got "+typeof t)},t.isJsonqlErrorObj=Dr,t.isNotEmpty=function(t){return void 0!==t&&!1!==t&&null!==t&&""!==I(t)},t.isObjectHasKey=V,t.isRegExp=Qr,t.logger=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{window&&window.DEBUG&&Reflect.apply(console.log,console,t)}catch(t){}},t.nil=function(){return!1},t.objDefineProps=function(t,r,e,n){return void 0===n&&(n=null),void 0===Object.getOwnPropertyDescriptor(t,r)&&Object.defineProperty(t,r,{set:e,get:null===n?function(){return null}:n}),t},t.objHasProp=mr,t.packError=function(t,r,e,n){var o;void 0===r&&(r="JsonqlError"),void 0===e&&(e=0),void 0===n&&(n="");var u={detail:t,className:r,statusCode:e,message:n};return JSON.stringify(((o={}).error=Dr(t)||u,o.TS=[Nr()],o))},t.packResult=function(t,e){void 0===e&&(e=!1);var n={};return n.data=t,e&&r(e)&&(e.push(Nr()),n.TS=e),JSON.stringify(n)},t.parseJson=L,t.resultHandler=function(t){return V(t,"data")&&!V(t,"error")?t.data:t},t.timestamp=Nr,t.toArray=G,t.toJson=function(t){return L("string"==typeof t?t:JSON.stringify(t))},t.toPayload=Fr,t.urlParams=Er,Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t=t||self).jsonqlUtils={})}(this,(function(t){"use strict";var r=Array.isArray,e="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},n="object"==typeof e&&e&&e.Object===Object&&e,o="object"==typeof self&&self&&self.Object===Object&&self,u=n||o||Function("return this")(),i=u.Symbol,a=Object.prototype,c=a.hasOwnProperty,f=a.toString,s=i?i.toStringTag:void 0;var l=Object.prototype.toString;var p=i?i.toStringTag:void 0;function v(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":p&&p in Object(t)?function(t){var r=c.call(t,s),e=t[s];try{t[s]=void 0;var n=!0}catch(t){}var o=f.call(t);return n&&(r?t[s]=e:delete t[s]),o}(t):function(t){return l.call(t)}(t)}var d,y,h=(d=Object.getPrototypeOf,y=Object,function(t){return d(y(t))});function g(t){return null!=t&&"object"==typeof t}var b=Function.prototype,_=Object.prototype,j=b.toString,m=_.hasOwnProperty,O=j.call(Object);function w(t){if(!g(t)||"[object Object]"!=v(t))return!1;var r=h(t);if(null===r)return!0;var e=m.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&j.call(e)==O}var S=i?i.prototype:void 0,P=S?S.toString:void 0;function A(t){if("string"==typeof t)return t;if(r(t))return function(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var u=Array(o);++n-1;);return e}(o,u),function(t,r){for(var e=t.length;e--&&T(r,t[e],0)>-1;);return e}(o,u)+1).join("")}var Q=function(t,r){return!!t.filter((function(t){return t===r})).length},G=function(t){return r(t)?t:[t]},L=function(t,r){void 0===r&&(r=!0);try{return JSON.parse(t)}catch(e){if(r)return t;throw new Error(e)}},V=function(t,r){try{var e=Object.keys(t);return Q(e,r)}catch(t){return!1}};function H(t,r){return t===r||t!=t&&r!=r}function K(t,r){for(var e=t.length;e--;)if(H(t[e][0],r))return e;return-1}var W=Array.prototype.splice;function Z(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1},Z.prototype.set=function(t,r){var e=this.__data__,n=K(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};function Y(t){if(!X(t))return!1;var r=v(t);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}var tt,rt=u["__core-js_shared__"],et=(tt=/[^.]+$/.exec(rt&&rt.keys&&rt.keys.IE_PROTO||""))?"Symbol(src)_1."+tt:"";var nt=Function.prototype.toString;var ot=/^\[object .+?Constructor\]$/,ut=Function.prototype,it=Object.prototype,at=ut.toString,ct=it.hasOwnProperty,ft=RegExp("^"+at.call(ct).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function st(t){return!(!X(t)||function(t){return!!et&&et in t}(t))&&(Y(t)?ft:ot).test(function(t){if(null!=t){try{return nt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function lt(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return st(e)?e:void 0}var pt=lt(u,"Map"),vt=lt(Object,"create");var dt=Object.prototype.hasOwnProperty;var yt=Object.prototype.hasOwnProperty;function ht(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1&&t%1==0&&t<=9007199254740991}function Dt(t){return null!=t&&Bt(t.length)&&!Y(t)}var $t="object"==typeof t&&t&&!t.nodeType&&t,It=$t&&"object"==typeof module&&module&&!module.nodeType&&module,Qt=It&&It.exports===$t?u.Buffer:void 0,Gt=(Qt?Qt.isBuffer:void 0)||function(){return!1},Lt={};Lt["[object Float32Array]"]=Lt["[object Float64Array]"]=Lt["[object Int8Array]"]=Lt["[object Int16Array]"]=Lt["[object Int32Array]"]=Lt["[object Uint8Array]"]=Lt["[object Uint8ClampedArray]"]=Lt["[object Uint16Array]"]=Lt["[object Uint32Array]"]=!0,Lt["[object Arguments]"]=Lt["[object Array]"]=Lt["[object ArrayBuffer]"]=Lt["[object Boolean]"]=Lt["[object DataView]"]=Lt["[object Date]"]=Lt["[object Error]"]=Lt["[object Function]"]=Lt["[object Map]"]=Lt["[object Number]"]=Lt["[object Object]"]=Lt["[object RegExp]"]=Lt["[object Set]"]=Lt["[object String]"]=Lt["[object WeakMap]"]=!1;var Vt="object"==typeof t&&t&&!t.nodeType&&t,Ht=Vt&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Ht&&Ht.exports===Vt&&n.process,Wt=function(){try{var t=Ht&&Ht.require&&Ht.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Zt=Wt&&Wt.isTypedArray,Xt=Zt?function(t){return function(r){return t(r)}}(Zt):function(t){return g(t)&&Bt(t.length)&&!!Lt[v(t)]};function Yt(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var tr=Object.prototype.hasOwnProperty;function rr(t,r,e){var n=t[r];tr.call(t,r)&&H(n,e)&&(void 0!==e||r in t)||mt(t,r,e)}var er=/^(?:0|[1-9]\d*)$/;function nr(t,r){var e=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==e||"symbol"!=e&&er.test(t))&&t>-1&&t%1==0&&t0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(yr);function br(t,r){return gr(function(t,r,e){return r=dr(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,u=dr(n.length-r,0),i=Array(u);++o1?r[n-1]:void 0,u=n>2?r[2]:void 0;for(o=_r.length>3&&"function"==typeof o?(n--,o):void 0,u&&function(t,r,e){if(!X(e))return!1;var n=typeof r;return!!("number"==n?Dt(e)&&nr(r,e.length):"string"==n&&r in e)&&H(e[r],t)}(r[0],r[1],u)&&(o=n<3?void 0:o,n=1),t=Object(t);++e0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return Reflect.apply(r,null,G(t))}),Reflect.apply(t,null,e))}},t.chainProcessPromises=function(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return t.then((function(t){return r(t)}))}),Reflect.apply(t,null,e))}},t.chainPromises=function(t,r){return void 0===r&&(r=!1),t.reduce((function(t,e){return t.then((function(t){return e.then((function(e){return!1===r?t.concat([e]):jr(t,e)}))}))}),Promise.resolve(!1===r?[]:w(r)?r:{}))},t.createEvt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return t.join("_")},t.createMutation=qr,t.createMutationStr=function(t,r,e,n){return void 0===e&&(e={}),void 0===n&&(n=!1),JSON.stringify(qr(t,r,e,n))},t.createQuery=Cr,t.createQueryStr=function(t,r,e){return void 0===r&&(r=[]),void 0===e&&(e=!1),JSON.stringify(Cr(t,r,e))},t.dasherize=function(t){return I(t).replace(/([A-Z])/g,"-$1").replace(/[-_\s]+/g,"-").toLowerCase()},t.extractArgsFromPayload=function(t,r){switch(r){case"query":return t.args;case"mutation":return[t.payload,t.condition];default:throw new Pr("Unknown "+r+" to extract argument from!")}},t.extractParamsFromContract=function(t,r,e){try{var n=t[r][e];if(!n)throw new wr(e,r);return n}catch(t){throw new wr(e,t)}},t.extractSocketPart=Ar,t.formatPayload=kr,t.getCallMethod=function(t){switch(!0){case t===Or[0]:return"query";case t===Or[1]:return"mutation";default:return!1}},t.getConfigValue=function(t,r){return r&&w(r)&&t in r?r[t]:void 0},t.getLogger=function(t){var r=[t];return function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.JSONQL_DEBUG&&Reflect.apply(console.info,console,r.concat(t))}catch(t){}}},t.getMutationFromArgs=Br,t.getMutationFromPayload=function(t){var r=Ur(t,Br);if(!1!==r)return r;throw new Sr("[getMutationArgs] Payload is malformed!",t)},t.getNameFromPayload=Rr,t.getNamespace=Ir,t.getNamespaceInOrder=function(t,r){var e=[];for(var n in t)n===r?e[1]=n:e[0]=n;return e},t.getNspInfoByConfig=function(t){var r=t.contract,e=t.enableAuth,n=Ir(t),o=e?$r(r):function(t,r){var e,n={};for(var o in t){var u=t[o];n[o]=u}return{size:1,nspGroup:(e={},e[r]=n,e),publicNamespace:r}}(r.socket,n[0]);return Object.assign(o,{namespaces:n})},t.getQueryFromArgs=Mr,t.getQueryFromPayload=function(t){var r=Ur(t,Mr);if(!1!==r)return r;throw new Sr("[getQueryArgs] Payload is malformed!",t)},t.getRegex=function(t){switch(!0){case!0===Qr(t):return t;case!0===xr(t):return new RegExp(t);default:return!1}},t.groupByNamespace=$r,t.inArray=Q,t.injectToFn=function(t,r,e,n){void 0===n&&(n=!1);var o=mr(t,r);return!1===n&&void 0!==o||Object.defineProperty(t,r,{value:e,writable:n}),t},t.isContract=function(t){return!!function(t){return w(t)&&(V(t,"query")||V(t,"mutation")||V(t,"socket"))}(t)&&t},t.isFunc=function(t){if("function"==typeof t)return!0;console.error("Expect to be Function type! Got "+typeof t)},t.isJsonqlErrorObj=Dr,t.isNotEmpty=function(t){return void 0!==t&&!1!==t&&null!==t&&""!==I(t)},t.isObjectHasKey=V,t.isRegExp=Qr,t.logger=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{window&&window.DEBUG&&Reflect.apply(console.log,console,t)}catch(t){}},t.nil=function(){return!1},t.objDefineProps=function(t,r,e,n){return void 0===n&&(n=null),void 0===Object.getOwnPropertyDescriptor(t,r)&&Object.defineProperty(t,r,{set:e,get:null===n?function(){return null}:n}),t},t.objHasProp=mr,t.packError=function(t,r,e,n){var o;void 0===r&&(r="JsonqlError"),void 0===e&&(e=0),void 0===n&&(n="");var u={detail:t,className:r,statusCode:e,message:n};return JSON.stringify(((o={}).error=Dr(t)||u,o.TS=[Nr()],o))},t.packResult=function(t,e){void 0===e&&(e=!1);var n={};return n.data=t,e&&r(e)&&(e.push(Nr()),n.TS=e),JSON.stringify(n)},t.parseJson=L,t.resultHandler=function(t){return V(t,"data")&&!V(t,"error")?t.data:t},t.timestamp=Nr,t.toArray=G,t.toJson=function(t){return L("string"==typeof t?t:JSON.stringify(t))},t.toPayload=Fr,t.urlParams=Er,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=browser.js.map diff --git a/packages/utils/main.js b/packages/utils/main.js index a573fdc47b60a392df91b8a1e615920f0102f4ce..74b71daa90de52def237f8e67ae2ccfc4398e41d 100644 --- a/packages/utils/main.js +++ b/packages/utils/main.js @@ -1,2 +1,2 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,r=(t=require("fs"))&&"object"==typeof t&&"default"in t?t.default:t,e=require("path"),n=Array.isArray,o="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},i="object"==typeof o&&o&&o.Object===Object&&o,u="object"==typeof self&&self&&self.Object===Object&&self,a=i||u||Function("return this")(),f=a.Symbol,s=Object.prototype,c=s.hasOwnProperty,h=s.toString,p=f?f.toStringTag:void 0;var l=Object.prototype.toString;var g=f?f.toStringTag:void 0;function y(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":g&&g in Object(t)?function(t){var r=c.call(t,p),e=t[p];try{t[p]=void 0;var n=!0}catch(t){}var o=h.call(t);return n&&(r?t[p]=e:delete t[p]),o}(t):function(t){return l.call(t)}(t)}var v,d,b=(v=Object.getPrototypeOf,d=Object,function(t){return v(d(t))});function w(t){return null!=t&&"object"==typeof t}var _=Function.prototype,m=Object.prototype,A=_.toString,E=m.hasOwnProperty,j=A.call(Object);function x(t){if(!w(t)||"[object Object]"!=y(t))return!1;var r=b(t);if(null===r)return!0;var e=E.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&A.call(e)==j}var P=f?f.prototype:void 0,R=P?P.toString:void 0;function O(t){if("string"==typeof t)return t;if(n(t))return function(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var i=Array(o);++n-1;);return e}(o,i),function(t,r){for(var e=t.length;e--&&U(r,t[e],0)>-1;);return e}(o,i)+1).join("")}var Q=function(t,r){return!!t.filter((function(t){return t===r})).length},V=function(t){return n(t)?t:[t]},G=function(t,r){void 0===r&&(r=!0);try{return JSON.parse(t)}catch(e){if(r)return t;throw new Error(e)}},H=function(t,r){try{var e=Object.keys(t);return Q(e,r)}catch(t){return!1}};function Z(t,r){return t===r||t!=t&&r!=r}function K(t,r){for(var e=t.length;e--;)if(Z(t[e][0],r))return e;return-1}var W=Array.prototype.splice;function X(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1},X.prototype.set=function(t,r){var e=this.__data__,n=K(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};function rt(t){if(!tt(t))return!1;var r=y(t);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}var et,nt=a["__core-js_shared__"],ot=(et=/[^.]+$/.exec(nt&&nt.keys&&nt.keys.IE_PROTO||""))?"Symbol(src)_1."+et:"";var it=Function.prototype.toString;var ut=/^\[object .+?Constructor\]$/,at=Function.prototype,ft=Object.prototype,st=at.toString,ct=ft.hasOwnProperty,ht=RegExp("^"+st.call(ct).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function pt(t){return!(!tt(t)||function(t){return!!ot&&ot in t}(t))&&(rt(t)?ht:ut).test(function(t){if(null!=t){try{return it.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function lt(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return pt(e)?e:void 0}var gt=lt(a,"Map"),yt=lt(Object,"create");var vt=Object.prototype.hasOwnProperty;var dt=Object.prototype.hasOwnProperty;function bt(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1&&t%1==0&&t<=9007199254740991}function qt(t){return null!=t&&Ft(t.length)&&!rt(t)}var Jt="object"==typeof exports&&exports&&!exports.nodeType&&exports,$t=Jt&&"object"==typeof module&&module&&!module.nodeType&&module,Qt=$t&&$t.exports===Jt?a.Buffer:void 0,Vt=(Qt?Qt.isBuffer:void 0)||function(){return!1},Gt={};Gt["[object Float32Array]"]=Gt["[object Float64Array]"]=Gt["[object Int8Array]"]=Gt["[object Int16Array]"]=Gt["[object Int32Array]"]=Gt["[object Uint8Array]"]=Gt["[object Uint8ClampedArray]"]=Gt["[object Uint16Array]"]=Gt["[object Uint32Array]"]=!0,Gt["[object Arguments]"]=Gt["[object Array]"]=Gt["[object ArrayBuffer]"]=Gt["[object Boolean]"]=Gt["[object DataView]"]=Gt["[object Date]"]=Gt["[object Error]"]=Gt["[object Function]"]=Gt["[object Map]"]=Gt["[object Number]"]=Gt["[object Object]"]=Gt["[object RegExp]"]=Gt["[object Set]"]=Gt["[object String]"]=Gt["[object WeakMap]"]=!1;var Ht="object"==typeof exports&&exports&&!exports.nodeType&&exports,Zt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Zt&&Zt.exports===Ht&&i.process,Wt=function(){try{var t=Zt&&Zt.require&&Zt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Xt=Wt&&Wt.isTypedArray,tr=Xt?function(t){return function(r){return t(r)}}(Xt):function(t){return w(t)&&Ft(t.length)&&!!Gt[y(t)]};function rr(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var er=Object.prototype.hasOwnProperty;function nr(t,r,e){var n=t[r];er.call(t,r)&&Z(n,e)&&(void 0!==e||r in t)||Et(t,r,e)}var or=/^(?:0|[1-9]\d*)$/;function ir(t,r){var e=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==e||"symbol"!=e&&or.test(t))&&t>-1&&t%1==0&&t0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(dr);function _r(t,r){return wr(function(t,r,e){return r=vr(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,i=vr(n.length-r,0),u=Array(i);++o1?r[n-1]:void 0,i=n>2?r[2]:void 0;for(o=mr.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,r,e){if(!tt(e))return!1;var n=typeof r;return!!("number"==n?qt(e)&&ir(r,e.length):"string"==n&&r in e)&&Z(e[r],t)}(r[0],r[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++e>18&63]+Zr[o>>12&63]+Zr[o>>6&63]+Zr[63&o]);return i.join("")}function ee(t){var r;Xr||te();for(var e=t.length,n=e%3,o="",i=[],u=0,a=e-n;ua?a:u+16383));return 1===n?(r=t[e-1],o+=Zr[r>>2],o+=Zr[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=Zr[r>>10],o+=Zr[r>>4&63],o+=Zr[r<<2&63],o+="="),i.push(o),i.join("")}function ne(t,r,e,n,o){var i,u,a=8*o-n-1,f=(1<>1,c=-7,h=e?o-1:0,p=e?-1:1,l=t[r+h];for(h+=p,i=l&(1<<-c)-1,l>>=-c,c+=a;c>0;i=256*i+t[r+h],h+=p,c-=8);for(u=i&(1<<-c)-1,i>>=-c,c+=n;c>0;u=256*u+t[r+h],h+=p,c-=8);if(0===i)i=1-s;else{if(i===f)return u?NaN:1/0*(l?-1:1);u+=Math.pow(2,n),i-=s}return(l?-1:1)*u*Math.pow(2,i-n)}function oe(t,r,e,n,o,i){var u,a,f,s=8*i-o-1,c=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:i-1,g=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,u=c):(u=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-u))<1&&(u--,f*=2),(r+=u+h>=1?p/f:p*Math.pow(2,1-h))*f>=2&&(u++,f/=2),u+h>=c?(a=0,u=c):u+h>=1?(a=(r*f-1)*Math.pow(2,o),u+=h):(a=r*Math.pow(2,h-1)*Math.pow(2,o),u=0));o>=8;t[e+l]=255&a,l+=g,a/=256,o-=8);for(u=u<0;t[e+l]=255&u,l+=g,u/=256,s-=8);t[e+l-g]|=128*y}var ie={}.toString,ue=Array.isArray||function(t){return"[object Array]"==ie.call(t)};function ae(){return se.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function fe(t,r){if(ae()=ae())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ae().toString(16)+" bytes");return 0|t}function ye(t){return!(null==t||!t._isBuffer)}function ve(t,r){if(ye(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return Fe(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return qe(t).length;default:if(n)return Fe(t).length;r=(""+r).toLowerCase(),n=!0}}function de(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return Ue(this,r,e);case"utf8":case"utf-8":return Oe(this,r,e);case"ascii":return Te(this,r,e);case"latin1":case"binary":return Se(this,r,e);case"base64":return Re(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Be(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function be(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function we(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=se.from(r,n)),ye(r))return 0===r.length?-1:_e(t,r,e,n,o);if("number"==typeof r)return r&=255,se.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):_e(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function _e(t,r,e,n,o){var i,u=1,a=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u=2,a/=2,f/=2,e/=2}function s(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(o){var c=-1;for(i=e;ia&&(e=a-f),i=e;i>=0;i--){for(var h=!0,p=0;po&&(n=o):n=o;var i=r.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var u=0;u>8,o=e%256,i.push(o),i.push(n);return i}(r,t.length-e),t,e,n)}function Re(t,r,e){return 0===r&&e===t.length?ee(t):ee(t.slice(r,e))}function Oe(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o239?4:s>223?3:s>191?2:1;if(o+h<=e)switch(h){case 1:s<128&&(c=s);break;case 2:128==(192&(i=t[o+1]))&&(f=(31&s)<<6|63&i)>127&&(c=f);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(f=(15&s)<<12|(63&i)<<6|63&u)>2047&&(f<55296||f>57343)&&(c=f);break;case 4:i=t[o+1],u=t[o+2],a=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&a)&&(f=(15&s)<<18|(63&i)<<12|(63&u)<<6|63&a)>65535&&f<1114112&&(c=f)}null===c?(c=65533,h=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=h}return function(t){var r=t.length;if(r<=4096)return String.fromCharCode.apply(String,t);var e="",n=0;for(;n0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),""},se.prototype.compare=function(t,r,e,n,o){if(!ye(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&r>=e)return 0;if(n>=o)return-1;if(r>=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),u=(e>>>=0)-(r>>>=0),a=Math.min(i,u),f=this.slice(n,o),s=t.slice(r,e),c=0;co)&&(e=o),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return me(this,t,r,e);case"utf8":case"utf-8":return Ae(this,t,r,e);case"ascii":return Ee(this,t,r,e);case"latin1":case"binary":return je(this,t,r,e);case"base64":return xe(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pe(this,t,r,e);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},se.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Te(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;on)&&(e=n);for(var o="",i=r;ie)throw new RangeError("Trying to access beyond buffer length")}function Ie(t,r,e,n,o,i){if(!ye(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||rt.length)throw new RangeError("Index out of range")}function Ce(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o>>8*(n?o:1-o)}function Ye(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o>>8*(n?o:3-o)&255}function Me(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ke(t,r,e,n,o){return o||Me(t,0,e,4),oe(t,r,e,n,23,4),e+4}function De(t,r,e,n,o){return o||Me(t,0,e,8),oe(t,r,e,n,52,8),e+8}se.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r0&&(o*=256);)n+=this[t+--r]*o;return n},se.prototype.readUInt8=function(t,r){return r||Ne(t,1,this.length),this[t]},se.prototype.readUInt16LE=function(t,r){return r||Ne(t,2,this.length),this[t]|this[t+1]<<8},se.prototype.readUInt16BE=function(t,r){return r||Ne(t,2,this.length),this[t]<<8|this[t+1]},se.prototype.readUInt32LE=function(t,r){return r||Ne(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},se.prototype.readUInt32BE=function(t,r){return r||Ne(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},se.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||Ne(t,r,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*r)),n},se.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||Ne(t,r,this.length);for(var n=r,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*r)),i},se.prototype.readInt8=function(t,r){return r||Ne(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},se.prototype.readInt16LE=function(t,r){r||Ne(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},se.prototype.readInt16BE=function(t,r){r||Ne(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},se.prototype.readInt32LE=function(t,r){return r||Ne(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},se.prototype.readInt32BE=function(t,r){return r||Ne(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},se.prototype.readFloatLE=function(t,r){return r||Ne(t,4,this.length),ne(this,t,!0,23,4)},se.prototype.readFloatBE=function(t,r){return r||Ne(t,4,this.length),ne(this,t,!1,23,4)},se.prototype.readDoubleLE=function(t,r){return r||Ne(t,8,this.length),ne(this,t,!0,52,8)},se.prototype.readDoubleBE=function(t,r){return r||Ne(t,8,this.length),ne(this,t,!1,52,8)},se.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||Ie(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i=0&&(i*=256);)this[r+o]=t/i&255;return r+e},se.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,1,255,0),se.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},se.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,2,65535,0),se.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):Ce(this,t,r,!0),r+2},se.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,2,65535,0),se.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):Ce(this,t,r,!1),r+2},se.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,4,4294967295,0),se.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):Ye(this,t,r,!0),r+4},se.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,4,4294967295,0),se.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):Ye(this,t,r,!1),r+4},se.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);Ie(this,t,r,e,o-1,-o)}var i=0,u=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},se.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);Ie(this,t,r,e,o-1,-o)}var i=e-1,u=1,a=0;for(this[r+i]=255&t;--i>=0&&(u*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/u>>0)-a&255;return r+e},se.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,1,127,-128),se.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},se.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,2,32767,-32768),se.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):Ce(this,t,r,!0),r+2},se.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,2,32767,-32768),se.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):Ce(this,t,r,!1),r+2},se.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,4,2147483647,-2147483648),se.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):Ye(this,t,r,!0),r+4},se.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),se.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):Ye(this,t,r,!1),r+4},se.prototype.writeFloatLE=function(t,r,e){return ke(this,t,r,!0,e)},se.prototype.writeFloatBE=function(t,r,e){return ke(this,t,r,!1,e)},se.prototype.writeDoubleLE=function(t,r,e){return De(this,t,r,!0,e)},se.prototype.writeDoubleBE=function(t,r,e){return De(this,t,r,!1,e)},se.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r=0;--o)t[o+r]=this[o+e];else if(i<1e3||!se.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function qe(t){return function(t){var r,e,n,o,i,u;Xr||te();var a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===t[a-2]?2:"="===t[a-1]?1:0,u=new Wr(3*a/4-i),n=i>0?a-4:a;var f=0;for(r=0,e=0;r>16&255,u[f++]=o>>8&255,u[f++]=255&o;return 2===i?(o=Kr[t.charCodeAt(r)]<<2|Kr[t.charCodeAt(r+1)]>>4,u[f++]=255&o):1===i&&(o=Kr[t.charCodeAt(r)]<<10|Kr[t.charCodeAt(r+1)]<<4|Kr[t.charCodeAt(r+2)]>>2,u[f++]=o>>8&255,u[f++]=255&o),u}(function(t){if((t=function(t){if(t.trim)return t.trim();return t.replace(/^\s+|\s+$/g,"")}(t).replace(Le,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Je(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function $e(t){return null!=t&&(!!t._isBuffer||Qe(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Qe(t.slice(0,0))}(t))}function Qe(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var Ve=function(t,r){if(r instanceof Error){var e={};return Object.getOwnPropertyNames(r).forEach((function(t){e[t]=r[t]})),e}return r};var Ge=function(t,r){try{var e=t.headers.accept.split(",");return r?e.filter((function(t){return t===r})):e}catch(t){return[]}},He=function(t,r){return!!Ge(t,r).length},Ze=function(t,r){return t.path===r.jsonqlPath};exports.VERSION="1.0.5",exports.buff=function(t,r){return void 0===r&&(r="base64"),$e(t)?t:new se.from(t,r)},exports.cacheBurst=Ir,exports.cacheBurstUrl=function(t){return Nr(t,Ir())},exports.chainFns=function(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return Reflect.apply(r,null,V(t))}),Reflect.apply(t,null,e))}},exports.chainPromises=function(t,r){return void 0===r&&(r=!1),t.reduce((function(t,e){return t.then((function(t){return e.then((function(e){return!1===r?t.concat([e]):Ar(t,e)}))}))}),Promise.resolve(!1===r?[]:x(r)?r:{}))},exports.createEvt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return t.join("_")},exports.createMutation=Fr,exports.createMutationStr=function(t,r,e,n){return void 0===e&&(e={}),void 0===n&&(n=!1),JSON.stringify(Fr(t,r,e,n))},exports.createQuery=zr,exports.createQueryStr=function(t,r,e){return void 0===r&&(r=[]),void 0===e&&(e=!1),JSON.stringify(zr(t,r,e))},exports.dasherize=Br,exports.extractArgsFromPayload=function(t,r){switch(r){case"query":return t.args;case"mutation":return[t.payload,t.condition];default:throw new Tr("Unknown "+r+" to extract argument from!")}},exports.extractParamsFromContract=function(t,r,e){try{var n=t[r][e];if(!n)throw new Rr(e,r);return n}catch(t){throw new Rr(e,t)}},exports.extractSocketPart=Sr,exports.findFromContract=function(t,e,n){return!!(n[t]&&n[t][e]&&n[t][e].file&&r.existsSync(n[t][e].file))&&n[t][e].file},exports.formatPayload=kr,exports.getCallMethod=function(t){switch(!0){case t===xr[0]:return"query";case t===xr[1]:return"mutation";default:return!1}},exports.getConfigValue=function(t,r){return r&&x(r)&&t in r?r[t]:void 0},exports.getDocLen=function(t){return se.byteLength(t,"utf8")},exports.getMutationFromArgs=$r,exports.getMutationFromPayload=function(t){var r=Jr(t,$r);if(!1!==r)return r;throw new Or("[getMutationArgs] Payload is malformed!",t)},exports.getNameFromPayload=Dr,exports.getNamespace=Gr,exports.getNamespaceInOrder=function(t,r){var e=[];for(var n in t)n===r?e[1]=n:e[0]=n;return e},exports.getNspInfoByConfig=function(t){var r=t.contract;if(t.enableAuth)return Vr(r);var e=Gr(t);return function(t,r){var e,n={};for(var o in t){var i=t[o];n[o]=i}return{size:1,nspGroup:(e={},e[r]=n,e),publicNamespace:r}}(r.socket,e[0])},exports.getPathToFn=function(t,n,o){var i=o.resolverDir,u=Br(t),a=[];o.contract&&o.contract[n]&&o.contract[n].path&&a.push(o.contract[n].path),a.push(e.join(i,n,u,[Pr,jr].join("."))),a.push(e.join(i,n,[u,jr].join(".")));for(var f=a.length,s=0;s=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var i=Array(o);++n-1;);return e}(o,i),function(t,r){for(var e=t.length;e--&&U(r,t[e],0)>-1;);return e}(o,i)+1).join("")}var Q=function(t,r){return!!t.filter((function(t){return t===r})).length},V=function(t){return n(t)?t:[t]},G=function(t,r){void 0===r&&(r=!0);try{return JSON.parse(t)}catch(e){if(r)return t;throw new Error(e)}},H=function(t,r){try{var e=Object.keys(t);return Q(e,r)}catch(t){return!1}};function Z(t,r){return t===r||t!=t&&r!=r}function K(t,r){for(var e=t.length;e--;)if(Z(t[e][0],r))return e;return-1}var W=Array.prototype.splice;function X(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1},X.prototype.set=function(t,r){var e=this.__data__,n=K(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};function rt(t){if(!tt(t))return!1;var r=y(t);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}var et,nt=a["__core-js_shared__"],ot=(et=/[^.]+$/.exec(nt&&nt.keys&&nt.keys.IE_PROTO||""))?"Symbol(src)_1."+et:"";var it=Function.prototype.toString;var ut=/^\[object .+?Constructor\]$/,at=Function.prototype,ft=Object.prototype,st=at.toString,ct=ft.hasOwnProperty,ht=RegExp("^"+st.call(ct).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function pt(t){return!(!tt(t)||function(t){return!!ot&&ot in t}(t))&&(rt(t)?ht:ut).test(function(t){if(null!=t){try{return it.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function lt(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return pt(e)?e:void 0}var gt=lt(a,"Map"),yt=lt(Object,"create");var vt=Object.prototype.hasOwnProperty;var dt=Object.prototype.hasOwnProperty;function bt(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1&&t%1==0&&t<=9007199254740991}function qt(t){return null!=t&&Ft(t.length)&&!rt(t)}var Jt="object"==typeof exports&&exports&&!exports.nodeType&&exports,$t=Jt&&"object"==typeof module&&module&&!module.nodeType&&module,Qt=$t&&$t.exports===Jt?a.Buffer:void 0,Vt=(Qt?Qt.isBuffer:void 0)||function(){return!1},Gt={};Gt["[object Float32Array]"]=Gt["[object Float64Array]"]=Gt["[object Int8Array]"]=Gt["[object Int16Array]"]=Gt["[object Int32Array]"]=Gt["[object Uint8Array]"]=Gt["[object Uint8ClampedArray]"]=Gt["[object Uint16Array]"]=Gt["[object Uint32Array]"]=!0,Gt["[object Arguments]"]=Gt["[object Array]"]=Gt["[object ArrayBuffer]"]=Gt["[object Boolean]"]=Gt["[object DataView]"]=Gt["[object Date]"]=Gt["[object Error]"]=Gt["[object Function]"]=Gt["[object Map]"]=Gt["[object Number]"]=Gt["[object Object]"]=Gt["[object RegExp]"]=Gt["[object Set]"]=Gt["[object String]"]=Gt["[object WeakMap]"]=!1;var Ht="object"==typeof exports&&exports&&!exports.nodeType&&exports,Zt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Zt&&Zt.exports===Ht&&i.process,Wt=function(){try{var t=Zt&&Zt.require&&Zt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Xt=Wt&&Wt.isTypedArray,tr=Xt?function(t){return function(r){return t(r)}}(Xt):function(t){return w(t)&&Ft(t.length)&&!!Gt[y(t)]};function rr(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var er=Object.prototype.hasOwnProperty;function nr(t,r,e){var n=t[r];er.call(t,r)&&Z(n,e)&&(void 0!==e||r in t)||Et(t,r,e)}var or=/^(?:0|[1-9]\d*)$/;function ir(t,r){var e=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==e||"symbol"!=e&&or.test(t))&&t>-1&&t%1==0&&t0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(dr);function _r(t,r){return wr(function(t,r,e){return r=vr(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,i=vr(n.length-r,0),u=Array(i);++o1?r[n-1]:void 0,i=n>2?r[2]:void 0;for(o=mr.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,r,e){if(!tt(e))return!1;var n=typeof r;return!!("number"==n?qt(e)&&ir(r,e.length):"string"==n&&r in e)&&Z(e[r],t)}(r[0],r[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++e>18&63]+Zr[o>>12&63]+Zr[o>>6&63]+Zr[63&o]);return i.join("")}function ee(t){var r;Xr||te();for(var e=t.length,n=e%3,o="",i=[],u=0,a=e-n;ua?a:u+16383));return 1===n?(r=t[e-1],o+=Zr[r>>2],o+=Zr[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=Zr[r>>10],o+=Zr[r>>4&63],o+=Zr[r<<2&63],o+="="),i.push(o),i.join("")}function ne(t,r,e,n,o){var i,u,a=8*o-n-1,f=(1<>1,c=-7,h=e?o-1:0,p=e?-1:1,l=t[r+h];for(h+=p,i=l&(1<<-c)-1,l>>=-c,c+=a;c>0;i=256*i+t[r+h],h+=p,c-=8);for(u=i&(1<<-c)-1,i>>=-c,c+=n;c>0;u=256*u+t[r+h],h+=p,c-=8);if(0===i)i=1-s;else{if(i===f)return u?NaN:1/0*(l?-1:1);u+=Math.pow(2,n),i-=s}return(l?-1:1)*u*Math.pow(2,i-n)}function oe(t,r,e,n,o,i){var u,a,f,s=8*i-o-1,c=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:i-1,g=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,u=c):(u=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-u))<1&&(u--,f*=2),(r+=u+h>=1?p/f:p*Math.pow(2,1-h))*f>=2&&(u++,f/=2),u+h>=c?(a=0,u=c):u+h>=1?(a=(r*f-1)*Math.pow(2,o),u+=h):(a=r*Math.pow(2,h-1)*Math.pow(2,o),u=0));o>=8;t[e+l]=255&a,l+=g,a/=256,o-=8);for(u=u<0;t[e+l]=255&u,l+=g,u/=256,s-=8);t[e+l-g]|=128*y}var ie={}.toString,ue=Array.isArray||function(t){return"[object Array]"==ie.call(t)};function ae(){return se.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function fe(t,r){if(ae()=ae())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ae().toString(16)+" bytes");return 0|t}function ye(t){return!(null==t||!t._isBuffer)}function ve(t,r){if(ye(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return Fe(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return qe(t).length;default:if(n)return Fe(t).length;r=(""+r).toLowerCase(),n=!0}}function de(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return Ue(this,r,e);case"utf8":case"utf-8":return Re(this,r,e);case"ascii":return Te(this,r,e);case"latin1":case"binary":return Se(this,r,e);case"base64":return Oe(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Be(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function be(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function we(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=se.from(r,n)),ye(r))return 0===r.length?-1:_e(t,r,e,n,o);if("number"==typeof r)return r&=255,se.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):_e(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function _e(t,r,e,n,o){var i,u=1,a=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u=2,a/=2,f/=2,e/=2}function s(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(o){var c=-1;for(i=e;ia&&(e=a-f),i=e;i>=0;i--){for(var h=!0,p=0;po&&(n=o):n=o;var i=r.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var u=0;u>8,o=e%256,i.push(o),i.push(n);return i}(r,t.length-e),t,e,n)}function Oe(t,r,e){return 0===r&&e===t.length?ee(t):ee(t.slice(r,e))}function Re(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o239?4:s>223?3:s>191?2:1;if(o+h<=e)switch(h){case 1:s<128&&(c=s);break;case 2:128==(192&(i=t[o+1]))&&(f=(31&s)<<6|63&i)>127&&(c=f);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(f=(15&s)<<12|(63&i)<<6|63&u)>2047&&(f<55296||f>57343)&&(c=f);break;case 4:i=t[o+1],u=t[o+2],a=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&a)&&(f=(15&s)<<18|(63&i)<<12|(63&u)<<6|63&a)>65535&&f<1114112&&(c=f)}null===c?(c=65533,h=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=h}return function(t){var r=t.length;if(r<=4096)return String.fromCharCode.apply(String,t);var e="",n=0;for(;n0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),""},se.prototype.compare=function(t,r,e,n,o){if(!ye(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&r>=e)return 0;if(n>=o)return-1;if(r>=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),u=(e>>>=0)-(r>>>=0),a=Math.min(i,u),f=this.slice(n,o),s=t.slice(r,e),c=0;co)&&(e=o),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return me(this,t,r,e);case"utf8":case"utf-8":return Ae(this,t,r,e);case"ascii":return Ee(this,t,r,e);case"latin1":case"binary":return je(this,t,r,e);case"base64":return xe(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pe(this,t,r,e);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},se.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Te(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;on)&&(e=n);for(var o="",i=r;ie)throw new RangeError("Trying to access beyond buffer length")}function Ie(t,r,e,n,o,i){if(!ye(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||rt.length)throw new RangeError("Index out of range")}function Ce(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o>>8*(n?o:1-o)}function Ye(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o>>8*(n?o:3-o)&255}function Me(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ke(t,r,e,n,o){return o||Me(t,0,e,4),oe(t,r,e,n,23,4),e+4}function De(t,r,e,n,o){return o||Me(t,0,e,8),oe(t,r,e,n,52,8),e+8}se.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r0&&(o*=256);)n+=this[t+--r]*o;return n},se.prototype.readUInt8=function(t,r){return r||Ne(t,1,this.length),this[t]},se.prototype.readUInt16LE=function(t,r){return r||Ne(t,2,this.length),this[t]|this[t+1]<<8},se.prototype.readUInt16BE=function(t,r){return r||Ne(t,2,this.length),this[t]<<8|this[t+1]},se.prototype.readUInt32LE=function(t,r){return r||Ne(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},se.prototype.readUInt32BE=function(t,r){return r||Ne(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},se.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||Ne(t,r,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*r)),n},se.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||Ne(t,r,this.length);for(var n=r,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*r)),i},se.prototype.readInt8=function(t,r){return r||Ne(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},se.prototype.readInt16LE=function(t,r){r||Ne(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},se.prototype.readInt16BE=function(t,r){r||Ne(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},se.prototype.readInt32LE=function(t,r){return r||Ne(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},se.prototype.readInt32BE=function(t,r){return r||Ne(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},se.prototype.readFloatLE=function(t,r){return r||Ne(t,4,this.length),ne(this,t,!0,23,4)},se.prototype.readFloatBE=function(t,r){return r||Ne(t,4,this.length),ne(this,t,!1,23,4)},se.prototype.readDoubleLE=function(t,r){return r||Ne(t,8,this.length),ne(this,t,!0,52,8)},se.prototype.readDoubleBE=function(t,r){return r||Ne(t,8,this.length),ne(this,t,!1,52,8)},se.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||Ie(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i=0&&(i*=256);)this[r+o]=t/i&255;return r+e},se.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,1,255,0),se.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},se.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,2,65535,0),se.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):Ce(this,t,r,!0),r+2},se.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,2,65535,0),se.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):Ce(this,t,r,!1),r+2},se.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,4,4294967295,0),se.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):Ye(this,t,r,!0),r+4},se.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,4,4294967295,0),se.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):Ye(this,t,r,!1),r+4},se.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);Ie(this,t,r,e,o-1,-o)}var i=0,u=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},se.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);Ie(this,t,r,e,o-1,-o)}var i=e-1,u=1,a=0;for(this[r+i]=255&t;--i>=0&&(u*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/u>>0)-a&255;return r+e},se.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,1,127,-128),se.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},se.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,2,32767,-32768),se.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):Ce(this,t,r,!0),r+2},se.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,2,32767,-32768),se.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):Ce(this,t,r,!1),r+2},se.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,4,2147483647,-2147483648),se.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):Ye(this,t,r,!0),r+4},se.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||Ie(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),se.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):Ye(this,t,r,!1),r+4},se.prototype.writeFloatLE=function(t,r,e){return ke(this,t,r,!0,e)},se.prototype.writeFloatBE=function(t,r,e){return ke(this,t,r,!1,e)},se.prototype.writeDoubleLE=function(t,r,e){return De(this,t,r,!0,e)},se.prototype.writeDoubleBE=function(t,r,e){return De(this,t,r,!1,e)},se.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r=0;--o)t[o+r]=this[o+e];else if(i<1e3||!se.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function qe(t){return function(t){var r,e,n,o,i,u;Xr||te();var a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===t[a-2]?2:"="===t[a-1]?1:0,u=new Wr(3*a/4-i),n=i>0?a-4:a;var f=0;for(r=0,e=0;r>16&255,u[f++]=o>>8&255,u[f++]=255&o;return 2===i?(o=Kr[t.charCodeAt(r)]<<2|Kr[t.charCodeAt(r+1)]>>4,u[f++]=255&o):1===i&&(o=Kr[t.charCodeAt(r)]<<10|Kr[t.charCodeAt(r+1)]<<4|Kr[t.charCodeAt(r+2)]>>2,u[f++]=o>>8&255,u[f++]=255&o),u}(function(t){if((t=function(t){if(t.trim)return t.trim();return t.replace(/^\s+|\s+$/g,"")}(t).replace(Le,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Je(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function $e(t){return null!=t&&(!!t._isBuffer||Qe(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Qe(t.slice(0,0))}(t))}function Qe(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var Ve=function(t,r){if(r instanceof Error){var e={};return Object.getOwnPropertyNames(r).forEach((function(t){e[t]=r[t]})),e}return r};var Ge=function(t,r){try{var e=t.headers.accept.split(",");return r?e.filter((function(t){return t===r})):e}catch(t){return[]}},He=function(t,r){return!!Ge(t,r).length},Ze=function(t,r){return t.path===r.jsonqlPath};exports.VERSION="1.0.6",exports.buff=function(t,r){return void 0===r&&(r="base64"),$e(t)?t:new se.from(t,r)},exports.cacheBurst=Ir,exports.cacheBurstUrl=function(t){return Nr(t,Ir())},exports.chainFns=function(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return Reflect.apply(r,null,V(t))}),Reflect.apply(t,null,e))}},exports.chainPromises=function(t,r){return void 0===r&&(r=!1),t.reduce((function(t,e){return t.then((function(t){return e.then((function(e){return!1===r?t.concat([e]):Ar(t,e)}))}))}),Promise.resolve(!1===r?[]:x(r)?r:{}))},exports.createEvt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return t.join("_")},exports.createMutation=Fr,exports.createMutationStr=function(t,r,e,n){return void 0===e&&(e={}),void 0===n&&(n=!1),JSON.stringify(Fr(t,r,e,n))},exports.createQuery=zr,exports.createQueryStr=function(t,r,e){return void 0===r&&(r=[]),void 0===e&&(e=!1),JSON.stringify(zr(t,r,e))},exports.dasherize=Br,exports.extractArgsFromPayload=function(t,r){switch(r){case"query":return t.args;case"mutation":return[t.payload,t.condition];default:throw new Tr("Unknown "+r+" to extract argument from!")}},exports.extractParamsFromContract=function(t,r,e){try{var n=t[r][e];if(!n)throw new Or(e,r);return n}catch(t){throw new Or(e,t)}},exports.extractSocketPart=Sr,exports.findFromContract=function(t,e,n){return!!(n[t]&&n[t][e]&&n[t][e].file&&r.existsSync(n[t][e].file))&&n[t][e].file},exports.formatPayload=kr,exports.getCallMethod=function(t){switch(!0){case t===xr[0]:return"query";case t===xr[1]:return"mutation";default:return!1}},exports.getConfigValue=function(t,r){return r&&x(r)&&t in r?r[t]:void 0},exports.getDocLen=function(t){return se.byteLength(t,"utf8")},exports.getMutationFromArgs=$r,exports.getMutationFromPayload=function(t){var r=Jr(t,$r);if(!1!==r)return r;throw new Rr("[getMutationArgs] Payload is malformed!",t)},exports.getNameFromPayload=Dr,exports.getNamespace=Gr,exports.getNamespaceInOrder=function(t,r){var e=[];for(var n in t)n===r?e[1]=n:e[0]=n;return e},exports.getNspInfoByConfig=function(t){var r=t.contract,e=t.enableAuth,n=Gr(t),o=e?Vr(r):function(t,r){var e,n={};for(var o in t){var i=t[o];n[o]=i}return{size:1,nspGroup:(e={},e[r]=n,e),publicNamespace:r}}(r.socket,n[0]);return Object.assign(o,{namespaces:n})},exports.getPathToFn=function(t,n,o){var i=o.resolverDir,u=Br(t),a=[];o.contract&&o.contract[n]&&o.contract[n].path&&a.push(o.contract[n].path),a.push(e.join(i,n,u,[Pr,jr].join("."))),a.push(e.join(i,n,[u,jr].join(".")));for(var f=a.length,s=0;s { const nspInfo = groupByNamespace(contract) + // expect this to fail + t.falsy(nspInfo.size) - debug('nspInfo', nspInfo) - - t.pass() + const nspInfo1 = getNspInfoByConfig({enableAuth: false, contract}) + debug('nspInfo', nspInfo1) + t.truthy(nspInfo1.size) }) diff --git a/packages/ws-server-core/tests/object.test.js b/packages/ws-server-core/tests/object.test.js index 092a21480b261f12fbb5f1576299898747c1d5bc..c823d8c8a99f82dcfdf5afe6e37f194209a642c7 100644 --- a/packages/ws-server-core/tests/object.test.js +++ b/packages/ws-server-core/tests/object.test.js @@ -1,6 +1,8 @@ // this is a standalone test to try the Object.defineProperty const test = require('ava') +const { getNameFromPayload } = require('jsonql-utils') + test.before( t => { const fn = require('./fixtures/fn') Object.defineProperty(fn, 'ctx', { @@ -25,7 +27,8 @@ test(`Different way to extract data from payload`, t => { const payload = { availableToEveryone: { args: [] } } const resolverName = Object.keys(payload)[0] - - t.is(resolverName, 'availableToEveryone') + const name = getNameFromPayload(payload) + + t.is(resolverName, name) })