Socket
Socket
Sign inDemoInstall

jsdoctypeparser

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsdoctypeparser - npm Package Compare versions

Comparing version 6.1.0 to 7.0.0

peg_lib/jsdoctype-closure.js

1

index.js

@@ -11,3 +11,2 @@ 'use strict';

/**

@@ -14,0 +13,0 @@ * Namespace for jsdoctypeparser.

@@ -28,7 +28,22 @@ 'use strict';

const {SyntaxError: JSDocTypeSyntaxError, parse} = require('../peg_lib/jsdoctype.js');
const {
parse, SyntaxError: JSDocTypeSyntaxError,
} = require('../peg_lib/jsdoctype-permissive.js');
const {
parse: parseJsdoc, SyntaxError: JSDocSyntaxError,
} = require('../peg_lib/jsdoctype-jsdoc.js');
const {
parse: parseClosure, SyntaxError: ClosureSyntaxError,
} = require('../peg_lib/jsdoctype-closure.js');
const {
parse: parseTypeScript, SyntaxError: TypeScriptSyntaxError,
} = require('../peg_lib/jsdoctype-typescript.js');
const {inspect} = require('util');
module.exports = {
/** * A class for JSDoc type expression syntax errors.
/**
* A class for JSDoc-like type expression syntax errors.
* @constructor

@@ -39,11 +54,48 @@ * @extends {Error}

/**
* A class for JSDoc-specific type expression syntax errors.
* @constructor
* @extends {Error}
*/
JSDocSyntaxError,
/**
* A class for Closure type expression syntax errors.
* @constructor
* @extends {Error}
*/
ClosureSyntaxError,
/**
* A class for TypeScript type expression syntax errors.
* @constructor
* @extends {Error}
*/
TypeScriptSyntaxError,
/**
* @typedef {object} ParseOptions
* @property {"permissive"|"jsdoc"|"closure"|"typescript"} [mode='permissive']
*/
/**
* Parse the specified type expression string.
* @param {string} typeExprStr Type expression string.
* @param {ParseOptions} opts
* @return {AstNode} AST.
*/
parse (typeExprStr) {
return parse(typeExprStr);
parse (typeExprStr, {mode = 'permissive'} = {}) {
switch (mode) {
case 'jsdoc':
return parseJsdoc(typeExprStr);
case 'closure':
return parseClosure(typeExprStr);
case 'typescript':
return parseTypeScript(typeExprStr);
case 'permissive':
return parse(typeExprStr);
default:
throw new TypeError('Unrecognized mode: ' + inspect(mode));
}
},
};

@@ -90,13 +90,8 @@ 'use strict';

