@artisfy/parse-data-attributes
Advanced tools
Comparing version 1.0.0 to 1.0.1
24
index.js
@@ -47,4 +47,4 @@ // Parses strings that can have multiple parameters and sub-parameters embedded | ||
function makeParseFunction (attributeName, keyNames) { | ||
return function parseFunction (elem) { // attributesStringattributesString: e.g. "switchName(no-auto, parent) switchName2(auto, parent)" | ||
let attributesString = elem.getAttribute(attributeName); | ||
return function parseFunction (elem) { | ||
let attributesString = elem.getAttribute(attributeName); // e.g. "switchName(no-auto, parent) switchName2(auto, parent)" | ||
@@ -75,2 +75,17 @@ if (!attributesString) { | ||
function parseStringWithIndefiniteNumberOfParams (attributesString) { | ||
if (!attributesString) { | ||
return []; | ||
} | ||
let parsedAttributeValues = parseAttributeString(attributesString); // e.g. [["func1", "1", "2"], ["func2"]] | ||
return parsedAttributeValues.map(function (arrayOfValues) { | ||
return { | ||
funcName: arrayOfValues[0], | ||
args: arrayOfValues.slice(1) | ||
}; | ||
}); | ||
} | ||
// this parses multiple parameters that *don't* repeat and *don't* have sub-parameters | ||
@@ -105,4 +120,6 @@ function makeSimpleParseFunction (attributeName, keyNames) { | ||
function getAttributeValueAsArray (elem, attributeName) { | ||
// get the value of the attribute | ||
let attributesString = elem.getAttribute(attributeName); | ||
// if it's an empty string or doesn't exist, return an empty array | ||
if (!attributesString) { | ||
@@ -112,4 +129,6 @@ return []; | ||
// trim and replace duplicate spaces | ||
attributesString = formatSpaces(attributesString); | ||
// return an array of the "words" in the string | ||
return attributesString.split(" "); | ||
@@ -126,2 +145,3 @@ } | ||
parseCopyDimensionsAttributes, | ||
parseStringWithIndefiniteNumberOfParams, | ||
formatSpaces, | ||
@@ -128,0 +148,0 @@ getAttributeValueAsArray |
{ | ||
"name": "@artisfy/parse-data-attributes", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Parses strings that can have multiple parameters and sub-parameters embedded", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6524
114