comment-parser
Advanced tools
Comparing version 0.7.4 to 0.7.5
@@ -0,1 +1,4 @@ | ||
# v0.7.5 | ||
- name parsing fixes | ||
# v0.7.4 | ||
@@ -2,0 +5,0 @@ - node 8 backward compatibility fixes |
{ | ||
"name": "comment-parser", | ||
"version": "0.7.4", | ||
"version": "0.7.5", | ||
"description": "Generic JSDoc-like comment parser. ", | ||
@@ -64,3 +64,4 @@ "main": "index.js", | ||
"Jordan Harband (https://github.com/ljharb)", | ||
"tengattack (https://github.com/tengattack)" | ||
"tengattack (https://github.com/tengattack)", | ||
"Jayden Seric (https://github.com/jaydenseric)" | ||
], | ||
@@ -67,0 +68,0 @@ "license": "MIT", |
@@ -16,8 +16,8 @@ 'use strict' | ||
PARSERS.parse_tag = function parse_tag (str) { | ||
const result = str.match(/^\s*@(\S+)/) | ||
if (!result) { throw new Error('Invalid `@tag`, missing @ symbol') } | ||
const match = str.match(/^\s*@(\S+)/) | ||
if (!match) { throw new SyntaxError('Invalid `@tag`, missing @ symbol') } | ||
return { | ||
source: result[0], | ||
data: { tag: result[1] } | ||
source: match[0], | ||
data: { tag: match[1] } | ||
} | ||
@@ -42,3 +42,3 @@ } | ||
if (curlies !== 0) { throw new Error('Invalid `{type}`, unpaired curlies') } | ||
if (curlies !== 0) { throw new SyntaxError('Invalid `{type}`, unpaired curlies') } | ||
@@ -73,3 +73,3 @@ return { | ||
if (brackets !== 0) { throw new Error('Invalid `name`, unpaired brackets') } | ||
if (brackets !== 0) { throw new SyntaxError('Invalid `name`, unpaired brackets') } | ||
@@ -82,7 +82,10 @@ res = { name, optional: false } | ||
if (name.indexOf('=') !== -1) { | ||
const parts = name.split('=') | ||
name = parts[0] | ||
res.default = parts[1].replace(/^(["'])(.+)(\1)$/, '$2') | ||
} | ||
const match = name.match( | ||
/^\s*([^=]+?)(?:\s*=\s*(.+?))?\s*(?=$)/ | ||
) | ||
if (!match) throw new SyntaxError('Invalid `name`, bad syntax') | ||
name = match[1] | ||
if (match[2]) res.default = match[2] | ||
} | ||
@@ -102,8 +105,8 @@ } | ||
const result = str.match(/^\s+((.|\s)+)?/) | ||
const match = str.match(/^\s+((.|\s)+)?/) | ||
if (result) { | ||
if (match) { | ||
return { | ||
source: result[0], | ||
data: { description: result[1] === undefined ? '' : result[1] } | ||
source: match[0], | ||
data: { description: match[1] === undefined ? '' : match[1] } | ||
} | ||
@@ -110,0 +113,0 @@ } |
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
34066
636