Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typeson

Package Overview
Dependencies
Maintainers
2
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typeson - npm Package Compare versions

Comparing version 5.0.1 to 5.0.2

2

dist/typeson-commonjs2.js

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

module.exports=function(e){function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var t={};return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=0)}([function(e,n,t){"use strict";function r(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}function i(e,n){return f.isObject(e)&&"function"==typeof e.then&&(!n||"function"==typeof e.catch)}function c(e){return w.call(e).slice(8,-1)}function o(e,n){if(!e||"object"!==(void 0===e?"undefined":O(e)))return!1;var t=j(e);if(!t)return!1;var r=S.call(t,"constructor")&&t.constructor;return"function"!=typeof r?null===n:"function"==typeof r&&null!==n&&T.call(r)===T.call(n)}function u(e){return!(!e||"Object"!==c(e))&&(!j(e)||o(e,Object))}function a(e){if(!e||"Object"!==c(e))return!1;var n=j(e);return!n||(o(e,Object)||a(n))}function s(e){return e&&"object"===(void 0===e?"undefined":O(e))}function f(e){var n=[],t=[],c={},a=this.types={},p=this.stringify=function(n,t,r,i){i=Object.assign({},e,i,{stringification:!0});var c=j(n,null,i);return m(c)?JSON.stringify(c[0],t,r):c.then(function(e){return JSON.stringify(e,t,r)})};this.stringifySync=function(e,n,t,r){return p(e,n,t,Object.assign({},{throwOnBadSyncType:!0},r,{sync:!0}))},this.stringifyAsync=function(e,n,t,r){return p(e,n,t,Object.assign({},{throwOnBadSyncType:!0},r,{sync:!1}))};var w=this.parse=function(n,t,r){return r=Object.assign({},e,r,{parse:!0}),S(JSON.parse(n,t),r)};this.parseSync=function(e,n,t){return w(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!0}))},this.parseAsync=function(e,n,t){return w(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!1}))},this.specialTypeNames=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.returnTypeNames=!0,this.encapsulate(e,n,t)},this.rootTypeName=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.iterateNone=!0,this.encapsulate(e,n,t)};var j=this.encapsulate=function(i,a,y){function p(e){var n=Object.values(S);if(n.length){if(y.returnTypeNames)return[].concat(r(new Set(n)));e&&u(e)&&!e.hasOwnProperty("$types")?e.$types=S:e={$:e,$types:{$:S}}}else s(e)&&e.hasOwnProperty("$types")&&(e={$:e,$types:!0});return!y.returnTypeNames&&e}function v(e,n){return Promise.all(n.map(function(e){return e[1].p})).then(function(t){return Promise.all(t.map(function(t){var r=[],i=n.splice(0,1)[0],c=b(i,7),u=c[0],a=c[2],s=c[3],f=c[4],y=c[5],l=c[6],p=d(u,t,a,s,r,!0,l),O=o(p,h);return u&&O?p.p.then(function(n){return f[y]=n,v(e,r)}):(u?f[y]=p:e=O?p.p:p,v(e,r))}))}).then(function(){return e})}function d(e,t,r,i,c,a,s){var p=void 0,v={},b=void 0===t?"undefined":O(t),j=$?function(n){if($){var u=s||i.type||f.getJSONType(t);$(Object.assign(n||v,{keypath:e,value:t,cyclic:r,stateObj:i,promisesData:c,resolvingTypesonPromise:a,awaitingTypesonPromise:o(t,h)},void 0!==u?{type:u}:{}))}}:null;if(b in{string:1,boolean:1,number:1,undefined:1})return void 0===t||"number"===b&&(isNaN(t)||t===-1/0||t===1/0)?(p=w(e,t,i,c,!1,a))!==t&&(v={replaced:p}):p=t,j&&j(),p;if(null===t)return j&&j(),t;if(r&&!i.iterateIn&&!i.iterateUnsetNumeric){var P=T.indexOf(t);if(!(P<0))return S[e]="#",j&&j({cyclicKeypath:A[P]}),"#"+A[P];!0===r&&(T.push(t),A.push(e))}var N=u(t),E=m(t),B=(N||E)&&(!n.length||i.replaced)||i.iterateIn?t:w(e,t,i,c,N||E),x=void 0;if(B!==t?(p=B,v={replaced:B}):E||"array"===i.iterateIn?(x=new Array(t.length),v={clone:x}):N||"object"===i.iterateIn?(x={},v={clone:x}):""===e&&o(t,h)?(c.push([e,t,r,i,void 0,void 0,i.type]),p=t):p=t,j&&j(),y.iterateNone){var I=Object.values(S);return I.length?I[0]:f.getJSONType(x||p)}if(!x)return p;if(i.iterateIn){for(var J in t){var K={ownKeys:t.hasOwnProperty(J)},k=e+(e?".":"")+l(J),U=d(k,t[J],!!r,K,c,a);o(U,h)?c.push([k,U,!!r,K,x,J,K.type]):void 0!==U&&(x[J]=U)}j&&j({endIterateIn:!0,end:!0})}else g(t).forEach(function(n){var i=e+(e?".":"")+l(n),u={ownKeys:!0},s=d(i,t[n],!!r,u,c,a);o(s,h)?c.push([i,s,!!r,u,x,n,u.type]):void 0!==s&&(x[n]=s)}),j&&j({endIterateOwn:!0,end:!0});if(i.iterateUnsetNumeric){for(var _=t.length,q=0;q<_;q++)if(!(q in t)){var C=e+(e?".":"")+q,M={ownKeys:!1},Y=d(C,void 0,!!r,M,c,a);o(Y,h)?c.push([C,Y,!!r,M,x,q,M.type]):void 0!==Y&&(x[q]=Y)}j&&j({endIterateUnsetNumeric:!0,end:!0})}return x}function w(e,r,i,o,u,a){console.log("rrr1",e,r);for(var s=u?n:t,f=s.length;f--;){var y=s[f];if(y.test(r,i)){var l=y.type;if(c[l]){var p=S[e];S[e]=p?[l].concat(p):l}if(i=Object.assign(i,{type:l,replaced:!0}),(j||!y.replaceAsync)&&!y.replace)return d(e,r,N&&"readonly",i,o,a,l);return d(e,y[j||!y.replaceAsync?"replace":"replaceAsync"](r,i),N&&"readonly",i,o,a,l)}}return r}y=Object.assign({sync:!0},e,y);var j=y.sync,S={},T=[],A=[],P=[],N=!(y&&"cyclic"in y)||y.cyclic,$=y.encapsulateObserver,E=d("",i,N,a||{},P);return P.length?j&&y.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(v(E,P)).then(p):!j&&y.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():y.stringification&&j?[p(E)]:j?p(E):Promise.resolve(p(E))};this.encapsulateSync=function(e,n,t){return j(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!0}))},this.encapsulateAsync=function(e,n,t){return j(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!1}))};var S=this.revive=function(n,t){function r(e,n,t,i,a,p){if(!f||"$types"!==e){var h=s[e];if(m(n)||u(n)){var O=m(n)?new Array(n.length):{};for(g(n).forEach(function(c){var u=r(e+(e?".":"")+l(c),n[c],t||O,i,O,c);o(u,d)?O[c]=void 0:void 0!==u&&(O[c]=u)}),n=O;y.length;){var w=b(y[0],4),j=w[0],S=w[1],T=w[2],A=w[3],P=v(j,S);if(o(P,d))T[A]=void 0;else{if(void 0===P)break;T[A]=P}y.splice(0,1)}}if(!h)return n;if("#"===h){var N=v(t,n.substr(1));return void 0===N&&y.push([t,n.substr(1),a,p]),N}var $=i.sync;return[].concat(h).reduce(function(e,n){var t=c[n];if(!t)throw new Error("Unregistered type: "+n);return t[$&&t.revive?"revive":!$&&t.reviveAsync?"reviveAsync":"revive"](e)},n)}}t=Object.assign({sync:!0},e,t);var a=t.sync,s=n&&n.$types,f=!0;if(!s)return n;if(!0===s)return n.$;s.$&&u(s.$)&&(n=n.$,s=s.$,f=!1);var y=[],p=r("",n,null,t);return p=o(p,d)?void 0:p,i(p)?a&&t.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():p:!a&&t.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():a?p:Promise.resolve(p)};this.reviveSync=function(e,n){return S(e,Object.assign({},{throwOnBadSyncType:!0},n,{sync:!0}))},this.reviveAsync=function(e,n){return S(e,Object.assign({},{throwOnBadSyncType:!0},n,{sync:!1}))},this.register=function(e,r){return r=r||{},[].concat(e).forEach(function e(i){if(m(i))return i.map(e);i&&g(i).forEach(function(e){if("#"===e)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(f.JSON_TYPES.includes(e))throw new TypeError("Plain JSON object types are reserved as type names");var o=i[e],u=o.testPlainObjects?n:t,s=u.filter(function(n){return n.type===e});if(s.length&&(u.splice(u.indexOf(s[0]),1),delete c[e],delete a[e]),o){if("function"==typeof o){var l=o;o={test:function(e){return e&&e.constructor===l},replace:function(e){return y({},e)},revive:function(e){return y(Object.create(l.prototype),e)}}}else m(o)&&(o={test:o[0],replace:o[1],revive:o[2]});var p={type:e,test:o.test.bind(o)};o.replace&&(p.replace=o.replace.bind(o)),o.replaceAsync&&(p.replaceAsync=o.replaceAsync.bind(o));var v="number"==typeof r.fallback?r.fallback:r.fallback?0:1/0;if(o.testPlainObjects?n.splice(v,0,p):t.splice(v,0,p),o.revive||o.reviveAsync){var d={};o.revive&&(d.revive=o.revive.bind(o)),o.reviveAsync&&(d.reviveAsync=o.reviveAsync.bind(o)),c[e]=d}a[e]=o}})}),this}}function y(e,n){return g(n).map(function(t){e[t]=n[t]}),e}function l(e){return e.replace(/~/g,"~0").replace(/\./g,"~1")}function p(e){return e.replace(/~1/g,".").replace(/~0/g,"~")}function v(e,n){if(""===n)return e;var t=n.indexOf(".");if(t>-1){var r=e[p(n.substr(0,t))];return void 0===r?void 0:v(r,n.substr(t+1))}return e[p(n)]}function d(){}function h(e){this.p=new Promise(e)}Object.defineProperty(n,"__esModule",{value:!0});var b=function(){function e(e,n){var t=[],r=!0,i=!1,c=void 0;try{for(var o,u=e[Symbol.iterator]();!(r=(o=u.next()).done)&&(t.push(o.value),!n||t.length!==n);r=!0);}catch(e){i=!0,c=e}finally{try{!r&&u.return&&u.return()}finally{if(i)throw c}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g=Object.keys,m=Array.isArray,w={}.toString,j=Object.getPrototypeOf,S={}.hasOwnProperty,T=S.toString;h.prototype.then=function(e,n){var t=this;return new h(function(r,i){t.p.then(function(n){r(e?e(n):n)},function(e){t.p.catch(function(e){return n?n(e):Promise.reject(e)}).then(r,i)})})},h.prototype.catch=function(e){return this.then(null,e)},h.resolve=function(e){return new h(function(n){n(e)})},h.reject=function(e){return new h(function(n,t){t(e)})},["all","race"].map(function(e){h[e]=function(n){return new h(function(t,r){Promise[e](n.map(function(e){return e.p})).then(t,r)})}}),f.Undefined=d,f.Promise=h,f.isThenable=i,f.toStringTag=c,f.hasConstructorOf=o,f.isObject=s,f.isPlainObject=u,f.isUserObject=a,f.escapeKeyPathComponent=l,f.unescapeKeyPathComponent=p,f.getByKeyPath=v,f.getJSONType=function(e){return null===e?"null":m(e)?"array":void 0===e?"undefined":O(e)},f.JSON_TYPES=["null","boolean","number","string","array","object"],n.default=f,e.exports=n.default}]);
module.exports=function(e){function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var t={};return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=0)}([function(e,n,t){"use strict";function r(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}function i(e,n){return f.isObject(e)&&"function"==typeof e.then&&(!n||"function"==typeof e.catch)}function c(e){return w.call(e).slice(8,-1)}function o(e,n){if(!e||"object"!==(void 0===e?"undefined":O(e)))return!1;var t=j(e);if(!t)return!1;var r=S.call(t,"constructor")&&t.constructor;return"function"!=typeof r?null===n:"function"==typeof r&&null!==n&&T.call(r)===T.call(n)}function u(e){return!(!e||"Object"!==c(e))&&(!j(e)||o(e,Object))}function a(e){if(!e||"Object"!==c(e))return!1;var n=j(e);return!n||(o(e,Object)||a(n))}function s(e){return e&&"object"===(void 0===e?"undefined":O(e))}function f(e){var n=[],t=[],c={},a=this.types={},p=this.stringify=function(n,t,r,i){i=Object.assign({},e,i,{stringification:!0});var c=j(n,null,i);return m(c)?JSON.stringify(c[0],t,r):c.then(function(e){return JSON.stringify(e,t,r)})};this.stringifySync=function(e,n,t,r){return p(e,n,t,Object.assign({},{throwOnBadSyncType:!0},r,{sync:!0}))},this.stringifyAsync=function(e,n,t,r){return p(e,n,t,Object.assign({},{throwOnBadSyncType:!0},r,{sync:!1}))};var w=this.parse=function(n,t,r){return r=Object.assign({},e,r,{parse:!0}),S(JSON.parse(n,t),r)};this.parseSync=function(e,n,t){return w(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!0}))},this.parseAsync=function(e,n,t){return w(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!1}))},this.specialTypeNames=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.returnTypeNames=!0,this.encapsulate(e,n,t)},this.rootTypeName=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.iterateNone=!0,this.encapsulate(e,n,t)};var j=this.encapsulate=function(i,a,y){function p(e){if(y.iterateNone){var n=Object.values(S);return n.length?n[0]:f.getJSONType(e)}var t=Object.values(S);if(t.length){if(y.returnTypeNames)return[].concat(r(new Set(t)));e&&u(e)&&!e.hasOwnProperty("$types")?e.$types=S:e={$:e,$types:{$:S}}}else s(e)&&e.hasOwnProperty("$types")&&(e={$:e,$types:!0});return!y.returnTypeNames&&e}function v(e,n){return Promise.all(n.map(function(e){return e[1].p})).then(function(t){return Promise.all(t.map(function(t){var r=[],i=n.splice(0,1)[0],c=b(i,7),u=c[0],a=c[2],s=c[3],f=c[4],y=c[5],l=c[6],p=d(u,t,a,s,r,!0,l),O=o(p,h);return u&&O?p.p.then(function(n){return f[y]=n,v(e,r)}):(u?f[y]=p:e=O?p.p:p,v(e,r))}))}).then(function(){return e})}function d(e,t,r,i,c,a,s){var p=void 0,v={},b=void 0===t?"undefined":O(t),j=$?function(n){if($){var u=s||i.type||f.getJSONType(t);$(Object.assign(n||v,{keypath:e,value:t,cyclic:r,stateObj:i,promisesData:c,resolvingTypesonPromise:a,awaitingTypesonPromise:o(t,h)},void 0!==u?{type:u}:{}))}}:null;if(b in{string:1,boolean:1,number:1,undefined:1})return void 0===t||"number"===b&&(isNaN(t)||t===-1/0||t===1/0)?(p=w(e,t,i,c,!1,a))!==t&&(v={replaced:p}):p=t,j&&j(),p;if(null===t)return j&&j(),t;if(r&&!i.iterateIn&&!i.iterateUnsetNumeric){var P=T.indexOf(t);if(!(P<0))return S[e]="#",j&&j({cyclicKeypath:A[P]}),"#"+A[P];!0===r&&(T.push(t),A.push(e))}var N=u(t),E=m(t),B=(N||E)&&(!n.length||i.replaced)||i.iterateIn?t:w(e,t,i,c,N||E),x=void 0;if(B!==t?(p=B,v={replaced:B}):E||"array"===i.iterateIn?(x=new Array(t.length),v={clone:x}):N||"object"===i.iterateIn?(x={},v={clone:x}):""===e&&o(t,h)?(c.push([e,t,r,i,void 0,void 0,i.type]),p=t):p=t,j&&j(),y.iterateNone)return x||p;if(!x)return p;if(i.iterateIn){for(var I in t){var J={ownKeys:t.hasOwnProperty(I)},K=e+(e?".":"")+l(I),k=d(K,t[I],!!r,J,c,a);o(k,h)?c.push([K,k,!!r,J,x,I,J.type]):void 0!==k&&(x[I]=k)}j&&j({endIterateIn:!0,end:!0})}else g(t).forEach(function(n){var i=e+(e?".":"")+l(n),u={ownKeys:!0},s=d(i,t[n],!!r,u,c,a);o(s,h)?c.push([i,s,!!r,u,x,n,u.type]):void 0!==s&&(x[n]=s)}),j&&j({endIterateOwn:!0,end:!0});if(i.iterateUnsetNumeric){for(var U=t.length,_=0;_<U;_++)if(!(_ in t)){var q=e+(e?".":"")+_,C={ownKeys:!1},M=d(q,void 0,!!r,C,c,a);o(M,h)?c.push([q,M,!!r,C,x,_,C.type]):void 0!==M&&(x[_]=M)}j&&j({endIterateUnsetNumeric:!0,end:!0})}return x}function w(e,r,i,o,u,a){for(var s=u?n:t,f=s.length;f--;){var y=s[f];if(y.test(r,i)){var l=y.type;if(c[l]){var p=S[e];S[e]=p?[l].concat(p):l}if(i=Object.assign(i,{type:l,replaced:!0}),(j||!y.replaceAsync)&&!y.replace)return d(e,r,N&&"readonly",i,o,a,l);return d(e,y[j||!y.replaceAsync?"replace":"replaceAsync"](r,i),N&&"readonly",i,o,a,l)}}return r}y=Object.assign({sync:!0},e,y);var j=y.sync,S={},T=[],A=[],P=[],N=!(y&&"cyclic"in y)||y.cyclic,$=y.encapsulateObserver,E=d("",i,N,a||{},P);return P.length?j&&y.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(v(E,P)).then(p):!j&&y.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():y.stringification&&j?[p(E)]:j?p(E):Promise.resolve(p(E))};this.encapsulateSync=function(e,n,t){return j(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!0}))},this.encapsulateAsync=function(e,n,t){return j(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!1}))};var S=this.revive=function(n,t){function r(e,n,t,i,a,p){if(!f||"$types"!==e){var h=s[e];if(m(n)||u(n)){var O=m(n)?new Array(n.length):{};for(g(n).forEach(function(c){var u=r(e+(e?".":"")+l(c),n[c],t||O,i,O,c);o(u,d)?O[c]=void 0:void 0!==u&&(O[c]=u)}),n=O;y.length;){var w=b(y[0],4),j=w[0],S=w[1],T=w[2],A=w[3],P=v(j,S);if(o(P,d))T[A]=void 0;else{if(void 0===P)break;T[A]=P}y.splice(0,1)}}if(!h)return n;if("#"===h){var N=v(t,n.substr(1));return void 0===N&&y.push([t,n.substr(1),a,p]),N}var $=i.sync;return[].concat(h).reduce(function(e,n){var t=c[n];if(!t)throw new Error("Unregistered type: "+n);return t[$&&t.revive?"revive":!$&&t.reviveAsync?"reviveAsync":"revive"](e)},n)}}t=Object.assign({sync:!0},e,t);var a=t.sync,s=n&&n.$types,f=!0;if(!s)return n;if(!0===s)return n.$;s.$&&u(s.$)&&(n=n.$,s=s.$,f=!1);var y=[],p=r("",n,null,t);return p=o(p,d)?void 0:p,i(p)?a&&t.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():p:!a&&t.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():a?p:Promise.resolve(p)};this.reviveSync=function(e,n){return S(e,Object.assign({},{throwOnBadSyncType:!0},n,{sync:!0}))},this.reviveAsync=function(e,n){return S(e,Object.assign({},{throwOnBadSyncType:!0},n,{sync:!1}))},this.register=function(e,r){return r=r||{},[].concat(e).forEach(function e(i){if(m(i))return i.map(e);i&&g(i).forEach(function(e){if("#"===e)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(f.JSON_TYPES.includes(e))throw new TypeError("Plain JSON object types are reserved as type names");var o=i[e],u=o.testPlainObjects?n:t,s=u.filter(function(n){return n.type===e});if(s.length&&(u.splice(u.indexOf(s[0]),1),delete c[e],delete a[e]),o){if("function"==typeof o){var l=o;o={test:function(e){return e&&e.constructor===l},replace:function(e){return y({},e)},revive:function(e){return y(Object.create(l.prototype),e)}}}else m(o)&&(o={test:o[0],replace:o[1],revive:o[2]});var p={type:e,test:o.test.bind(o)};o.replace&&(p.replace=o.replace.bind(o)),o.replaceAsync&&(p.replaceAsync=o.replaceAsync.bind(o));var v="number"==typeof r.fallback?r.fallback:r.fallback?0:1/0;if(o.testPlainObjects?n.splice(v,0,p):t.splice(v,0,p),o.revive||o.reviveAsync){var d={};o.revive&&(d.revive=o.revive.bind(o)),o.reviveAsync&&(d.reviveAsync=o.reviveAsync.bind(o)),c[e]=d}a[e]=o}})}),this}}function y(e,n){return g(n).map(function(t){e[t]=n[t]}),e}function l(e){return e.replace(/~/g,"~0").replace(/\./g,"~1")}function p(e){return e.replace(/~1/g,".").replace(/~0/g,"~")}function v(e,n){if(""===n)return e;var t=n.indexOf(".");if(t>-1){var r=e[p(n.substr(0,t))];return void 0===r?void 0:v(r,n.substr(t+1))}return e[p(n)]}function d(){}function h(e){this.p=new Promise(e)}Object.defineProperty(n,"__esModule",{value:!0});var b=function(){function e(e,n){var t=[],r=!0,i=!1,c=void 0;try{for(var o,u=e[Symbol.iterator]();!(r=(o=u.next()).done)&&(t.push(o.value),!n||t.length!==n);r=!0);}catch(e){i=!0,c=e}finally{try{!r&&u.return&&u.return()}finally{if(i)throw c}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g=Object.keys,m=Array.isArray,w={}.toString,j=Object.getPrototypeOf,S={}.hasOwnProperty,T=S.toString;h.prototype.then=function(e,n){var t=this;return new h(function(r,i){t.p.then(function(n){r(e?e(n):n)},function(e){t.p.catch(function(e){return n?n(e):Promise.reject(e)}).then(r,i)})})},h.prototype.catch=function(e){return this.then(null,e)},h.resolve=function(e){return new h(function(n){n(e)})},h.reject=function(e){return new h(function(n,t){t(e)})},["all","race"].map(function(e){h[e]=function(n){return new h(function(t,r){Promise[e](n.map(function(e){return e.p})).then(t,r)})}}),f.Undefined=d,f.Promise=h,f.isThenable=i,f.toStringTag=c,f.hasConstructorOf=o,f.isObject=s,f.isPlainObject=u,f.isUserObject=a,f.escapeKeyPathComponent=l,f.unescapeKeyPathComponent=p,f.getByKeyPath=v,f.getJSONType=function(e){return null===e?"null":m(e)?"array":void 0===e?"undefined":O(e)},f.JSON_TYPES=["null","boolean","number","string","array","object"],n.default=f,e.exports=n.default}]);

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

