shift73k/assets_old/node_modules/@discoveryjs/json-ext/dist/json-ext.min.js

2 lines
7.2 KiB
JavaScript
Raw Normal View History

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).jsonExt=e()}(this,(function(){"use strict";function t(t){return"function"==typeof t.pipe&&"function"==typeof t._read&&"object"==typeof t._readableState&&null!==t._readableState}var e={escapableCharCodeSubstitution:{8:"\\b",9:"\\t",10:"\\n",12:"\\f",13:"\\r",34:'\\"',92:"\\\\"},isLeadingSurrogate:function(t){return t>=55296&&t<=56319},isTrailingSurrogate:function(t){return t>=56320&&t<=57343},type:{PRIMITIVE:1,PROMISE:4,ARRAY:3,OBJECT:2,STRING_STREAM:5,OBJECT_STREAM:6},isReadableStream:t,replaceValue:function(t,e,s,n){switch(s&&"function"==typeof s.toJSON&&(s=s.toJSON()),null!==n&&(s=n.call(t,String(e),s)),typeof s){case"function":case"symbol":s=void 0;break;case"object":if(null!==s){const t=s.constructor;t!==String&&t!==Number&&t!==Boolean||(s=s.valueOf())}}return s},getTypeNative:function(t){return null===t||"object"!=typeof t?1:Array.isArray(t)?3:2},getTypeAsync:function(e){return null===e||"object"!=typeof e?1:"function"==typeof e.then?4:t(e)?e._readableState.objectMode?6:5:Array.isArray(e)?3:2},normalizeReplacer:function(t){if("function"==typeof t)return t;if(Array.isArray(t)){const e=new Set(t.map((t=>"string"==typeof t||"number"==typeof t?String(t):null)).filter((t=>"string"==typeof t)));return e.add(""),(t,s)=>e.has(t)?s:void 0}return null},normalizeSpace:function(t){return"number"==typeof t?!(!Number.isFinite(t)||t<1)&&" ".repeat(Math.min(t,10)):"string"==typeof t&&t.slice(0,10)||!1}};const{normalizeReplacer:s,normalizeSpace:n,replaceValue:i,getTypeNative:a,getTypeAsync:r,isLeadingSurrogate:l,isTrailingSurrogate:h,escapableCharCodeSubstitution:u,type:{PRIMITIVE:o,OBJECT:c,ARRAY:f,PROMISE:p,STRING_STREAM:g,OBJECT_STREAM:d}}=e,S=Array.from({length:2048}).map(((t,e)=>u.hasOwnProperty(e)?2:e<32?6:e<128?1:2));function y(t){let e=0,s=!1;for(let n=0;n<t.length;n++){const i=t.charCodeAt(n);if(i<2048)e+=S[i];else{if(l(i)){e+=6,s=!0;continue}h(i)?e=s?e-2:e+6:e+=3}s=!1}return e+2}var b=TextDecoder;const{isReadableStream:k}=e,v=new b;function m(t){return null!==t&&"object"==typeof t}function O(t,e){return"SyntaxError"===t.name&&e.jsonParseOffset&&(t.message=t.message.replace(/at position (\d+)/,((t,s)=>"at position "+(Number(s)+e.jsonParseOffset)))),t}function D(t,e){const s=t.length;t.length+=e.length;for(let n=0;n<e.length;n++)t[s+n]=e[n]}class w{constructor(){this.value=void 0,this.valueStack=null,this.stack=new Array(100),this.lastFlushDepth=0,this.flushDepth=0,this.stateString=!1,this.stateStringEscape=!1,this.pendingByteSeq=null,this.pendingChunk=null,this.pos=0,this.jsonParseOffset=0}flush(t,e,s){let n=t.slice(e,s);if(this.jsonParseOffset=this.pos,null!==this.pendingChunk&&(n=this.pendingChunk+n,this.pendingChunk=null),","===n[0]&&(n=n.slice(1),this.jsonParseOffset++),this.flushDepth===this.lastFlushDepth)this.flushDepth>0?(this.jsonParseOffset--,1===this.stack[this.flushDepth-1]?Object.assign(this.valueStack.value,JSON.parse("{"+n+"}")):D(this.valueStack.value,JSON.parse("["+n+"]"))):(this.value=JSON.parse(n),this.valueStack={value:this.value,prev:null});else if(this.flushDepth>this.lastFlushDepth){for(let t=this.flushDepth-1;t>=this.lastFlushDepth;t--)n+=1===this.stack[t]?"}":"]";0===this.lastFlushDepth?(this.value=JSON.parse(n),this.valueStack={value:this.value,prev:null}):(this.jsonParseOffset--,1===this.stack[this.lastFlushDepth-1]?Object.assign(this.valueStack.value,JSON.parse("{"+n+"}")):D(this.valueStack.value,JSON.parse("["+n+"]")));for(let t=this.lastFlushDepth||1;t<this.flushDepth;t++){let e=this.valueStack.value;if(1===this.stack[t-1]){let t;for(t in e);e=e[t]}else e=e[e.length-1];this.valueStack={value:e,prev:this.valueStack}}}else{for(let t=this.lastFlushDepth-1;t>=this.flushDepth;t--)this.jsonParseOffset--,n=(1===this.stack[t]?"{":"[")+n;1===this.stack[this.lastFlushDepth-1]?Object.assign(this.valueStack.value,JSON.parse(n)):D(this.valueStack.value,JSON.parse(n));for(let t=this.lastFlushDepth-1;t>=this.flushDepth;t--