
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
This module makes dealing with parsed XML objects easy and painless. Uses Needle's XML formatted objects.
For example, a parsed Needle XML response might look like this:
<NodeName someAttribute="someValue">
<ChildNode>Value 1</ChildNode>
</NodeName>
Becomes:
{
"name": "NodeName",
"value": "",
"attributes": {
"someAttribute": "someValue"
},
"children": [
{
"name": "ChildNode",
"value": "Value 1",
"attributes": {},
"children": []
}
]
}
EZWrap makes dealing with traversing child nodes and attributes easy and reliable. If a node in the path does not exist, no problem. The fluent-like interface handles missing or empty nodes without a problem.
Install like so:
npm i --save ezwrap
const EZWrap = require('ezwrap');
const res = new EZWrap(response.body); // provide the parsed xml object to the constructor
// Get a node attribute
res.attr('someAttribute'); // => someValue
// Get a value from a child node
res.get('ChildNode').value; // => Value 1
// Safely handle missing paths in the XML
res.get('Does').get('Not').get('Exist').value; // => null
Custom inspection is included so that visualizing where you are in the tree is simple.
For example, in the node REPL:
$ node
> const EZWrap = require('ezwrap')
undefined
> const xml = {
... "name": "NodeName",
... "value": "",
... "attributes": {
..... "someAttribute": "someValue"
..... },
... "children": [
... {
..... "name": "ChildNode",
..... "value": "Value 1",
..... "attributes": {},
..... "children": []
..... }
... ]
... }
undefined
> res = new EZWrap(xml)
<NodeName someAttribute="someValue">
<ChildNode ... />
</NodeName>
> res.get('ChildNode')
<ChildNode>
Value 1
</ChildNode>
Really convenient for REPL and debugging, especially with payloads with a ton of child nodes and deep trees.
You can use this module in the browser too. A separate file is included, which has been run through Babel and Browserify for browser compatibility.
new EZWrap(xmlObject)Returns a new wrapped instance where:
xmlObject – the XML-parsed object to wrapezwrap.isWrappedProperty which denotes whether the object is EZWrapped (true)
ezwrap.lengthProperty which returns the number of children the node contains.
ezwrap.valueProperty which returns the value of the node or null if not defined.
ezwrap.nameProperty which returns the name of the node or null if not defined.
ezwrap.attr(name)Gets an attribute value on the node where:
name – is the name of the attributeReturns the value of the attribute or null if not defined.
ezwrap.all(name)Filters children nodes where:
name – is the name of the child nodes to keepReturns an EZWrapped object containing the filtered nodes.
ezwrap.get(name)Gets the first node where:
name – is the name of the child node to getReturns the EZWrapped child object, or a wrapped empty object if not found.
ezwrap.find(closure)Similar to Array.find(), gets the first node where:
closure(node) – is a function called on each child node until the return value is truthy.
node – EZWrapped child nodeReturns the selected EZWrapped node or an empty EZWrapped node if no nodes were matched.
ezwrap.forEach(closure)Similar to Array.forEach(), calls the closure function for each child node.
closure(node) – function called on each child node
node – EZWrapped child nodeezwrap.filter(closure)Similar to Array.filter(), calls the closure function for each child node and keeps the filtered results.
closure(node) – function called on each child node. Return truthy to keep the node in the results.
node – EZWrapped child nodeReturns an EZWrapped object containing the filtered children.
ezwrap.map(closure)Similar to Array.map(), calls the closure function for each child node and returns an array of mapped results.`
closure(node) – function called on each child node. The value returned will be included in the results.
node – EZWrapped child nodeReturns an array of mapped result values.
EZWrap.getEmptyObject([options])Class/static function that generates raw XML-like objects, where:
options:
name: Optional node namevalue: Optional node valueattributes: Optional attributes objectchildren: Optional array of node objectsReturns a raw, unwrapped node object.
There is plenty of room for this module to grow. Feel free to contribute additions!
To build the browser bundle, run:
npm run build
This will update:
dist/ezwrap.jsdist/ezwrap.min.jsdist/ezwrap.min.js.mapTo run the unit tests with code coverage and linting:
npm run report
Included scripts you can run are:
npm run clean – Cleans the distribution and coverage directoriesnpm run build – Builds the browser distributionnpm run test – Runs unit tests without coveragenpm run cover – Runs unit tests with coveragenpm run lint – Runs eslint for code quality checksnpm run report – Runs build, cover, and lintGood luck, and have fun!
FAQs
Easily wrap parsed XML objects for reliable access
We found that ezwrap 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.