Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oniyi-utils-xml

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oniyi-utils-xml - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

33

lib/utils.js

@@ -8,3 +8,3 @@ 'use strict';

const xpath = require('xpath');
const isString = require('lodash.isstring');
const _ = require('lodash');

@@ -17,3 +17,3 @@ // internal modules

const parse = (xmlString, mimeType = 'text/xml', parserOptions = {}) => {
const safeMimeType = (isString(mimeType) && mimeType) || 'text/xml';
const safeMimeType = (_.isString(mimeType) && mimeType) || 'text/xml';

@@ -30,4 +30,30 @@ const parser = new DOMParser(parserOptions);

const ensureXMLDoc = stringOrXMLDoc => (isString(stringOrXMLDoc) && parse(stringOrXMLDoc)) || stringOrXMLDoc;
const ensureXMLDoc = stringOrXMLDoc => (_.isString(stringOrXMLDoc) && parse(stringOrXMLDoc)) || stringOrXMLDoc;
const parseXMLNode = (node, selectors, xpathSelect) =>
_.reduce(selectors, (result, value, selectorKey) => {
// normalize the selector value to a spec object for future steps
const spec = ((input) => {
if (_.isPlainObject(input)) { return input; }
if (_.isString(input)) { return { selector: input }; }
return undefined;
})(value);
if (!_.isPlainObject(spec)) { return result; }
const selected = xpathSelect(spec.selector, node, !spec.multi);
if (_.isUndefined(selected)) { return result; }
if (!_.isFunction(spec.transform)) {
/* beautify preserve:start */
return Object.assign(result, { [selectorKey]: selected });
/* beautify preserve:end */
}
/* beautify preserve:start */
return Object.assign(result, { [selectorKey]: spec.transform(selected) });
/* beautify preserve:end */
}, {});
module.exports = {

@@ -39,2 +65,3 @@ parse,

ensureXMLDoc,
parseXMLNode,
};

8

package.json
{
"name": "oniyi-utils-xml",
"version": "1.0.0",
"version": "1.1.0",
"description": "utils for handling xml data",

@@ -27,8 +27,8 @@ "author": "Benjamin Kroeger <benjamin.kroeger@gmail.com>",

"dependencies": {
"lodash.isstring": "4.0.1",
"xmldom": "0.1.19",
"lodash": "4.17.4",
"xmldom": "0.1.27",
"xpath": "0.0.24"
},
"devDependencies": {
"ava": "0.19.1",
"ava": "0.21.0",
"eslint": "3.15.0",

@@ -35,0 +35,0 @@ "eslint-config-oniyi": "4.4.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc