PageSourceSearch

https://spectreconsole.net/_content/DeweySearch.Web/dewey-search.js?v=639198145617580888

js spectreconsole.net collected 2026-10-02 07:46:49 UTC 6,680 bytes, 1 lines download raw bytes

1(function(e){"use strict";class t{constructor(e){this.base=(e||"").replace(/\/+$/,""),this.manifest=null,this.shards=new Map,this.fragments=new Map,this.inflight=new Map,this._shardSet=new Set,this._psz=2,this._maxEdit=2}_url(e){return this.base?`${this.base}/${e}`:e}async loadManifest(){if(this.manifest)return this.manifest;const e=await fetch(this._url("index.json"));if(!e.ok)throw new Error(`DeweySearch index ${e.status}`);return this.manifest=await e.json(),this._shardSet=new Set(this.manifest.shards||[]),this._psz=this.manifest.psz||2,this._maxEdit=this.manifest.med!=null?this.manifest.med:2,this.manifest}availableFacets(){return this.manifest&&this.manifest.facets||{}}docEntry(e){return this.manifest&&this.manifest.docs?this.manifest.docs[e]:null}matchesFacets(e,t){if(!t)return!0;const n=this.docEntry(e),s=n&&n.f||{};for(const n of Object.keys(t)){const e=t[n];if(!e||e.size===0)continue;const o=s[n]||[];if(!o.some(t=>e.has(t)))return!1}return!0}_prefixOf(e){return e.length<=this._psz?e:e.slice(0,this._psz)}async _loadShard(e){if(this.shards.has(e))return this.shards.get(e);if(!this._shardSet.has(e))return this.shards.set(e,null),null;const t=this._url(`t-${e}.json`);if(this.inflight.has(t))return this.inflight.get(t);const n=fetch(t).then(e=>e.ok?e.json():null).then(n=>{const s=n?n.terms:null;return this.shards.set(e,s),this.inflight.delete(t),s}).catch(()=>(this.inflight.delete(t),this.shards.set(e,null),null));return this.inflight.set(t,n),n}async loadFragment(e){if(this.fragments.has(e))return this.fragments.get(e);const t=this._url(`f-${e}.json`);if(this.inflight.has(t))return this.inflight.get(t);const n=fetch(t).then(e=>e.ok?e.json():null).then(n=>(this.fragments.set(e,n),this.inflight.delete(t),n)).catch(()=>(this.inflight.delete(t),null));return this.inflight.set(t,n),n}_expand(e){const t=[e],n=this.manifest&&this.manifest.syn||{};if(n[e])for(const s of n[e])t.includes(s)||t.push(s);return t}_budget(e){const t=e<=3?0:e<=6?1:2;return Math.min(t,this._maxEdit)}async search(e){await this.loadManifest();const s=[...new Set(t._tokenize(e))];if(s.length===0)return[];const h=this.manifest.n||0,c=this.manifest.avgdl||1,n=this.manifest.docs||[],l=1.2,d=.75,o=new Map,i=new Map,a=new Map;for(const r of s){const u=this._expand(r),e=new Map;for(const s of u){const m=s!==r,o=await this._loadShard(this._prefixOf(s));if(!o)continue;const i=this._budget(s.length);for(const r of Object.keys(o)){let u=0;if(r===s)u=1;else if(s.length>=2&&r.length>s.length&&r.startsWith(s)&&(u=.9*(s.length/r.length)),i>0&&r.charCodeAt(0)===s.charCodeAt(0)){const e=t._editDistance(s,r,i);e!==1/0&&(u=Math.max(u,1/(1+e)))}if(u<=0)continue;m&&(u*=.5);const f=o[r],p=f.length,g=Math.log(1+(h-p+.5)/(p+.5));for(const[s,o,i]of f){const h=n[s]&&n[s].l||c,m=i*(l+1)/(i+l*(1-d+d*h/c)),r=g*m*t._fieldBoost(o)*u;r>(e.get(s)||0)&&e.set(s,r),a.set(s,(a.get(s)||0)|o)}}}for(const[t,n]of e)o.set(t,(o.get(t)||0)+n),i.set(t,(i.get(t)||0)+1)}const m=s.length,u=t._normalizeTitle(e),r=[];for(const[e,l]of o){const s=i.get(e)/m,d=n[e]&&n[e].p||1,c=n[e],h=u&&c&&t._normalizeTitle(c.t)===u?t.EXACT_TITLE_BOOST:1;r.push({docId:e,score:l*s*s*d*h,fields:a.get(e)||0})}return r.sort((e,t)=>t.score-e.score),r}static FieldFlags=Object.freeze({Title:1,Heading:2,Description:4,Body:8});static _fieldBoost(e){let t=0;return e&1&&(t+=4),e&2&&(t+=2),e&4&&(t+=2),e&8&&(t+=1),t===0?1:t}static EXACT_TITLE_BOOST=6;static _normalizeTitle(e){return(e||"").normalize("NFD").replace(/\p{Mn}/gu,"").toLowerCase().replace(/[^a-z0-9]+/g,"")}static _IRREGULAR=Object.freeze({addenda:"addendum",algae:"alga",alumni:"alumnus",analyses:"analysis",antennae:"antenna",apices:"apex",appendices:"appendix",automata:"automaton",bacteria:"bacterium",cacti:"cactus",calves:"calf",children:"child",corpora:"corpus",cortices:"cortex",crises:"crisis",criteria:"criterion",curricula:"curriculum",data:"datum",diagnoses:"diagnosis",ellipses:"ellipsis",elves:"elf",emphases:"emphasis",errata:"erratum",feet:"foot",foci:"focus",formulae:"formula",fungi:"fungus",geese:"goose",genera:"genus",halves:"half",helices:"helix",hooves:"hoof",hypotheses:"hypothesis",indices:"index",knives:"knife",larvae:"larva",leaves:"leaf",lice:"louse",lives:"life",loaves:"loaf",matrices:"matrix",maxima:"maximum",media:"medium",memoranda:"memorandum",men:"man",mice:"mouse",millennia:"millennium",minima:"minimum",minutiae:"minutia",nebulae:"nebula",
1nuclei:"nucleus",oases:"oasis",optima:"optimum",oxen:"ox",parentheses:"parenthesis",phenomena:"phenomenon",prognoses:"prognosis",radii:"radius",referenda:"referendum",scarves:"scarf",schemata:"schema",selves:"self",shelves:"shelf",spectra:"spectrum",stadia:"stadium",stimuli:"stimulus",strata:"stratum",syllabi:"syllabus",symposia:"symposium",syntheses:"synthesis",teeth:"tooth",termini:"terminus",theses:"thesis",thieves:"thief",vertebrae:"vertebra",vertices:"vertex",vortices:"vortex",wives:"wife",wolves:"wolf",women:"woman"});static _stem(e){if(!e)return e;const s=t._IRREGULAR[e];s&&(e=s);const n=e.length;if(n>4&&e.endsWith("ies"))return e.slice(0,n-3)+"y";if(n>3&&e.endsWith("es")){const t=e[n-3],s=t==="s"||t==="x"||t==="z"||e.endsWith("ches")||e.endsWith("shes");return s?e.slice(0,n-2):e.slice(0,n-1)}return n>3&&e[n-1]==="s"&&e[n-2]!=="s"?e.slice(0,n-1):e}static _tokenize(e){if(!e)return[];const o=e.normalize("NFD").replace(/[\u0300-\u036f]/g,""),s=[];let n="";for(const e of o)if(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9")n+=e;else if(n){for(const e of t._emitRun(n))s.push(e);n=""}if(n)for(const e of t._emitRun(n))s.push(e);return s}static _emitRun(e){const o=t._splitIdentifier(e),n=new Set,s=[];for(const i of o){const e=t._stem(i.toLowerCase());e&&!n.has(e)&&(n.add(e),s.push(e))}if(o.length>1){const o=t._stem(e.toLowerCase());n.has(o)||(n.add(o),s.push(o))}return s}static _splitIdentifier(e){const t=e=>e>="A"&&e<="Z",o=e=>e>="a"&&e<="z",i=e=>e>="0"&&e<="9",n=[];let s=0;for(let a=1;a<e.length;a++){const r=e[a-1],c=e[a],l=o(r)&&t(c)||t(r)&&t(c)&&a+1<e.length&&o(e[a+1])||i(r)!==i(c);l&&(n.push(e.slice(s,a)),s=a)}return n.push(e.slice(s)),n}static _editDistance(e,t,n){const i=e.length,s=t.length;if(Math.abs(i-s)>n)return 1/0;let o=new Array(s+1);for(let e=0;e<=s;e++)o[e]=e;for(let r=1;r<=i;r++){const a=new Array(s+1);a[0]=r;let c=r;for(let n=1;n<=s;n++){const i=e.charCodeAt(r-1)===t.charCodeAt(n-1)?0:1;a[n]=Math.min(o[n]+1,a[n-1]+1,o[n-1]+i),a[n]<c&&(c=a[n])}if(c>n)return 1/0;o=a}return o[s]<=n?o[s]:1/0}}function n(e){return t._tokenize(e)}function s(e){return t._stem(e)}e&&(e.DeweySearchEngine=t),typeof module!="undefined"&&module.exports&&(module.exports={DeweySearchEngine:t,tokenize:n,stem:s})})(typeof globalThis!="undefined"?globalThis:this)

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.