PageSourceSearch

https://www.robotmesh.com/studio/content/jsx/robotmesh/tsjs/robotmesh.webworker/nonmodules/util_general.js

js robotmesh.com collected 2026-09-24 12:52:58 UTC 11,831 bytes, 1 lines download raw bytes

1var util,DataFormat;!function(e){var t=null;function n(...e){}function r(e){return null==e}function o(e,t,n=0){if(!e)return-1;const r="function"==typeof t;for(var o=n;o<e.length;o++)if(r&&t(e[o])||!r&&t===e[o])return o;return-1}function s(e,t,n=-1){if(!e)return-1;n<0&&(n=e.length+n);const r="function"==typeof t;for(var o=n;o>=0;o--)if(r&&t(e[o])||!r&&t===e[o])return o;return-1}function i(e,t){return e.splice(t,1)[0]}function u(e){var t="";for(let n=0;n<e.length;n+=2){const r=e[n];t+=r<32&&0!=r&&13!=r&&10!=r&&9!=r?"\\x"+d(r):String.fromCharCode(r)}return t}function a(e){const t=f.atob(e);let n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function c(e){const t=function(e){let t=[];if(e instanceof Uint8Array)for(let n=0;n<e.length;n+=16384)t.push(String.fromCharCode.apply(null,e.subarray(n,n+16384)));else for(let n=0;n<e.length;n+=16384)t.push(String.fromCharCode.apply(null,e.slice(n,n+16384)));return t.join("")}(e);return f.btoa(t)}let f;function l(e){let t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2){var n=e.substr(r,2);
1t[r/2]=parseInt(n,16)}return t}function h(e){var t="";return e.forEach((e,n)=>{t+=d(e)}),t}function g(e){for(var t=[],n=0;n<e.length;n+=2){var r=e.substr(n,2);t.push(parseInt(r,16))}return t}function d(e){if(-1==e&&(e=255),e<0||e>255)throw Error("byte out of range: "+e);var t=e.toString(16);return 1==t.length&&(t="0"+t),t}function x(e){var t="";return e.forEach((e,n)=>{t+=d(e)}),t}function p(e){const t=new Uint8Array[e.length];for(var n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function m(e,t){return e>>8*t&255}function y(e,t,n=null){return null==n&&(n=e.length/2-t),e.length<2*(t+n)?null:e.substr(2*t,2*n)}e.logFn=n,e.logErrFn=n,function(){if("undefined"!=typeof console&&console.log&&console.error){let t="undefined"!=typeof global?global:self;t.cefIsActive&&t.nwjsIsActive?(e.logFn=(...e)=>console.log(e?e.join(", "):""),e.logErrFn=(...e)=>console.error(e?e.join(", "):"")):(e.logFn=console.log,e.logErrFn=console.error)}}(),e.logEnable=function(...e){null==t&&(t={}),e&&e.forEach(e=>{e.toLowerCase().indexOf("err")>=0?t[e]={isError:!0}:t[e]={}})},e.logDisable=function(...e){null!=t&&(e?e.forEach(e=>{delete t[e]}):t=null)},e.log=function(n,r,...o){if(t){var s=t[n];if(void 0!==s){"function"==typeof r&&(r=r());var i=[n,r];o&&i.push.apply(i,o),s.isError?e.logErrFn.apply(console,i):e.logFn.apply(console,i)}}},e.assert=function(e,t){if(!e)throw new Error(t||"Assertion failed")},e.assertEqual=function(e,t,n){if(e!=t)throw console.error("expected:",e),console.error("  actual:",t),new Error(n||"Assertion failed: not equal")},e.isNullOrUndefined=r,e.assertNotNullOrUndefined=function(e){if(r(e))throw new Error("Assertion failed: null or undefined")},e.endsWith=function(e,t){return-1!==e.indexOf(t,e.length-t.length)},e.startsWith=function(e,t){return-1!==e.lastIndexOf(t,0)},e.ord=function(e){if(e&&0!=e.length)return e.charCodeAt(0)},e.replaceBetween=function(e,t,n,r,o){e=e.replace(/\r\n/g,"\n"),t=t.replace(/\r\n/g,"\n"),n=n.replace(/r\n/g,"\n");let s=e.indexOf(t);if(-1!=s){let o=e.indexOf(n,s+t.length);if(-1!=o)return e=e.substr(0,s)+r+e.substr(o+n.length)}return o?o(e,r):e},e.toCamelCase=function(e,t=!1){return(e=e.replace(/_/g," ")).replace(/(?:^\w|[A-Z]|\b\w)/g,(function(e,n){return 0==n&&t?e.toLowerCase():e.toUpperCase()})).replace(/\s+/g,"")},e.toSnakeCase=function(e){let t=[];t=-1!==e.indexOf(" ")?e.split(" "):e.split("(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])");for(let e=0;e<t.length;e++)t[e]=t[e].toLowerCase();return t.join("_")},e.split=function(e,t,n=null){let r=e.split(t);if(null!=n&&r.length>n){const e=r.slice(n-1);r=r.slice(0,n-1),r[n-1]=e.join(t)}return r},e.indexOf=o,e.lastIndexOf=s,e.contains=function(e,t){return-1!==o(e,t)},e.find=function(e,t,n=0){var r=o(e,t,n);if(-1!=r)return e[r]},e.grep=function(e,t){var n=[];if(!e)return n;for(var r=0;r<e.length;r++)t(e[r])&&n.push(e[r]);return n},e.findLast=function(e,t,n=-1){var r=s(e,t,n);if(-1!=r)return e[r]},e.removeAt=i,e.removeItem=function(e,t){const n=o(e,t);-1!==n&&i(e,n)},e.insertBefore=function(t,n,r){const o=e.indexOf(t,e=>e===n);e.assert(-1!==o,`"List doesn't contain ${n}`),t.splice(o,0,r)},e.sort=function(e,t,n=!1){e.sort((e,r)=>{const o=t(e),s=t(r);let i=o<s?-1:o>s?1:0;return n&&(i*=-1),i})},e.pushToValueList=function(e,t,n){t in e||(e[t]=[]),null!=n&&null!=n&&e[t].push(n)},e.removeFromValueList=function(e,t,n){var r=e[t];if(!r)return!1;var o=r.indexOf(n);return-1!=o&&(r.splice(o,1),!0)},e.repeatString=function(e,t){return t<1?"":Array(t+1).join(e)},e.deepEquals=function e(t,n,r=0){if(t===n)return!0;if(null==t||null==t||null==n||null==n)return!1;const o=typeof t;if(o!==typeof n||"number"===o||"string"===o||"boolean"===o)return!1;if(Object.keys(t).length!==Object.keys(n).length)return!1;for(var s in t)if(0===r){if(t[s]!=n[s])return!1}else if(!e(t[s],n[s],--r))return!1;return!0},e.generateGuid=function(e=!1){let t=(new Date).getTime();return"undefined"!=typeof performance&&"function"==typeof performance.now&&(t+=performance.now()),(e?"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx":"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx").replace(/[xy]/g,(function(e){const n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?n:3&n|8).toString(16)}))},e.hexToAscii=function(e){for(var t="",n=0;n<e.length;n+=2){var r=e.substr(n,2),o=parseInt(r,16);t+=o<32&&0!=o&&13!=o&&10!=o&&9!=o?"\\x"+r:String.fromCharCode(o)}return t},e.bytesToAscii=u,e.hexUtf8ToString=function(e,t=!1){const n=function(e){var t,n,r,o,s,i;t="",r=e.length,n=0;for(;n<r;)switch((o=e[n++])>>
14){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t+=String.fromCharCode(o);break;case 12:case 13:s=e[n++],t+=String.fromCharCode((31&o)<<6|63&s);break;case 14:s=e[n++],i=e[n++],t+=String.fromCharCode((15&o)<<12|(63&s)<<6|(63&i)<<0)}return t}(g(e));let r="";for(let e=0;e<n.length;e++){const o=n.charCodeAt(e);if(t&&0==o)break;r+=o<32&&0!=o&&13!=o&&10!=o&&9!=o?"\\x"+o.toString(16):String.fromCharCode(o)}return r},e.bytesPad=function(e,t){const n=e.length%t;if(0==n)return e;const r=new Uint8Array(e.length+(t-n));return r.set(e,0),r},e.base64toBytesPad=function(e){const t=f.atob(e);let n,r=4*Math.ceil(t.length/4),o=new Uint8Array(r);for(n=0;n<t.length;n++)o[n]=t.charCodeAt(n);for(;n<r;n++)o[n]=0;return o},e.base64toNumbers=function(e){const t=f.atob(e);let n=[];for(let e=0;e<t.length;e++)n.push(t.charCodeAt(e));return n},e.base64toBytes=a,e.bytesToBase64=c,function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function n(e){this.message=e}n.prototype=new Error,n.prototype.name="InvalidCharacterError",e.btoa=function(e){for(var r,o,s=String(e),i=0,u=t,a="";s.charAt(0|i)||(u="=",i%1);a+=u.charAt(63&r>>8-i%1*8)){if((o=s.charCodeAt(i+=3/4))>255)throw new n("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|o}return a},e.atob=function(e){var r=String(e).replace(/[=]+$/g,"");if(r.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var o,s,i=0,u=0,a="";s=r.charAt(u++);~s&&(o=i%4?64*o+s:s,i++%4)?a+=String.fromCharCode(255&o>>(-2*i&6)):0)s=t.indexOf(s);return a}}(f||(f={})),e.bytesToBase64_native=function(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),s=o.byteLength,i=s%3,u=s-i,a=0;a<u;a+=3)n+=r[(16515072&(t=o[a]<<16|o[a+1]<<8|o[a+2]))>>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==i?n+=r[(252&(t=o[u]))>>2]+r[(3&t)<<4]+"==":2==i&&(n+=r[(64512&(t=o[u]<<8|o[u+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n},e.stringToUTF8Array=function(e){const t=[];for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t.push(r):r<2048?t.push(192|r>>6,128|63&r):r<55296||r>=57344?t.push(224|r>>12,128|r>>6&63,128|63&r):t.push(239,191,189)}return t},e.toBytes=function(e,t=DataFormat.Hex){switch(t){default:case DataFormat.Hex:return l(e);case DataFormat.Ascii:return p(e);case DataFormat.Base64:return a(e)}},e.fromBytes=function(e,t=DataFormat.Hex){switch(t){default:case DataFormat.Hex:return h(e);case DataFormat.Ascii:return u(e);case DataFormat.Base64:return c(e)}},e.indexOfBytes=function(e,t){if(!e||!t||0===t.length)return;let n=0,r=0;for(;n<e.length;){if(e[n]===t[r]){if(r===t.length-1)return n-r;r++}else r=0;n++}return-1},e.hexToBytes=l,e.bytesToHex=h,e.bytesToNumbers=function(e){return[].slice.call(e)},e.numbersToBytes=function(e){return new Uint8Array(e)},e.hexToNumbers=g,e.byteToHex=d,e.numbersToHex=x,e.asciiToNumbers=function(e){const t=[];for(var n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t},e.asciiToBytes=p,e.asciiToHex=function(e){for(var t="",n=0;n<e.length;n++){t+=d(e.charCodeAt(n))}return t},e.addressToHex=function(e){return x([m(e,0),m(e,1),m(e,2),m(e,3)])},e.uint32ToHex=function(e,t=!1){return x(t?[m(e,0),m(e,1),m(e,2),m(e,3)]:[m(e,3),m(e,2),m(e,1),m(e,0)])},e.hexToUint32=function(e,t,n=!1){var r=g(y(e,t,4));return n?(r[3]<<24)+(r[2]<<16)+(r[1]<<8)+r[0]:(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3]},e.uint16ToHex=function(e){return x([m(e,1),m(e,0)])},e.hexToUint16=function(e,t){var n=g(y(e,t,2));return(n[0]<<8)+n[1]},e.getIntByte=m,e.hexSubstr=y;const b=/(\{+)([_a-zA-Z0-9]+)(,\d+)?(:.+?)?(\})/g;function v(e,t){return e=(e=(e=e.replace(b,(...n)=>{if(n[1].length%2==0)return n[0];const r=n[2];if(void 0===t)throw new Error("format '"+e+"': no args specified");const o=t[r];if(void 0===o)throw new Error("format '"+e+"': "+r+" not defined in "+JSON.stringify(t));return o}
1)).replace(/{{/g,"{")).replace(/}}/g,"}")}e.format=function(e,t){return v(e,t)},e.formatInvariant=v,e.padLeft=function(e,t,n=" "){return Array(t-String(e).length+1).join(n)+e},e.formatEnum=function(t,n,r){const o=r;if(isNaN(o))throw new Error("enum value not a number");const s=n[o];if(void 0===s)return e.log("ERROR_i18n","No enum key: ",n,s),""+o;const i=t[s];return void 0===i?(e.log("ERROR_i18n","No enum message: ",n,s),s):i},e.executeFunction=function(e,t,n){const r=e.pop();for(const n of e)t=t[n];return t[r].apply(t,n)},e.colorFromHash=function(e,t=100,n=30){const r=function(e){if("number"==typeof e)return 2654435761*e%Math.pow(2,32);{let t=0;if(!e||0==e.length)return t;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t),t&=t;return t}}(e);return`hsl(${Math.abs(r%360)}, ${t}%, ${n}%)`};e.Deferred=class{constructor(e){this._timeout=e,this._state="pending",this._promise=new Promise((e,t)=>{this.resolve=t=>{"pending"===this._state&&(this._state="resolved"),e&&e(t)},this.reject=e=>{"pending"===this._state&&(this._state="rejected"),t&&t(e)}}),this._timeout&&setTimeout(()=>this.reject("timeout"),this._timeout)}promise(){return this._promise}state(){return this._state}},e.delay=function(e){return new Promise((t,n)=>{setTimeout(()=>t(),e)})};e.ConsecutiveAsyncOps=class{constructor(){this.queue=[],this.currentProcessRequestNum=0}enqueue(t){e.log("AsyncOps","enqueue: ",t.debugMsg);const n=new e.Deferred(t.timeout),r=this.queue.length>0;return this.queue.push({dfd:n,fn:t.fn,debugMsg:t.debugMsg}),r||this.processRequests(),n.promise()}async processRequests(){const t=++this.currentProcessRequestNum;for(e.log("AsyncOps","processRequests: start",this.queue.length);this.queue.length>0;){const t=this.queue[0];if(e.log("AsyncOps","processRequests: proc",t&&t.debugMsg?t.debugMsg:t),t&&"pending"===t.dfd.state()){let e;try{e=await t.fn()}catch(e){t.dfd.reject(e),t.dfd=null}t.dfd&&(t.dfd.resolve(e),t.dfd=null)}this.queue.splice(0,1)}if(t!==this.currentProcessRequestNum)throw new Error("ConsecutiveAsyncOps bug: executing simultaneous requests");e.log("AsyncOps","processRequests: end",this.queue.length)}rejectAll(t){e.log("AsyncOps","rejectAll",this.queue.length);for(const e of this.queue)e.dfd.reject(t);this.queue=[]}}}(util||(util={})),function(e){e[e.Base64=1]="Base64",e[e.Ascii=2]="Ascii",e[e.Hex=3]="Hex"}(DataFormat||(DataFormat={}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.