const concretePublishedObjects = genericNode.objects.map(concretePublish);
if (genericNode.meta) {
switch (genericNode.meta.syntax) {
case 'SQUARE_BRACKET':
if (genericNode.subject && genericNode.subject.name === 'Array') {
return format('%s[]', concretePublishedObjects.join(', '));
}
break;
case 'ANGLE_BRACKET_WITH_DOT':
return format('%s.<%s>', concretePublish(genericNode.subject),
concretePublishedObjects.join(', '));
}
switch (genericNode.meta.syntax) {
case 'SQUARE_BRACKET':
return format('%s[]', concretePublishedObjects.join(', '));
case 'ANGLE_BRACKET_WITH_DOT':
return format('%s.<%s>', concretePublish(genericNode.subject),
concretePublishedObjects.join(', '));
}

@@ -149,3 +144,3 @@ return format('%s<%s>', concretePublish(genericNode.subject),

NAMED_PARAMETER (parameterNode, concretePublish) {
return parameterNode.name + (parameterNode.typeName ? ': ' + concretePublish(parameterNode.typeName) : '');
return parameterNode.name + ': ' + concretePublish(parameterNode.typeName);
},

@@ -152,0 +147,0 @@ ANY () {

@@ -16,12 +16,10 @@ 'use strict';

if (node) {
const childNodeInfo = _collectChildNodeInfo(node);
childNodeInfo.forEach(function([childNode, parentPropName, parentNode]) {
traverse(childNode, opt_onEnter ? (node, pn, pNode) => {
opt_onEnter(node, pn || parentPropName, pNode || parentNode);
} : null, opt_onLeave ? (node, pn, pNode) => {
opt_onLeave(node, pn || parentPropName, pNode || parentNode);
} : null);
});
}
const childNodeInfo = _collectChildNodeInfo(node);
childNodeInfo.forEach(function([childNode, parentPropName, parentNode]) {
traverse(childNode, opt_onEnter ? (node, pn, pNode) => {
opt_onEnter(node, pn || parentPropName, pNode || parentNode);
} : null, opt_onLeave ? (node, pn, pNode) => {
opt_onLeave(node, pn || parentPropName, pNode || parentNode);
} : null);
});

@@ -28,0 +26,0 @@ if (opt_onLeave) opt_onLeave(node, null, null);

{
"name": "jsdoctypeparser",
"description": "Strict JsDoc type expression parser.",
"version": "6.1.0",
"version": "7.0.0",
"author": "Kuniwak <orga.chem.job@gmail.com>",

@@ -20,3 +20,3 @@ "contributors": [

"engines": {
"node": ">=6"
"node": ">=10"
},

@@ -33,2 +33,11 @@ "homepage": "https://jsdoctypeparser.github.io",

"bin": "./bin/jsdoctypeparser",
"nyc": {
"reporter": [
"text",
"html"
],
"exclude": [
"tests"
]
},
"scripts": {

@@ -39,2 +48,6 @@ "prepare": "npm-run-all build",

"lint": "eslint .",
"start": "static -p 8050",
"open-coverage": "open-cli http://localhost:8050/coverage/",
"open-cov": "run-p start open-coverage",
"coverage": "nyc npm run mocha",
"mocha": "mocha tests/test_*",

@@ -45,3 +58,7 @@ "typecheck": "tsc",

"prebuild": "npm-run-all clean",
"build": "pegjs --cache -o ./peg_lib/jsdoctype.js ./peg_src/jsdoctype.pegjs"
"build:jsdoc": "frs-replace '^.*// [^/]*?no-jsdoc(?!-)[^/]*?$' '' -f gm -i './peg_src/jsdoctype.pegjs' --stdout | frs-replace '^.*// [^/]*?no-jsdoc-begin[\\s\\S]*?no-jsdoc-end.*?$' '' -f gm | pegjs --cache -o ./peg_lib/jsdoctype-jsdoc.js",
"build:typescript": "frs-replace '^.*// [^/]*?no-typescript(?!-)[^/]*?$' '' -f gm -i './peg_src/jsdoctype.pegjs' --stdout | frs-replace '^.*// [^/]*?no-typescript-begin[\\s\\S]*?no-typescript-end.*?$' '' -f gm | pegjs --cache -o ./peg_lib/jsdoctype-typescript.js",
"build:closure": "frs-replace '^.*// [^/]*?no-closure(?!-)[^/]*?$' '' -f gm -i './peg_src/jsdoctype.pegjs' --stdout | frs-replace '^.*// [^/]*?no-closure-begin[\\s\\S]*?no-closure-end.*?$' '' -f gm| pegjs --cache -o ./peg_lib/jsdoctype-closure.js",
"build:permissive": "pegjs --cache -o ./peg_lib/jsdoctype-permissive.js ./peg_src/jsdoctype.pegjs",
"build": "npm run build:jsdoc && npm run build:typescript && npm run build:closure && npm run build:permissive"
},

@@ -55,15 +72,19 @@ "husky": {

"devDependencies": {
"@types/node": "^12.12.14",
"@types/node": "^14.0.13",
"chai": "^4.2.0",
"eslint": "^6.7.2",
"husky": "^3.1.0",
"mkdirp": "^0.5.1",
"mocha": "^6.2.2",
"eslint": "^7.2.0",
"@frsource/frs-replace": "^2.1.1",
"husky": "^4.2.5",
"mkdirp": "^1.0.4",
"mocha": "^8.0.1",
"node-static": "^0.7.11",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"object.entries-ponyfill": "^1.0.1",
"open-cli": "^6.0.1",
"pegjs": "^0.10.0",
"rimraf": "^3.0.0",
"typescript": "^3.7.2"
"rimraf": "^3.0.2",
"typescript": "^3.9.5"
},
"license": "MIT"
}

@@ -14,3 +14,3 @@ {

"lib"
],
]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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