{"name":"jsdoctypeparser","description":"Strict JsDoc type expression parser.","version":"7.0.0","author":{"name":"Kuniwak","email":"orga.chem.job@gmail.com"},"contributors":[{"name":"Brett Zamir"},{"name":"Nathan Shively-Sanders"}],"keywords":["jsdoc","type expression","parser"],"repository":{"type":"git","url":"git://github.com/jsdoctypeparser/jsdoctypeparser.git"},"engines":{"node":">=10"},"homepage":"https://jsdoctypeparser.github.io","bugs":{"url":"https://github.com/jsdoctypeparser/jsdoctypeparser/issues"},"directories":{"test":"test"},"main":"index.js","bin":{"jsdoctypeparser":"bin/jsdoctypeparser"},"nyc":{"reporter":["text","html"],"exclude":["tests"]},"scripts":{"prepare":"npm-run-all build","pretest":"npm-run-all lint build","test":"npm-run-all mocha typecheck","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_*","typecheck":"tsc","clean":"rimraf ./peg_lib","postclean":"mkdirp ./peg_lib","prebuild":"npm-run-all clean","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"},"husky":{"hooks":{"pre-push":"npm test"}},"dependencies":{},"devDependencies":{"@types/node":"^14.0.13","chai":"^4.2.0","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.2","typescript":"^3.9.5"},"license":"MIT","gitHead":"793786409bac710a0f2728ad6e92ea9133dc4835","_id":"jsdoctypeparser@7.0.0","_nodeVersion":"12.13.1","_npmVersion":"6.14.4","dist":{"integrity":"sha512-6vWPn5qSy+MbgCVjXsQKVkRywhs+IxFU7Chw72DKsWoGueYp6QX8eTc55+EA0yPGYfhmglb1gfi283asXirfGQ==","shasum":"957192fbcb8c574240092cca4635383a6ed706eb","tarball":"http://registry-npm.ywwl.com/jsdoctypeparser/download/jsdoctypeparser-7.0.0.tgz","fileCount":41,"unpackedSize":797843,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe4kabCRA9TVsSAnZWagAAvGUP+gLZF5LtKMf94ETiG0Fz\n+GbbuszOoUqC9PMzNjb8tiMm6uVsl7Hb6dwKTVVM5wSpOyxuxldLqyeljPw2\nnhUfqMNmfycj5+pfXshAh6ctLNBygntW7vfOOYHeNMxuCT5kAryFJRxbaO71\nqD6Tw7VmnXyp7NwCh56ozYedPpZMqle0bWyd0T4z4pTEI6i7G3VEYS97JNOQ\nCGpzWxZlkN1wu89xnoFSNBt/l7ifg1szAWazbvGVZIY7Cd8cZeZuo4QwjCcs\n3jDn8yWJEMsd/n8WtBsgVedLyai57JVh6cj2pQA2qdkAen2irBo/YHPNQZkt\ngKCgC19w89YqHzDTy8no2jjE6YHRdn5bAhEC5CMKU1QJtROUFOQIp82uEujB\nYrmUh8m1aI8c1hw4sEircVxNHJQkLswv6gRxfp+o4ULeXTqF7sls0jv5h+eu\n0ish51Ol4B29XNQc9/O8gzjiottg1pQbbmN+d6BF5uspLxaY70Y+A4zcPHge\n6sYr6qSDleZ++YL+iw60g6tkoQYsg/3IUVlPGPMsm3g3pGp2OqmgCQPT9YR1\npL3vzeecDHGS9THcZrrMU61kl+MPmHBav9bU7xCN+CeK55Cd7mbvT0XupiOt\nF6fQDLZmxVKwAHwq6OMLXrR5M3r+/4HbJw1UqhsQdHLnDs2ejqVduRL1jA9M\nZEl/\r\n=KETc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCWWabB4oupHAP10tQ/kwRzWKAtVPA89A9C/PJqXymFQgIgRZU9aAuluy3DEm+ewlmMhqdv8Pt+vend49QXX3BSSHA="}],"size":72280,"noattachment":false,"key":"/jsdoctypeparser/-/jsdoctypeparser-7.0.0.tgz"},"maintainers":[{"name":"orgachem","email":"orga.chem.job@gmail.com"}],"_npmUser":{"name":"sanders_n","email":"ncsander@indiana.edu"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jsdoctypeparser_7.0.0_1591887514475_0.07366426433596862"},"_hasShrinkwrap":false,"readme":"# jsdoctypeparser\n\n[![Build Status](https://travis-ci.org/jsdoctypeparser/jsdoctypeparser.svg?branch=master)](https://travis-ci.org/jsdoctypeparser/jsdoctypeparser)\n[![NPM version](https://badge.fury.io/js/jsdoctypeparser.svg)](http://badge.fury.io/js/jsdoctypeparser)\n\nThe parser can parse:\n\n* [JSDoc type expressions](https://jsdoc.app/tags-type.html)\n  * `foo.bar`, `String[]`\n* [Closure Compiler type expressions](https://developers.google.com/closure/compiler/docs/js-for-compiler)\n  * `Array<string>`, `function(arg1, arg2): ret`\n* [some Typescript types](https://github.com/Microsoft/TypeScript)\n  * `(x: number) => string`, `typeof x`, `import(\"./some-module\")`\n* Complex type expressions\n  * `Array<Array<string>>`, `function(function(Function))`\n\n## Live demo\n\nThe [live demo](https://jsdoctypeparser.github.io) is available.\n\n## Usage (Programmatic)\n\n### Parsing\n\n```javascript\nconst {parse} = require('jsdoctypeparser');\n\nconst ast = parse('Array<MyClass>');\n```\n\nThe `ast` becomes:\n\n```json\n{\n  \"type\": \"GENERIC\",\n  \"subject\": {\n    \"type\": \"NAME\",\n    \"name\": \"Array\"\n  },\n  \"objects\": [\n    {\n      \"type\": \"NAME\",\n      \"name\": \"MyClass\"\n    }\n  ],\n  \"meta\": {\n    \"syntax\": \"ANGLE_BRACKET\"\n  }\n}\n```\n\nSee the [AST specifications](https://github.com/Kuniwak/jsdoctypeparser/blob/update-readme/README.md#ast-specifications).\n\n### Publishing\n\nWe can stringify the AST nodes by using `publish`.\n\n```javascript\nconst {publish} = require('jsdoctypeparser');\n\nconst ast = {\n  type: 'GENERIC',\n  subject: {\n    type: 'NAME',\n    name: 'Array'\n  },\n  objects: [\n    {\n      type: 'NAME',\n      name: 'MyClass'\n    }\n  ]\n};\n\nconst string = publish(ast);\n```\n\nThe `string` becomes:\n\n```json\n\"Array<MyClass>\"\n```\n\n#### Custom publishing\n\nWe can change the stringification strategy by using the 2nd parameter of `publish(node, publisher)`.\nThe `publisher` MUST have handlers for all node types (see `lib/NodeType.js`).\n\nAnd we can override default behavior by using `createDefaultPublisher`.\n\n```javascript\nconst {publish, createDefaultPublisher} = require('jsdoctypeparser');\n\nconst ast = {\n  type: 'NAME',\n  name: 'MyClass',\n};\n\nconst customPublisher = createDefaultPublisher();\ncustomPublisher.NAME = (node, pub) =>\n  `<a href=\"./types/${node.name}.html\">${node.name}</a>`;\n\nconst string = publish(ast, customPublisher);\n```\n\nThe `string` becomes:\n\n```html\n<a href=\"./types/MyClass.html\">MyClass</a>\n```\n\n### Traversing\n\nWe can traverse the AST by using `traverse`.\nThis function takes 3 parameters (a node and an onEnter handler, an onLeave handler).\nThe handlers take a visiting node.\n\n```javascript\nconst {parse, traverse} = require('jsdoctypeparser');\nconst ast = parse('Array<{ key1: function(), key2: A.B.C }>');\n\nfunction onEnter(node, parentName, parentNode) {\n  console.log('enter', node.type, parentName, parentNode.type);\n}\n\nfunction onLeave(node, parentName, parentNode) {\n  console.log('leave', node.type, parentName, parentNode.type);\n}\n\ntraverse(ast, onEnter, onLeave);\n```\n\nThe output will be:\n\n```\nenter GENERIC null null\nenter NAME subject GENERIC\nleave NAME subject GENERIC\nenter RECORD objects GENERIC\nenter RECORD_ENTRY entries RECORD\nenter FUNCTION value RECORD_ENTRY\nleave FUNCTION value RECORD_ENTRY\nleave RECORD_ENTRY entries RECORD\nenter RECORD_ENTRY entries RECORD\nenter MEMBER value RECORD_ENTRY\nenter MEMBER owner MEMBER\nenter NAME owner MEMBER\nleave NAME owner MEMBER\nleave MEMBER owner MEMBER\nleave MEMBER value RECORD_ENTRY\nleave RECORD_ENTRY entries RECORD\nleave RECORD objects GENERIC\nleave GENERIC null null\n```\n\n## AST Specifications\n\n### `NAME`\n\nExample:\n\n```javascript\n/**\n * @type {name}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"NAME\",\n  \"name\": string\n}\n```\n\n### `MEMBER`\n\nExample:\n\n```javascript\n/**\n * @type {owner.name}\n * @type {superOwner.owner.name}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"MEMBER\",\n  \"name\": string,\n  \"quoteStyle\": \"none\",\n  \"owner\": node,\n  \"hasEventPrefix\": boolean\n}\n```\n\n### `INNER_MEMBER`\n\nExample:\n\n```javascript\n/**\n * @type {owner~name}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"INNER_MEMBER\",\n  \"name\": string,\n  \"quoteStyle\": \"none\",\n  \"owner\": node,\n  \"hasEventPrefix\": boolean\n}\n```\n\n### `INSTANCE_MEMBER`\n\nExample:\n\n```javascript\n/**\n * @type {owner#name}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"INSTANCE_MEMBER\",\n  \"name\": string,\n  \"quoteStyle\": \"none\",\n  \"owner\": node,\n  \"hasEventPrefix\": boolean\n}\n```\n\n### `UNION`\n\nExample:\n\n```javascript\n/**\n * @type {left|right}\n * @type {(left|right)}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"UNION\",\n  \"left\": node,\n  \"right\": node\n}\n```\n\n### `INTERSECTION`\n\nExample:\n\n```javascript\n/**\n * @type {left&right}\n * @type {(left&right)}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"INTERSECTION\",\n  \"left\": node,\n  \"right\": node\n}\n```\n\n### `RECORD`\n\nExample:\n\n```javascript\n/**\n * @type {{}}\n * @type {{ key: value }}\n * @type {{ key: value, anyKey }}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"RECORD\",\n  \"entries\": [\n    recordEntryNode,\n    recordEntryNode,\n    ...\n  ]\n}\n```\n\n### `RECORD_ENTRY`\n\nStructure:\n\n```javascript\n{\n  \"type\": \"RECORD_ENTRY\",\n  \"key\": string,\n  \"value\": node (or null)\n}\n```\n\n### `GENERIC`\n\nExample:\n\n```javascript\n/**\n * @type {Subject<Object, Object>}\n * @type {Object[]}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"GENERIC\",\n  \"subject\": node,\n  \"objects\": [\n    node,\n    node,\n    ...\n  ],\n  \"meta\": {\n    \"syntax\": (\"ANGLE_BRACKET\" or \"ANGLE_BRACKET_WITH_DOT\" or \"SQUARE_BRACKET\")\n  }\n}\n```\n\n### `FUNCTION`\n\nExample:\n\n```javascript\n/**\n * @type {function()}\n * @type {function(param, param): return}\n * @type {function(this: Context)}\n * @type {function(new: Class)}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"FUNCTION\",\n  \"params\": [\n    node,\n    node,\n    ...\n  ],\n  \"returns\": node (or null),\n  \"new\": node (or null),\n  \"this\": node (or null)\n}\n```\n\n### `OPTIONAL`\n\nExample:\n\n```javascript\n/**\n * @type {Optional=}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"OPTIONAL\",\n  \"value\": node,\n  \"meta\": {\n    \"syntax\": (\"PREFIX_EQUALS_SIGN\" or \"SUFFIX_EQUALS_SIGN\")\n  }\n}\n```\n\n### `NULLABLE`\n\nExample:\n\n```javascript\n/**\n * @type {?Nullable}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"NULLABLE\",\n  \"value\": node,\n  \"meta\": {\n    \"syntax\": (\"PREFIX_QUESTION_MARK\" or \"SUFFIX_QUESTION_MARK\")\n  }\n}\n```\n\n### `NOT_NULLABLE`\n\nExample:\n\n```javascript\n/**\n * @type {!NotNullable}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"NOT_NULLABLE\",\n  \"value\": node,\n  \"meta\": {\n    \"syntax\": (\"PREFIX_BANG\" or \"SUFFIX_BANG\")\n  }\n}\n```\n\n### `VARIADIC`\n\nExample:\n\n```javascript\n/**\n * @type {...Variadic}\n * @type {Variadic...}\n * @type {...}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"VARIADIC\",\n  \"value\": node (or null),\n  \"meta\": {\n    \"syntax\": (\"PREFIX_DOTS\" or \"SUFFIX_DOTS\" or \"ONLY_DOTS\")\n  }\n}\n```\n\n### `MODULE`\n\nExample:\n\n```javascript\n/**\n * @type {module:path/to/file.Module}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"MODULE\",\n  \"value\": node\n}\n```\n\n### `FILE_PATH`\n\nExample:\n\n```javascript\n/**\n * @type {module:path/to/file.Module}\n *               ^^^^^^^^^^^^\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"FILE_PATH\",\n  \"path\": string\n}\n```\n\n### `EXTERNAL`\n\nExample:\n\n```javascript\n/**\n * @type {external:External}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"EXTERNAL\",\n  \"value\": node\n}\n```\n\n### `STRING_VALUE`\n\nExample:\n\n```javascript\n/**\n * @type {\"abc\"}\n * @type {\"can\\\"escape\"}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"STRING_VALUE\",\n  \"quoteStyle\": \"double\",\n  \"string\": string\n}\n```\n\n### `NUMBER_VALUE`\n\nExample:\n\n```javascript\n/**\n * @type {123}\n * @type {0b11}\n * @type {0o77}\n * @type {0xff}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"NUMBER_VALUE\",\n  \"number\": string\n}\n```\n\n### `ANY`\n\nExample:\n\n```javascript\n/**\n * @type {*}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"ANY\"\n}\n```\n\n### `UNKNOWN`\n\nExample:\n\n```javascript\n/**\n * @type {?}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"UNKNOWN\"\n}\n```\n\n### `PARENTHESIS`\n\nExample:\n\n```javascript\n/**\n * @type {(Foo)}\n */\n```\n\nStructure:\n\n```javascript\n{\n  \"type\": \"PARENTHESIS\",\n  \"value\": node\n}\n```\n\n### Others\n\nWe can use a parenthesis to change operator orders.\n\n```javascript\n/**\n * @type {(module:path/to/file.js).foo}\n */\n```\n\n## Usage (CLI)\n\nTo parse a type into a JSON structure, you may pass a string argument\ncontaining the structure to parse (with the JSON results equivalent to the\nparsing example above):\n\n```\njsdoctypeparser 'Array<MyClass>'\n```\n\nNote: There is no need to prefix the path to the `jsdoctypeparser` binary,\ne.g., with `./node_modules/.bin/` when you are running within one of the\n`package.json` `scripts` or if you have installed the package globally.\n\n## License\n\n[This script is licensed under the MIT](./LICENSE-MIT.txt).\n","publish_time":1591887514647,"_cnpm_publish_time":1591887514647,"dist-tags":{"latest":"9.0.0"}}