Socket
Book a DemoInstallSign in
Socket

libxml2-wasm

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libxml2-wasm

Bring libxml2 to browsers using WebAssembly

Source
npmnpm
Version
0.0.5
Version published
Weekly downloads
2.6K
-59.29%
Maintainers
1
Weekly downloads
 
Created
Source

libxml2-wasm

CI Build on master npm

Disclaimer

Current version is for feasibility/performance evaluation only

The api may have breaking changes in patch versions.

Why another xml lib?

Compiling C library libxml2 to WebAssembly brings benefits of both pure javascript implementation or native addons, and avoided their drawbacks:

  • Good performance: roughly same as the native addons, and much better than pure javascript implementations
  • Better compatibility: don't need to compile to every platform, nodeJs version, or dependency libraries(e.g. glibc); and supports browsers too.
  • Comprehensive functionality(To be finished): backed by libxml2, we just need some wrappers being callable by javascript.

Documentation

https://jameslan.github.io/libxml2-wasm/index.html

Supported Environments

This library uses ES Module and top level await, so it require the following environment.

EnvironmentVersion
NodeJsv14.8+
ChromeV89+
EdgeV89+
Safariv15+

Benchmark

To run the benchmark, build the lib first,

npm ci && npm run build

Then run test in benchmark directory,

cd benchmark && npm ci
npm test

libxmljs2 is js binding to native library libxml2; while fast-xml and xmldoc are pure javascript implementations.

Environment: NodeJs v18.17.1 on Darwin x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz

Running "fixtures/small.xml: 787 chars" suite...
Progress: 100%

  libxml2-wasm:
    59 122 ops/s, ±3.49%   | fastest

  libxmljs2:
    20 392 ops/s, ±10.93%   | 65.51% slower

  fast-xml-parser:
    15 433 ops/s, ±6.45%   | 73.9% slower

  xmldoc:
    12 842 ops/s, ±4.01%   | slowest, 78.28% slower

Running "fixtures/medium.xml: 35562 chars" suite...
Progress: 100%

  libxml2-wasm:
    2 294 ops/s, ±3.21%   | 32.75% slower

  libxmljs2:
    3 411 ops/s, ±10.12%   | fastest

  fast-xml-parser:
    845 ops/s, ±3.29%     | 75.23% slower

  xmldoc:
    720 ops/s, ±2.75%     | slowest, 78.89% slower

Running "fixtures/large.xml: 2337522 chars" suite...
Progress: 100%

  libxml2-wasm:
    18 ops/s, ±3.66%   | fastest

  libxmljs2:
    12 ops/s, ±28.60%   | 33.33% slower

  fast-xml-parser:
    6 ops/s, ±6.83%    | 66.67% slower

  xmldoc:
    4 ops/s, ±8.64%    | slowest, 77.78% slower

FAQs

Package last updated on 12 Oct 2023

Did you know?

Socket

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.

Install

Related posts