npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

x2js

v3.4.4

Published

Transforms between XML string and JavaScript object trees.

Downloads

149,875

Readme

x2js

This is a library that converts between XML and JavaScript objects. The conversion is not necessarily lossless but it is very convenient.

npm version

master | development ------ | ----------- Build Status | Build Status

Integration

The code is all contained within the x2js.js file, so you can include it directly via a script tag. It will create window.X2JS, which is a constructor that can be used to create instances of the converter, providing an optional configuration object.

In a Node app, require("x2js") will give you the constructor that you can use the same way.

Loading via AMD-capable loaders (e.g. require.js) is also supported and works equivalently.

The xmldom package is a dependency but it is only used under Node, as in browsers the browser DOM is used.

Quick start

var x2js = new X2JS();
var document = x2js.xml2js(xml);

console.log(document.MyRootElement.ElementX[1].toString());

var xml = x2js.js2xml(document);
console.log(xml);

See the type definitions within x2js.d.ts for information about what configuration options you can pass.

Automated tests

A set of QUnit test cases are part of the project and act as the primary usage examples.

Run karma start --single run to test with Chrome, Firefox and IE. Run node_modules\.bin\qunit-cli all_tests.js to test with the Node runtime. Run npm test to execute both sets of tests.

Travis CI uses npm travistest to run tests using Firefox via Karma and Node.

Contributing

Contributions are welcome! To ensure speedy merges, please:

  • base any pull requests on the development branch.
  • ensure that the code passes ESLint validation with the included ruleset.

Commit Message Guidelines

We want to have a comitizen friendly formatted commit messages. This leads to more readable messages that are easy to follow when looking through the project history. But also, we use the git commit messages to generate the change log.

Commit Message Format

The commit message must respect this format that includes a type, a scope and a subject:

<type>(<scope>): <subject>

The header is mandatory and the scope of the header is optional.

Any line of the commit message cannot be longer 100 characters! This allows the message to be easier to read on GitHub as well as in various git tools.

Type

Must be one of the following:

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system, CI configuration or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Configuration files
  • chore: Other changes that don't modify src or test files
  • revert: Revert another commit
  • quiet: Not documented in readme.md

Scope

The scope could be anything specifying place of the commit change. For example DejaDatePicker, DejaMonacoEditor, etc.

Subject

The subject contains succinct description of the change:

  • use the imperative, present tense: "change" not "changed" nor "changes"
  • don't capitalize first letter
  • no dot (.) at the end

Breaking Changes should start with the word BREAKING CHANGE: with a space or two newlines. The rest of the commit message is then used for this.