Home / Function/ b() — astro Function Reference

b() — astro Function Reference

Architecture documentation for the b() function in levenshtein-string-matcher.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  baf7d8ae_50a7_3b8f_6732_c04b03c46b3f["b()"]
  d6c0cbba_560c_49e8_9eb1_ca2ef141e506["LevenshteinStringMatcher"]
  baf7d8ae_50a7_3b8f_6732_c04b03c46b3f -->|defined in| d6c0cbba_560c_49e8_9eb1_ca2ef141e506
  style baf7d8ae_50a7_3b8f_6732_c04b03c46b3f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/assets/fonts/infra/levenshtein-string-matcher.ts lines 42–118

	#myers_x(b: string, a: string): number {
		const n = a.length;
		const m = b.length;
		const mhc = [];
		const phc = [];
		const hsize = Math.ceil(n / 32);
		const vsize = Math.ceil(m / 32);
		for (let i = 0; i < hsize; i++) {
			phc[i] = -1;
			mhc[i] = 0;
		}
		let j = 0;
		for (; j < vsize - 1; j++) {
			let mv = 0;
			let pv = -1;
			const start = j * 32;
			const vlen = Math.min(32, m) + start;
			for (let k = start; k < vlen; k++) {
				this.#peq[b.charCodeAt(k)] |= 1 << k;
			}
			for (let i = 0; i < n; i++) {
				const eq = this.#peq[a.charCodeAt(i)];
				const pb = (phc[(i / 32) | 0] >>> i) & 1;
				const mb = (mhc[(i / 32) | 0] >>> i) & 1;
				const xv = eq | mv;
				const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb;
				let ph = mv | ~(xh | pv);
				let mh = pv & xh;
				if ((ph >>> 31) ^ pb) {
					phc[(i / 32) | 0] ^= 1 << i;
				}
				if ((mh >>> 31) ^ mb) {
					mhc[(i / 32) | 0] ^= 1 << i;
				}
				ph = (ph << 1) | pb;
				mh = (mh << 1) | mb;
				pv = mh | ~(xv | ph);
				mv = ph & xv;
			}
			for (let k = start; k < vlen; k++) {
				this.#peq[b.charCodeAt(k)] = 0;
			}
		}
		let mv = 0;
		let pv = -1;
		const start = j * 32;
		const vlen = Math.min(32, m - start) + start;
		for (let k = start; k < vlen; k++) {
			this.#peq[b.charCodeAt(k)] |= 1 << k;
		}
		let score = m;
		for (let i = 0; i < n; i++) {
			const eq = this.#peq[a.charCodeAt(i)];
			const pb = (phc[(i / 32) | 0] >>> i) & 1;
			const mb = (mhc[(i / 32) | 0] >>> i) & 1;
			const xv = eq | mv;
			const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb;
			let ph = mv | ~(xh | pv);
			let mh = pv & xh;
			score += (ph >>> (m - 1)) & 1;
			score -= (mh >>> (m - 1)) & 1;
			if ((ph >>> 31) ^ pb) {
				phc[(i / 32) | 0] ^= 1 << i;
			}
			if ((mh >>> 31) ^ mb) {
				mhc[(i / 32) | 0] ^= 1 << i;
			}
			ph = (ph << 1) | pb;
			mh = (mh << 1) | mb;
			pv = mh | ~(xv | ph);
			mv = ph & xv;
		}
		for (let k = start; k < vlen; k++) {
			this.#peq[b.charCodeAt(k)] = 0;
		}
		return score;
	}

Domain

Subdomains

Frequently Asked Questions

What does b() do?
b() is a function in the astro codebase, defined in packages/astro/src/assets/fonts/infra/levenshtein-string-matcher.ts.
Where is b() defined?
b() is defined in packages/astro/src/assets/fonts/infra/levenshtein-string-matcher.ts at line 42.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free