!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Typeson=n():e.Typeson=n()}(this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var t={};return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=0)}([function(e,n,t){"use strict";function r(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}function i(e,n){return f.isObject(e)&&"function"==typeof e.then&&(!n||"function"==typeof e.catch)}function o(e){return w.call(e).slice(8,-1)}function c(e,n){if(!e||"object"!==(void 0===e?"undefined":O(e)))return!1;var t=j(e);if(!t)return!1;var r=S.call(t,"constructor")&&t.constructor;return"function"!=typeof r?null===n:"function"==typeof r&&null!==n&&T.call(r)===T.call(n)}function u(e){return!(!e||"Object"!==o(e))&&(!j(e)||c(e,Object))}function a(e){if(!e||"Object"!==o(e))return!1;var n=j(e);return!n||(c(e,Object)||a(n))}function s(e){return e&&"object"===(void 0===e?"undefined":O(e))}function f(e){var n=[],t=[],o={},a=this.types={},l=this.stringify=function(n,t,r,i){i=Object.assign({},e,i,{stringification:!0});var o=j(n,null,i);return m(o)?JSON.stringify(o[0],t,r):o.then(function(e){return JSON.stringify(e,t,r)})};this.stringifySync=function(e,n,t,r){return l(e,n,t,Object.assign({},{throwOnBadSyncType:!0},r,{sync:!0}))},this.stringifyAsync=function(e,n,t,r){return l(e,n,t,Object.assign({},{throwOnBadSyncType:!0},r,{sync:!1}))};var w=this.parse=function(n,t,r){return r=Object.assign({},e,r,{parse:!0}),S(JSON.parse(n,t),r)};this.parseSync=function(e,n,t){return w(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!0}))},this.parseAsync=function(e,n,t){return w(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!1}))},this.specialTypeNames=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.returnTypeNames=!0,this.encapsulate(e,n,t)},this.rootTypeName=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.iterateNone=!0,this.encapsulate(e,n,t)};var j=this.encapsulate=function(i,a,y){function l(e){var n=Object.values(S);if(n.length){if(y.returnTypeNames)return[].concat(r(new Set(n)));e&&u(e)&&!e.hasOwnProperty("$types")?e.$types=S:e={$:e,$types:{$:S}}}else s(e)&&e.hasOwnProperty("$types")&&(e={$:e,$types:!0});return!y.returnTypeNames&&e}function v(e,n){return Promise.all(n.map(function(e){return e[1].p})).then(function(t){return Promise.all(t.map(function(t){var r=[],i=n.splice(0,1)[0],o=b(i,7),u=o[0],a=o[2],s=o[3],f=o[4],y=o[5],p=o[6],l=d(u,t,a,s,r,!0,p),O=c(l,h);return u&&O?l.p.then(function(n){return f[y]=n,v(e,r)}):(u?f[y]=l:e=O?l.p:l,v(e,r))}))}).then(function(){return e})}function d(e,t,r,i,o,a,s){var l=void 0,v={},b=void 0===t?"undefined":O(t),j=$?function(n){if($){var u=s||i.type||f.getJSONType(t);$(Object.assign(n||v,{keypath:e,value:t,cyclic:r,stateObj:i,promisesData:o,resolvingTypesonPromise:a,awaitingTypesonPromise:c(t,h)},void 0!==u?{type:u}:{}))}}:null;if(b in{string:1,boolean:1,number:1,undefined:1})return void 0===t||"number"===b&&(isNaN(t)||t===-1/0||t===1/0)?(l=w(e,t,i,o,!1,a))!==t&&(v={replaced:l}):l=t,j&&j(),l;if(null===t)return j&&j(),t;if(r&&!i.iterateIn&&!i.iterateUnsetNumeric){var P=T.indexOf(t);if(!(P<0))return S[e]="#",j&&j({cyclicKeypath:A[P]}),"#"+A[P];!0===r&&(T.push(t),A.push(e))}var N=u(t),x=m(t),E=(N||x)&&(!n.length||i.replaced)||i.iterateIn?t:w(e,t,i,o,N||x),B=void 0;if(E!==t?(l=E,v={replaced:E}):x||"array"===i.iterateIn?(B=new Array(t.length),v={clone:B}):N||"object"===i.iterateIn?(B={},v={clone:B}):""===e&&c(t,h)?(o.push([e,t,r,i,void 0,void 0,i.type]),l=t):l=t,j&&j(),y.iterateNone){var I=Object.values(S);return I.length?I[0]:f.getJSONType(B||l)}if(!B)return l;if(i.iterateIn){for(var J in t){var K={ownKeys:t.hasOwnProperty(J)},k=e+(e?".":"")+p(J),U=d(k,t[J],!!r,K,o,a);c(U,h)?o.push([k,U,!!r,K,B,J,K.type]):void 0!==U&&(B[J]=U)}j&&j({endIterateIn:!0,end:!0})}else g(t).forEach(function(n){var i=e+(e?".":"")+p(n),u={ownKeys:!0},s=d(i,t[n],!!r,u,o,a);c(s,h)?o.push([i,s,!!r,u,B,n,u.type]):void 0!==s&&(B[n]=s)}),j&&j({endIterateOwn:!0,end:!0});if(i.iterateUnsetNumeric){for(var _=t.length,q=0;q<_;q++)if(!(q in t)){var C=e+(e?".":"")+q,M={ownKeys:!1},Y=d(C,void 0,!!r,M,o,a);c(Y,h)?o.push([C,Y,!!r,M,B,q,M.type]):void 0!==Y&&(B[q]=Y)}j&&j({endIterateUnsetNumeric:!0,end:!0})}return B}function w(e,r,i,c,u,a){console.log("rrr1",e,r);for(var s=u?n:t,f=s.length;f--;){var y=s[f];if(y.test(r,i)){var p=y.type;if(o[p]){var l=S[e];S[e]=l?[p].concat(l):p}if(i=Object.assign(i,{type:p,replaced:!0}),(j||!y.replaceAsync)&&!y.replace)return d(e,r,N&&"readonly",i,c,a,p);return d(e,y[j||!y.replaceAsync?"replace":"replaceAsync"](r,i),N&&"readonly",i,c,a,p)}}return r}y=Object.assign({sync:!0},e,y);var j=y.sync,S={},T=[],A=[],P=[],N=!(y&&"cyclic"in y)||y.cyclic,$=y.encapsulateObserver,x=d("",i,N,a||{},P);return P.length?j&&y.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(v(x,P)).then(l):!j&&y.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():y.stringification&&j?[l(x)]:j?l(x):Promise.resolve(l(x))};this.encapsulateSync=function(e,n,t){return j(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!0}))},this.encapsulateAsync=function(e,n,t){return j(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!1}))};var S=this.revive=function(n,t){function r(e,n,t,i,a,l){if(!f||"$types"!==e){var h=s[e];if(m(n)||u(n)){var O=m(n)?new Array(n.length):{};for(g(n).forEach(function(o){var u=r(e+(e?".":"")+p(o),n[o],t||O,i,O,o);c(u,d)?O[o]=void 0:void 0!==u&&(O[o]=u)}),n=O;y.length;){var w=b(y[0],4),j=w[0],S=w[1],T=w[2],A=w[3],P=v(j,S);if(c(P,d))T[A]=void 0;else{if(void 0===P)break;T[A]=P}y.splice(0,1)}}if(!h)return n;if("#"===h){var N=v(t,n.substr(1));return void 0===N&&y.push([t,n.substr(1),a,l]),N}var $=i.sync;return[].concat(h).reduce(function(e,n){var t=o[n];if(!t)throw new Error("Unregistered type: "+n);return t[$&&t.revive?"revive":!$&&t.reviveAsync?"reviveAsync":"revive"](e)},n)}}t=Object.assign({sync:!0},e,t);var a=t.sync,s=n&&n.$types,f=!0;if(!s)return n;if(!0===s)return n.$;s.$&&u(s.$)&&(n=n.$,s=s.$,f=!1);var y=[],l=r("",n,null,t);return l=c(l,d)?void 0:l,i(l)?a&&t.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():l:!a&&t.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():a?l:Promise.resolve(l)};this.reviveSync=function(e,n){return S(e,Object.assign({},{throwOnBadSyncType:!0},n,{sync:!0}))},this.reviveAsync=function(e,n){return S(e,Object.assign({},{throwOnBadSyncType:!0},n,{sync:!1}))},this.register=function(e,r){return r=r||{},[].concat(e).forEach(function e(i){if(m(i))return i.map(e);i&&g(i).forEach(function(e){if("#"===e)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(f.JSON_TYPES.includes(e))throw new TypeError("Plain JSON object types are reserved as type names");var c=i[e],u=c.testPlainObjects?n:t,s=u.filter(function(n){return n.type===e});if(s.length&&(u.splice(u.indexOf(s[0]),1),delete o[e],delete a[e]),c){if("function"==typeof c){var p=c;c={test:function(e){return e&&e.constructor===p},replace:function(e){return y({},e)},revive:function(e){return y(Object.create(p.prototype),e)}}}else m(c)&&(c={test:c[0],replace:c[1],revive:c[2]});var l={type:e,test:c.test.bind(c)};c.replace&&(l.replace=c.replace.bind(c)),c.replaceAsync&&(l.replaceAsync=c.replaceAsync.bind(c));var v="number"==typeof r.fallback?r.fallback:r.fallback?0:1/0;if(c.testPlainObjects?n.splice(v,0,l):t.splice(v,0,l),c.revive||c.reviveAsync){var d={};c.revive&&(d.revive=c.revive.bind(c)),c.reviveAsync&&(d.reviveAsync=c.reviveAsync.bind(c)),o[e]=d}a[e]=c}})}),this}}function y(e,n){return g(n).map(function(t){e[t]=n[t]}),e}function p(e){return e.replace(/~/g,"~0").replace(/\./g,"~1")}function l(e){return e.replace(/~1/g,".").replace(/~0/g,"~")}function v(e,n){if(""===n)return e;var t=n.indexOf(".");if(t>-1){var r=e[l(n.substr(0,t))];return void 0===r?void 0:v(r,n.substr(t+1))}return e[l(n)]}function d(){}function h(e){this.p=new Promise(e)}Object.defineProperty(n,"__esModule",{value:!0});var b=function(){function e(e,n){var t=[],r=!0,i=!1,o=void 0;try{for(var c,u=e[Symbol.iterator]();!(r=(c=u.next()).done)&&(t.push(c.value),!n||t.length!==n);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&u.return&&u.return()}finally{if(i)throw o}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g=Object.keys,m=Array.isArray,w={}.toString,j=Object.getPrototypeOf,S={}.hasOwnProperty,T=S.toString;h.prototype.then=function(e,n){var t=this;return new h(function(r,i){t.p.then(function(n){r(e?e(n):n)},function(e){t.p.catch(function(e){return n?n(e):Promise.reject(e)}).then(r,i)})})},h.prototype.catch=function(e){return this.then(null,e)},h.resolve=function(e){return new h(function(n){n(e)})},h.reject=function(e){return new h(function(n,t){t(e)})},["all","race"].map(function(e){h[e]=function(n){return new h(function(t,r){Promise[e](n.map(function(e){return e.p})).then(t,r)})}}),f.Undefined=d,f.Promise=h,f.isThenable=i,f.toStringTag=o,f.hasConstructorOf=c,f.isObject=s,f.isPlainObject=u,f.isUserObject=a,f.escapeKeyPathComponent=p,f.unescapeKeyPathComponent=l,f.getByKeyPath=v,f.getJSONType=function(e){return null===e?"null":m(e)?"array":void 0===e?"undefined":O(e)},f.JSON_TYPES=["null","boolean","number","string","array","object"],n.default=f,e.exports=n.default}])});
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Typeson=n():e.Typeson=n()}(this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var t={};return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=0)}([function(e,n,t){"use strict";function r(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}function i(e,n){return f.isObject(e)&&"function"==typeof e.then&&(!n||"function"==typeof e.catch)}function o(e){return w.call(e).slice(8,-1)}function c(e,n){if(!e||"object"!==(void 0===e?"undefined":O(e)))return!1;var t=j(e);if(!t)return!1;var r=S.call(t,"constructor")&&t.constructor;return"function"!=typeof r?null===n:"function"==typeof r&&null!==n&&T.call(r)===T.call(n)}function u(e){return!(!e||"Object"!==o(e))&&(!j(e)||c(e,Object))}function a(e){if(!e||"Object"!==o(e))return!1;var n=j(e);return!n||(c(e,Object)||a(n))}function s(e){return e&&"object"===(void 0===e?"undefined":O(e))}function f(e){var n=[],t=[],o={},a=this.types={},l=this.stringify=function(n,t,r,i){i=Object.assign({},e,i,{stringification:!0});var o=j(n,null,i);return m(o)?JSON.stringify(o[0],t,r):o.then(function(e){return JSON.stringify(e,t,r)})};this.stringifySync=function(e,n,t,r){return l(e,n,t,Object.assign({},{throwOnBadSyncType:!0},r,{sync:!0}))},this.stringifyAsync=function(e,n,t,r){return l(e,n,t,Object.assign({},{throwOnBadSyncType:!0},r,{sync:!1}))};var w=this.parse=function(n,t,r){return r=Object.assign({},e,r,{parse:!0}),S(JSON.parse(n,t),r)};this.parseSync=function(e,n,t){return w(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!0}))},this.parseAsync=function(e,n,t){return w(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!1}))},this.specialTypeNames=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.returnTypeNames=!0,this.encapsulate(e,n,t)},this.rootTypeName=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.iterateNone=!0,this.encapsulate(e,n,t)};var j=this.encapsulate=function(i,a,y){function l(e){if(y.iterateNone){var n=Object.values(S);return n.length?n[0]:f.getJSONType(e)}var t=Object.values(S);if(t.length){if(y.returnTypeNames)return[].concat(r(new Set(t)));e&&u(e)&&!e.hasOwnProperty("$types")?e.$types=S:e={$:e,$types:{$:S}}}else s(e)&&e.hasOwnProperty("$types")&&(e={$:e,$types:!0});return!y.returnTypeNames&&e}function v(e,n){return Promise.all(n.map(function(e){return e[1].p})).then(function(t){return Promise.all(t.map(function(t){var r=[],i=n.splice(0,1)[0],o=b(i,7),u=o[0],a=o[2],s=o[3],f=o[4],y=o[5],p=o[6],l=d(u,t,a,s,r,!0,p),O=c(l,h);return u&&O?l.p.then(function(n){return f[y]=n,v(e,r)}):(u?f[y]=l:e=O?l.p:l,v(e,r))}))}).then(function(){return e})}function d(e,t,r,i,o,a,s){var l=void 0,v={},b=void 0===t?"undefined":O(t),j=$?function(n){if($){var u=s||i.type||f.getJSONType(t);$(Object.assign(n||v,{keypath:e,value:t,cyclic:r,stateObj:i,promisesData:o,resolvingTypesonPromise:a,awaitingTypesonPromise:c(t,h)},void 0!==u?{type:u}:{}))}}:null;if(b in{string:1,boolean:1,number:1,undefined:1})return void 0===t||"number"===b&&(isNaN(t)||t===-1/0||t===1/0)?(l=w(e,t,i,o,!1,a))!==t&&(v={replaced:l}):l=t,j&&j(),l;if(null===t)return j&&j(),t;if(r&&!i.iterateIn&&!i.iterateUnsetNumeric){var P=T.indexOf(t);if(!(P<0))return S[e]="#",j&&j({cyclicKeypath:A[P]}),"#"+A[P];!0===r&&(T.push(t),A.push(e))}var N=u(t),x=m(t),E=(N||x)&&(!n.length||i.replaced)||i.iterateIn?t:w(e,t,i,o,N||x),B=void 0;if(E!==t?(l=E,v={replaced:E}):x||"array"===i.iterateIn?(B=new Array(t.length),v={clone:B}):N||"object"===i.iterateIn?(B={},v={clone:B}):""===e&&c(t,h)?(o.push([e,t,r,i,void 0,void 0,i.type]),l=t):l=t,j&&j(),y.iterateNone)return B||l;if(!B)return l;if(i.iterateIn){for(var I in t){var J={ownKeys:t.hasOwnProperty(I)},K=e+(e?".":"")+p(I),k=d(K,t[I],!!r,J,o,a);c(k,h)?o.push([K,k,!!r,J,B,I,J.type]):void 0!==k&&(B[I]=k)}j&&j({endIterateIn:!0,end:!0})}else g(t).forEach(function(n){var i=e+(e?".":"")+p(n),u={ownKeys:!0},s=d(i,t[n],!!r,u,o,a);c(s,h)?o.push([i,s,!!r,u,B,n,u.type]):void 0!==s&&(B[n]=s)}),j&&j({endIterateOwn:!0,end:!0});if(i.iterateUnsetNumeric){for(var U=t.length,_=0;_<U;_++)if(!(_ in t)){var q=e+(e?".":"")+_,C={ownKeys:!1},M=d(q,void 0,!!r,C,o,a);c(M,h)?o.push([q,M,!!r,C,B,_,C.type]):void 0!==M&&(B[_]=M)}j&&j({endIterateUnsetNumeric:!0,end:!0})}return B}function w(e,r,i,c,u,a){for(var s=u?n:t,f=s.length;f--;){var y=s[f];if(y.test(r,i)){var p=y.type;if(o[p]){var l=S[e];S[e]=l?[p].concat(l):p}if(i=Object.assign(i,{type:p,replaced:!0}),(j||!y.replaceAsync)&&!y.replace)return d(e,r,N&&"readonly",i,c,a,p);return d(e,y[j||!y.replaceAsync?"replace":"replaceAsync"](r,i),N&&"readonly",i,c,a,p)}}return r}y=Object.assign({sync:!0},e,y);var j=y.sync,S={},T=[],A=[],P=[],N=!(y&&"cyclic"in y)||y.cyclic,$=y.encapsulateObserver,x=d("",i,N,a||{},P);return P.length?j&&y.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(v(x,P)).then(l):!j&&y.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():y.stringification&&j?[l(x)]:j?l(x):Promise.resolve(l(x))};this.encapsulateSync=function(e,n,t){return j(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!0}))},this.encapsulateAsync=function(e,n,t){return j(e,n,Object.assign({},{throwOnBadSyncType:!0},t,{sync:!1}))};var S=this.revive=function(n,t){function r(e,n,t,i,a,l){if(!f||"$types"!==e){var h=s[e];if(m(n)||u(n)){var O=m(n)?new Array(n.length):{};for(g(n).forEach(function(o){var u=r(e+(e?".":"")+p(o),n[o],t||O,i,O,o);c(u,d)?O[o]=void 0:void 0!==u&&(O[o]=u)}),n=O;y.length;){var w=b(y[0],4),j=w[0],S=w[1],T=w[2],A=w[3],P=v(j,S);if(c(P,d))T[A]=void 0;else{if(void 0===P)break;T[A]=P}y.splice(0,1)}}if(!h)return n;if("#"===h){var N=v(t,n.substr(1));return void 0===N&&y.push([t,n.substr(1),a,l]),N}var $=i.sync;return[].concat(h).reduce(function(e,n){var t=o[n];if(!t)throw new Error("Unregistered type: "+n);return t[$&&t.revive?"revive":!$&&t.reviveAsync?"reviveAsync":"revive"](e)},n)}}t=Object.assign({sync:!0},e,t);var a=t.sync,s=n&&n.$types,f=!0;if(!s)return n;if(!0===s)return n.$;s.$&&u(s.$)&&(n=n.$,s=s.$,f=!1);var y=[],l=r("",n,null,t);return l=c(l,d)?void 0:l,i(l)?a&&t.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():l:!a&&t.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():a?l:Promise.resolve(l)};this.reviveSync=function(e,n){return S(e,Object.assign({},{throwOnBadSyncType:!0},n,{sync:!0}))},this.reviveAsync=function(e,n){return S(e,Object.assign({},{throwOnBadSyncType:!0},n,{sync:!1}))},this.register=function(e,r){return r=r||{},[].concat(e).forEach(function e(i){if(m(i))return i.map(e);i&&g(i).forEach(function(e){if("#"===e)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(f.JSON_TYPES.includes(e))throw new TypeError("Plain JSON object types are reserved as type names");var c=i[e],u=c.testPlainObjects?n:t,s=u.filter(function(n){return n.type===e});if(s.length&&(u.splice(u.indexOf(s[0]),1),delete o[e],delete a[e]),c){if("function"==typeof c){var p=c;c={test:function(e){return e&&e.constructor===p},replace:function(e){return y({},e)},revive:function(e){return y(Object.create(p.prototype),e)}}}else m(c)&&(c={test:c[0],replace:c[1],revive:c[2]});var l={type:e,test:c.test.bind(c)};c.replace&&(l.replace=c.replace.bind(c)),c.replaceAsync&&(l.replaceAsync=c.replaceAsync.bind(c));var v="number"==typeof r.fallback?r.fallback:r.fallback?0:1/0;if(c.testPlainObjects?n.splice(v,0,l):t.splice(v,0,l),c.revive||c.reviveAsync){var d={};c.revive&&(d.revive=c.revive.bind(c)),c.reviveAsync&&(d.reviveAsync=c.reviveAsync.bind(c)),o[e]=d}a[e]=c}})}),this}}function y(e,n){return g(n).map(function(t){e[t]=n[t]}),e}function p(e){return e.replace(/~/g,"~0").replace(/\./g,"~1")}function l(e){return e.replace(/~1/g,".").replace(/~0/g,"~")}function v(e,n){if(""===n)return e;var t=n.indexOf(".");if(t>-1){var r=e[l(n.substr(0,t))];return void 0===r?void 0:v(r,n.substr(t+1))}return e[l(n)]}function d(){}function h(e){this.p=new Promise(e)}Object.defineProperty(n,"__esModule",{value:!0});var b=function(){function e(e,n){var t=[],r=!0,i=!1,o=void 0;try{for(var c,u=e[Symbol.iterator]();!(r=(c=u.next()).done)&&(t.push(c.value),!n||t.length!==n);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&u.return&&u.return()}finally{if(i)throw o}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g=Object.keys,m=Array.isArray,w={}.toString,j=Object.getPrototypeOf,S={}.hasOwnProperty,T=S.toString;h.prototype.then=function(e,n){var t=this;return new h(function(r,i){t.p.then(function(n){r(e?e(n):n)},function(e){t.p.catch(function(e){return n?n(e):Promise.reject(e)}).then(r,i)})})},h.prototype.catch=function(e){return this.then(null,e)},h.resolve=function(e){return new h(function(n){n(e)})},h.reject=function(e){return new h(function(n,t){t(e)})},["all","race"].map(function(e){h[e]=function(n){return new h(function(t,r){Promise[e](n.map(function(e){return e.p})).then(t,r)})}}),f.Undefined=d,f.Promise=h,f.isThenable=i,f.toStringTag=o,f.hasConstructorOf=c,f.isObject=s,f.isPlainObject=u,f.isUserObject=a,f.escapeKeyPathComponent=p,f.unescapeKeyPathComponent=l,f.getByKeyPath=v,f.getJSONType=function(e){return null===e?"null":m(e)?"array":void 0===e?"undefined":O(e)},f.JSON_TYPES=["null","boolean","number","string","array","object"],n.default=f,e.exports=n.default}])});
{
"name": "typeson",
"version": "5.0.1",
"version": "5.0.2",
"description": "Preserves types over JSON, BSON or socket.io",

@@ -9,3 +9,3 @@ "main": "./dist/typeson-commonjs2.js",

"test": "node test.js",
"build": "node_modules/.bin/webpack --optimize-minimize"
"install": "node_modules/.bin/webpack --optimize-minimize"
},

@@ -12,0 +12,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc