Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Matcher
✓ import { Matcher } from 'marcheur';
✗ const { Matcher } = require('marcheur');
Marcheur is primarily used in ESM environments. Matcher is a core utility for defining pattern-matching conditions.
Nodal
✓ import { Nodal } from 'marcheur/nodal';
✗ const { Nodal } = require('marcheur/nodal');
Nodal is a specialized utility for element creation and attribute remapping, imported from its own sub-path.
qname
✓ import { qname } from 'marcheur/qname';
✗ const { qname } = require('marcheur/qname');
The `qname` function for qualified name parsing and namespace handling is available as a named export from its specific sub-path.
This quickstart demonstrates how to define and apply transformation rules to a JavaScript object tree using Marcheur's `Matcher` and `qname` utilities. It illustrates a conceptual `createTreeWalker` for processing.
import { createTreeWalker } from 'marcheur'; // Hypothetical core processor builder
import { Matcher } from 'marcheur';
import { qname } from 'marcheur/qname';
// Example source data representing an XML-like JS object tree
const document = {
element: 'root',
attrs: { 'xmlns:foo': 'http://foo.com/ns', version: '1.0' },
children: [
{ element: 'item', attrs: { id: 'a' }, children: ['Text A'] },
{ element: 'foo:data', attrs: { value: '123' }, children: ['Some Foo Data'] },
],
};
const nsMap = { foo: 'http://foo.com/ns' };
// Define transformation rules using Matcher and qname for pattern matching
const rules = [
{
// Match any 'item' element and transform it
match: new Matcher().element('item'),
apply: (node) => ({
element: 'transformedItem',
attrs: { ...node.attrs, processed: 'true' },
children: node.children.map(c => typeof c === 'string' ? `MODIFIED: ${c}` : c),
}),
},
{
// Match 'foo:data' using qname for namespace-aware matching
match: new Matcher().element(qname('foo:data', nsMap)),
apply: (node) => ({
element: 'foo:transformedData',
attrs: { originalValue: node.attrs.value },
children: ['Namespace handled!'],
}),
},
{
// Default rule: copy nodes and recurse for unmatched elements
match: new Matcher().any(), // Assumes a generic 'any' matcher
apply: (node, walk) => {
if (typeof node === 'string') return node; // Handle text nodes
return {
...node,
children: node.children ? node.children.map(walk) : [],
};
},
},
];
// Hypothetical function to create and execute a tree walker/processor
const walker = createTreeWalker(rules); // 'createTreeWalker' is an assumed API
const transformedDoc = walker.walk(document);
console.log('Original Document:', JSON.stringify(document, null, 2));
console.log('\nTransformed Document:', JSON.stringify(transformedDoc, null, 2));
// Direct usage of the qname utility
const qualifiedNameInfo = qname('foo:bar', nsMap);
console.log('\nqname("foo:bar", nsMap):', qualifiedNameInfo);
// Expected output: { ns: 'http://foo.com/ns', ln: 'bar' }
const simpleNameInfo = qname('baz');
console.log('qname("baz"):', simpleNameInfo);
// Expected output: { qn: 'baz' }
Audit
Dependencies
No dependency data recorded yet.