npm.io
2.30.0 • Published 1 week ago

@esposter/xml2js

Licence
Apache-2.0
Version
2.30.0
Deps
3
Size
1.1 MB
Vulns
0
Weekly
634
Stars
23

@esposter/xml2js

Apache-2.0 licensed NPM version NPM downloads NPM Unpacked Size (with version)

Inspired by xml2js.

A complete rewrite from CoffeeScript to TypeScript that removes unnecessary dependencies like events — resolving issues such as this.removeAllListeners is not a function. Retains all the options and behaviour of the original xml2js. Use parseStringPromise as the primary parsing API.

Table of Contents


Getting Started

pnpm i @esposter/xml2js

Documentation

We highly recommend you take a look at the documentation to level up.

Usage
import { parseStringPromise } from "@esposter/xml2js";

const xml = `<root><child attr="value">text</child></root>`;
const result = await parseStringPromise(xml);
// result: { root: { child: [ { _: 'text', $: { attr: 'value' } } ] } }
Why Not the Original xml2js?

The original package pulls in the events module which causes runtime errors in certain bundler/edge environments. This rewrite is a drop-in replacement that works cleanly in Node.js, Azure Functions, and browser bundles.

Commands

Run from packages/xml2js/:

pnpm build        # compile to dist/
pnpm test         # vitest watch mode (coverage is run from the repo root)
pnpm lint:fix     # auto-fix lint
pnpm typecheck    # type check

License

This project is licensed under the Apache-2.0 license.

Keywords