
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
libxml2-wasm
Advanced tools
When comparing the previous two main approaches — pure JavaScript implementation and traditional C implementation binding — WebAssembly offers a unique combination of advantages. It provides excellent performance while maintaining the best compatibility with modern JavaScript runtimes.
Javascript Implementation | Traditional C Binding | WebAssembly | |
---|---|---|---|
Parsing Speed | Average1 | Fast | Fast |
C/C++ Toolchain at Runtime | Not required | Required2 | Not Required |
Prebuilt Binaries | N/A | One for each OS / Runtime / Arch | Universal for all |
Prebuilt Binary Compatibility | N/A | May be broken across libc versions | Very Good |
Browser Compatibility | Yes | No | Yes |
https://jameslan.github.io/libxml2-wasm/index.html
Due to the usage of WebAssembly, ES module and top level await etc, this library requires the minimum version of the following environments,
Environment | Version |
---|---|
Node.js | v16+ |
Chrome | V89+ |
Edge | V89+ |
Safari | v15+ |
Install libxml2-wasm
package:
npm i libxml2-wasm
libxml2-wasm
is an ES module,
the import process differs between ES modules and CommonJS modules.
import fs from 'node:fs';
import { XmlDocument } from 'libxml2-wasm';
const doc1 = XmlDocument.fromString('<note><to>Tove</to></note>');
const doc2 = XmlDocument.fromBuffer(fs.readFileSync('doc.xml'));
doc1.dispose();
doc2.dispose();
const fs = require('node:fs');
import('libxml2-wasm').then(({ XmlDocument }) => {
const doc1 = XmlDocument.fromString('<note><to>Tove</to></note>');
const doc2 = XmlDocument.fromBuffer(fs.readFileSync('doc.xml'));
doc1.dispose();
doc2.dispose();
});
IMPORTANT: dispose()
is required to avoid memory leak.
For more detail, see the Doc.
FAQs
WebAssembly-based libxml2 javascript wrapper
The npm package libxml2-wasm receives a total of 5,404 weekly downloads. As such, libxml2-wasm popularity was classified as popular.
We found that libxml2-wasm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.