Skip to content

Commit

Permalink
update dev dependencies to fix tests, ignore libs
Browse files Browse the repository at this point in the history
  • Loading branch information
kriscarle committed Feb 22, 2022
1 parent 1c2f562 commit a81d1b7
Show file tree
Hide file tree
Showing 4 changed files with 314 additions and 947 deletions.
37 changes: 19 additions & 18 deletions lib/strxml.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
/* istanbul ignore file */
// strxml from https://github.com/mapbox/strxml

var esc = require("./xml-escape");
var esc = require('./xml-escape')

module.exports.attr = attr;
module.exports.tagClose = tagClose;
module.exports.tag = tag;
module.exports.attr = attr
module.exports.tagClose = tagClose
module.exports.tag = tag

/**
* @param {array} _ an array of attributes
* @returns {string}
*/
function attr(attributes) {
if (!Object.keys(attributes).length) return "";
if (!Object.keys(attributes).length) return ''
return (
" " +
' ' +
Object.keys(attributes)
.map(function (key) {
return key + '="' + esc(attributes[key]) + '"';
return key + '="' + esc(attributes[key]) + '"'
})
.join(" ")
);
.join(' ')
)
}

/**
Expand All @@ -28,7 +29,7 @@ function attr(attributes) {
* @returns {string}
*/
function tagClose(el, attributes) {
return "<" + el + attr(attributes) + "/>";
return '<' + el + attr(attributes) + '/>'
}

/**
Expand All @@ -38,18 +39,18 @@ function tagClose(el, attributes) {
* @returns {string}
*/
function tag(el, attributes, contents) {
if (Array.isArray(attributes) || typeof attributes === "string") {
contents = attributes;
attributes = {};
if (Array.isArray(attributes) || typeof attributes === 'string') {
contents = attributes
attributes = {}
}
if (Array.isArray(contents))
contents =
"\n" +
'\n' +
contents
.map(function (content) {
return " " + content;
return ' ' + content
})
.join("\n") +
"\n";
return "<" + el + attr(attributes) + ">" + contents + "</" + el + ">";
.join('\n') +
'\n'
return '<' + el + attr(attributes) + '>' + contents + '</' + el + '>'
}
29 changes: 15 additions & 14 deletions lib/xml-escape.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
/* istanbul ignore file */
// originally from https://github.com/miketheprogrammer/xml-escape

var escape = (module.exports = function escape(string, ignore) {
var pattern;
var pattern

if (string === null || string === undefined) return;
if (string === null || string === undefined) return

ignore = (ignore || "").replace(/[^&"<>\']/g, "");
pattern = "([&\"<>'])".replace(new RegExp("[" + ignore + "]", "g"), "");
ignore = (ignore || '').replace(/[^&"<>\']/g, '')
pattern = '([&"<>\'])'.replace(new RegExp('[' + ignore + ']', 'g'), '')

return string.replace(new RegExp(pattern, "g"), function (str, item) {
return escape.map[item];
});
});
return string.replace(new RegExp(pattern, 'g'), function (str, item) {
return escape.map[item]
})
})

var map = (escape.map = {
">": "&gt;",
"<": "&lt;",
"'": "&apos;",
'"': "&quot;",
"&": "&amp;",
});
'>': '&gt;',
'<': '&lt;',
"'": '&apos;',
'"': '&quot;',
'&': '&amp;'
})
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
"license": "BSD-2-Clause",
"devDependencies": {
"browserify": "^16.5.2",
"coveralls": "^3.1.0",
"coveralls": "^3.1.1",
"fuzzer": "^0.2.1",
"glob": "^7.1.3",
"glob": "^7.2.0",
"nyc": "^15.1.0",
"tap": "^14.10.8"
"tap": "^15.1.6"
},
"dependencies": {
"minimist": "^1.2.5",
Expand Down

0 comments on commit a81d1b7

Please sign in to comment.