npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

beans-xml

v0.1.1

Published

WebAssembly bindings for beans-xml (Spring Framework <beans> XML parser)

Readme

beans-xml

WebAssembly bindings for beans-xml — a lenient parser for Spring Framework <beans> XML configuration.

const beansXml = require("beans-xml");

const bytes = fs.readFileSync("applicationContext.xml"); // Buffer, NOT a decoded string
const result = JSON.parse(beansXml.parse(bytes)); // schema v1, see schema/beans-xml.v1.json
const isBeansDoc = beansXml.is_beans_doc(bytes); // cheap root-element pre-check

Node.js target only — no browser/bundler build yet. This package is built with wasm-pack --target nodejs (CommonJS, loads the .wasm via fs.readFileSync at require time). It will not work as-is in a browser or with a bundler expecting --target web/--target bundler output (fetch-based instantiation, ESM). That's a separate build target to add later, not a difference in the Rust source.

Two things that will bite you

(a) Feed raw bytes — never a host-pre-decoded string. Always pass the file's original Buffer/Uint8Array to parse/is_beans_doc, not a string you already decoded (e.g. fs.readFileSync(path, "utf-8") then re-encoded). beans-xml detects the encoding itself (BOM sniff, UTF-8, XML declaration encoding= label, an EUC-KR heuristic for declaration-less legacy files, then a lossy fallback) — result.encoding reports which of these won. Feeding it bytes that already went through a host UTF-8 decoder defeats all of that, since a genuinely non-UTF-8 file would already have been mangled (replacement characters) before beans-xml ever sees it.

(b) Spans are byte offsets into the UTF-8 text beans-xml itself decoded — never JS string indices, and never the original file's raw bytes for anything but a UTF-8 source. Every ByteSpan { start, end } in the JSON indexes into the UTF-8 bytes of the decoded text, while a JS string is indexed by UTF-16 code units — these diverge the moment a multi-byte character (e.g. Korean identifiers) appears before the offset you care about. result.encoding (the WHATWG name TextDecoder accepts directly) is what makes this reproducible:

// bytes is the same Buffer/Uint8Array you fed to parse()
const decodedText = new TextDecoder(result.encoding).decode(bytes);
const utf8Bytes = new TextEncoder().encode(decodedText); // byte-identical to beans-xml's own internal String
const text = new TextDecoder("utf-8").decode(
  utf8Bytes.subarray(span.start, span.end)
);

If the input was plain UTF-8, bytes and utf8Bytes are already byte-identical (decoding then re-encoding UTF-8 is a no-op), so slicing bytes directly happens to work in that one case — but relying on that silently breaks the moment a file turns out to be EUC-KR/CP949/UTF-16/ etc., which is exactly the failure mode result.encoding exists to prevent. Always go through the TextDecoder/TextEncoder round trip above regardless of what encoding you expect.

References are raw

ref="beanA" / bean="beanA" / local="beanA" / parent="beanA" are recorded as the raw name beanA in BeanRef.raw — resolving it to an actual bean (across imported files, component-scan-declared beans, or XML-vs-annotation config) is the consumer's job. A parser sees one file.