Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
libxmljs-mt
Advanced tools
This project is a fork of libxmljs. The current version 0.18.1 is based on libxmljs 0.18.7 and libxml 2.9.4.
Libxmljs was originally designed with single-threaded operations in mind. There are no asynchroneous operations for things like parsing XML documents. But even more importantly, since the embedded libxml was configured only for single-threaded use, no other package could build on this to provide multi-threaded operations using libxml. The issue is discussed at length in upstream issue 296.
This package here adds multi-threading support to libxmljs. It does offer a method to asynchroneously parse an XML file using
libxmljs.fromXmlAsync(buffer, options, function callback(err, doc) {…});
and it can be used by other packages to provide
more advanced asynchroneous operations.
To do so, the code has to construct a libxmljs::WorkerParent
object
on the V8 thread and then a libxmljs::WorkerSentinel
on the worker thread.
Both of these are RAII sentinels, so they do some setup in their constructor
and some cleaning up in their destructor.
Getting their lifetime right is important.
When using nan, it's easiest to make the WorkerParent
a member
of the class derived from NanAsyncWorker
and have a WorkerSentinel
variable in the Execute
method of that class.
It is to be hoped that this fork is a temporary solution, and that the original libxmljs project will adapt either this solution or a similar one to become usable in a multi-threaded way. But the corresponding bug report has remained open for too long, and even though there was some very valuable discussion going on, there were also long spans with no activity at all. It is hard to tell when this fork will become obsolete, if ever.
Note that this project makes use of a git submodule for the libxml code,
so if you are building from a git checkout you might have to perform
git submodule update --init
before you can do npm install
.
Below comes the documentation from the original project, with only slight modifications where appropriate.
LibXML bindings for node.js
var libxmljs = require("libxmljs-mt");
var xml = '<?xml version="1.0" encoding="UTF-8"?>' +
'<root>' +
'<child foo="bar">' +
'<grandchild baz="fizbuzz">grandchild content</grandchild>' +
'</child>' +
'<sibling>with content!</sibling>' +
'</root>';
var xmlDoc = libxmljs.parseXml(xml);
// xpath queries
var gchild = xmlDoc.get('//grandchild');
console.log(gchild.text()); // prints "grandchild content"
var children = xmlDoc.root().childNodes();
var child = children[0];
console.log(child.attr('foo').value()); // prints "bar"
Check out the wiki http://github.com/libxmljs/libxmljs/wiki.
See the examples folder.
npm install libxmljs-mt
Start by checking out the open issues both for the upstream project and the multi-threaded fork. Specifically the desired feature ones.
Make sure you have met the requirements for node-gyp. You do not need to manually install node-gyp; it comes bundled with node.
FAQs
multi-threaded libxml bindings for v8 javascript engine
The npm package libxmljs-mt receives a total of 344 weekly downloads. As such, libxmljs-mt popularity was classified as not popular.
We found that libxmljs-mt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.