Skip to content

Commit

Permalink
doc: add return type
Browse files Browse the repository at this point in the history
  • Loading branch information
seanghay committed Jul 18, 2023
1 parent 6cfc927 commit 13fe350
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/vector-drawable-svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ const gradientItemAttrsTransforms = {
}

/**
* Parse Android XML Resources and returns an object.
* @param {string | undefined} value
* @returns {Object.<string, string>}
*/
exports.parseAndroidResource = function (value) {
if (typeof value !== 'string') return;
const parser = new DOMParser()
const doc = parser.parseFromString(value)
const resourcesNode = doc.getElementsByTagName("resources")[0]
if (!resourcesNode) return;

const map = new Map()

for (let i = 0; i < resourcesNode.childNodes.length; i++) {
Expand Down
3 changes: 1 addition & 2 deletions tests/parse-resources.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ describe("transform android resources to map", () => {
<color name="ucrop_color_toolbar">@color/colorPrimary</color>
<color name="ucrop_color_statusbar">@color/colorPrimaryDark</color>
<color name="ucrop_color_widget_active">@color/colorPrimary</color>
</resources>
`
</resources>`

const result = parseAndroidResource(input)
expect(result).toMatchObject({
Expand Down

0 comments on commit 13fe350

Please sign in to comment.