{"analyzedAt":"2022-12-13T02:56:47.947Z","collected":{"metadata":{"name":"@ts-graphviz/parser","scope":"ts-graphviz","version":"0.6.1","description":"Graphviz dot language parser for ts-graphviz.","keywords":["graphviz","dot","parser"],"date":"2022-12-12T14:32:00.475Z","author":{"name":"kamiazya","email":"yuki@kamiazya.tech","username":"kamiazya"},"publisher":{"username":"kamiazya","email":"yuki@kamiazya.tech"},"maintainers":[{"username":"kamiazya","email":"yuki@kamiazya.tech"}],"repository":{"type":"git","url":"git+https://github.com/ts-graphviz/parser.git"},"links":{"npm":"https://www.npmjs.com/package/%40ts-graphviz%2Fparser","homepage":"https://github.com/ts-graphviz/parser#readme","repository":"https://github.com/ts-graphviz/parser","bugs":"https://github.com/ts-graphviz/parser/issues"},"license":"MIT","dependencies":{"ts-graphviz":"^0.16.0"},"devDependencies":{"@ts-graphviz/node":"^0.4.0","@types/jest":"^26.0.23","@types/jest-specific-snapshot":"^0.5.5","@types/svgo":"^2.3.1","@typescript-eslint/eslint-plugin":"^4.22.1","@typescript-eslint/parser":"^4.22.1","eslint":"^7.25.0","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-jest":"^24.3.6","eslint-plugin-prettier":"^3.4.0","jest":"^26.6.3","jest-snapshot-serializer-raw":"^1.2.0","jest-specific-snapshot":"^5.0.0","peggy":"^1.2.0","prettier":"^2.2.1","prettier-plugin-pegjs":"^0.4.0","rollup":"^2.47.0","rollup-plugin-delete":"^2.0.0","rollup-plugin-dts":"^3.0.1","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","svgo":"^2.3.1","ts-dedent":"^2.1.1","ts-jest":"^26.5.6","ts-node":"^9.1.1","ts-pegjs":"^1.1.1","typescript":"^4.2.4"},"releases":[{"from":"2022-11-13T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":2},{"from":"2022-09-14T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":2},{"from":"2022-06-16T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":2},{"from":"2021-12-13T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":2},{"from":"2020-12-13T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":15}],"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","hasTestScript":true,"readme":"---\n# This project has been merged into [ts-graphviz](https://github.com/ts-graphviz/ts-graphviz). \n---\n\n[![NodeCI](https://github.com/ts-graphviz/parser/workflows/NodeCI/badge.svg)](https://github.com/ts-graphviz/parser/actions?workflow=NodeCI)\n[![npm version](https://badge.fury.io/js/%40ts-graphviz%2Fparser.svg)](https://badge.fury.io/js/%40ts-graphviz%2Fparser)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)\n[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg)](#contributors)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\n# @ts-graphviz/parser\n\nGraphviz dot language parser for ts-graphviz.\n\n## Key Feature\n\n- Parse function that converts the DOT language to a [ts-graphviz](https://github.com/ts-graphviz/ts-graphviz) model.\n- Provides module that enables operations at AST level.\n- TypeScript Support.\n- Supports multiple runtime and module.\n  - Node.js, Browser and Deno.\n  - UMD, ESM, CommonJS\n\n![State Machine](./img/state-machine.svg)\n\n## Installation\n\nThe module can then be installed using [npm](https://www.npmjs.com/):\n\n[![NPM](https://nodei.co/npm/@ts-graphviz/parser.png)](https://nodei.co/npm/@ts-graphviz/parser/)\n\n```bash\n# yarn\n$ yarn add @ts-graphviz/parser\n# or npm\n$ npm install -S @ts-graphviz/parser\n```\n\n## High level API\n\n### `function parse(dot: string, options?: ParseOption)`\n\nParse a string written in dot language and convert it to a model.\n\nThe returned values are [ts-graphviz](https://github.com/ts-graphviz/ts-graphviz) models\nsuch as `Digraph`, `Graph`, `Node`, `Edge`, `Subgraph`.\n\n- Parameters\n  - `dot` -- string in the dot language to be parsed.\n  - `options.rule` -- Object type of dot string.\n    - This can be `\"graph\"`, `\"subgraph\"`, `\"node\"`, `\"edge\"`.\n\n```ts\nimport { parse } from '@ts-graphviz/parser';\n\nconst G = parse(`\ndigraph hoge {\n  a -> b;\n}`);\n```\n\nThis is equivalent to the code below when using ts-graphviz.\n\n```ts\nimport { digraph } from 'ts-graphviz';\n\nconst G = digraph('hoge', (g) => {\n  g.edge(['a', 'b']);\n});\n```\n\nIf the given string is invalid, a SyntaxError exception will be thrown.\n\n```ts\nimport { parse, SyntaxError } from '@ts-graphviz/parser';\n\ntry {\n  parse(`invalid`);\n} catch (e) {\n  if (e instanceof SyntaxError) {\n    console.log(e.message);\n  }\n}\n```\n\n### Example: parse as Node instance\n\n```ts\nimport { Node } from 'ts-graphviz';\nimport { parse } from '@ts-graphviz/parser';\n\nconst node = parse(\n  `test [\n    style=filled;\n    color=lightgrey;\n    label = \"example #1\";\n  ];`,\n  { rule: 'node' },\n);\n\nconsole.log(node instanceof Node);\n// true\n```\n\n### `dot` tagged template\n\n> This is an experimental API.\n> Behavior may change in the future.\n\nA tag template version of the parse function.\n\nReturns a Graph or Digraph object based on the parsed result.\n\nIf the given string is invalid, a SyntaxError exception will be thrown.\n\n```ts\nimport { dot } from '@ts-graphviz/parser';\n\nconst G = dot`\n  graph {\n    a -- b\n  }\n`;\n```\n\n### `function convert(ast)`\n\n> May change the publishing method.\n\nConvert AST to ts-graphviz model.\n\n```ts\nexport function convert(ast: AST.Dot): RootCluster;\nexport function convert(ast: AST.Graph): RootCluster;\nexport function convert(ast: AST.Subgraph): Subgraph;\nexport function convert(ast: AST.Node): Node;\nexport function convert(ast: AST.Edge): Edge;\n```\n\n## Low level API\n\n### `AST` module\n\nThe `AST` module provides the ability to handle the AST as a result of parsing the dot language\nfor lower level operations.\n\n#### `function AST.parse(dot: string, options?: ParseOption)`\n\nThe basic usage is the same as the `parse` function, except that it returns the dot language AST.\n\n- Parameters\n  - `dot` -- string in the dot language to be parsed.\n  - `options.rule` -- Object type of dot string.\n    - This can be `\"graph\"`, `\"subgraph\"`, `\"node\"`, `\"edge\"`, `\"attributes\"`, `\"attribute\", \"cluster_statements\"`.\n\n```ts\nimport { AST } from '@ts-graphviz/parser';\n\nconst ast = AST.parse(`\n  digraph example {\n    node1 [\n      label = \"My Node\",\n    ]\n  }\n`);\n\nconsole.log(ast);\n// {\n//   type: 'dot',\n//   body: [\n//     {\n//       type: 'graph',\n//       id: {\n//         type: 'literal',\n//         value: 'example',\n//         quoted: false,\n//         location: {\n//           start: { offset: 11, line: 2, column: 11 },\n//           end: { offset: 18, line: 2, column: 18 }\n//         }\n//       },\n//       directed: true,\n//       strict: false,\n//       body: [\n//         {\n//           type: 'node',\n//           id: {\n//             type: 'literal',\n//             value: 'node1',\n//             quoted: false,\n//             location: {\n//               start: { offset: 25, line: 3, column: 5 },\n//               end: { offset: 30, line: 3, column: 10 }\n//             }\n//           },\n//           body: [\n//             {\n//               type: 'attribute',\n//               key: {\n//                 type: 'literal',\n//                 value: 'label',\n//                 quoted: false,\n//                 location: {\n//                   start: { offset: 39, line: 4, column: 7 },\n//                   end: { offset: 44, line: 4, column: 12 }\n//                 }\n//               },\n//               value: {\n//                 type: 'literal',\n//                 value: 'My Node',\n//                 quoted: true,\n//                 location: {\n//                   start: { offset: 47, line: 4, column: 15 },\n//                   end: { offset: 56, line: 4, column: 24 }\n//                 }\n//               },\n//               location: {\n//                 start: { offset: 39, line: 4, column: 7 },\n//                 end: { offset: 57, line: 4, column: 25 }\n//               }\n//             }\n//           ],\n//           location: {\n//             start: { offset: 25, line: 3, column: 5 },\n//             end: { offset: 63, line: 5, column: 6 }\n//           }\n//         }\n//       ],\n//       location: {\n//         start: { offset: 3, line: 2, column: 3 },\n//         end: { offset: 67, line: 6, column: 4 }\n//       }\n//     }\n//   ],\n//   location: {\n//     start: { offset: 3, line: 2, column: 3 },\n//     end: { offset: 68, line: 7, column: 1 }\n//   }\n// }\n```\n\n##### Example: Specifying the `rule` option\n\n```ts\nconst ast = AST.parse('test [ style=filled; ];', { rule: 'node' });\n\nconsole.log(ast);\n// {\n//   type: 'node',\n//   id: {\n//     type: 'literal',\n//     value: 'test',\n//     quoted: false,\n//     location: {\n//       start: { offset: 0, line: 1, column: 1 },\n//       end: { offset: 4, line: 1, column: 5 }\n//     }\n//   },\n//   body: [\n//     {\n//       type: 'attribute',\n//       key: {\n//         type: 'literal',\n//         value: 'style',\n//         quoted: false,\n//         location: {\n//           start: { offset: 7, line: 1, column: 8 },\n//           end: { offset: 12, line: 1, column: 13 }\n//         }\n//       },\n//       value: {\n//         type: 'literal',\n//         value: 'filled',\n//         quoted: false,\n//         location: {\n//           start: { offset: 13, line: 1, column: 14 },\n//           end: { offset: 19, line: 1, column: 20 }\n//         }\n//       },\n//       location: {\n//         start: { offset: 7, line: 1, column: 8 },\n//         end: { offset: 20, line: 1, column: 21 }\n//       }\n//     }\n//   ],\n//   location: {\n//     start: { offset: 0, line: 1, column: 1 },\n//     end: { offset: 23, line: 1, column: 24 }\n//   }\n// }\n```\n\n#### `function AST.stringify(ast: AST.ASTNode, options?: StringifyOption): string`\n\nStringify Graphviz AST Node.\n\n- Parameters\n  - `ast` -- Graphviz AST node.\n- Returns\n  - DOT language string.\n\n## See Also\n\nGraphviz-dot Test and Integration\n\n- [ts-graphviz](https://github.com/ts-graphviz/ts-graphviz)\n  - Graphviz library for TypeScript.\n- [@ts-graphviz/react](https://github.com/ts-graphviz/react)\n  - Graphviz-dot Renderer using React.\n- [jest-graphviz](https://github.com/ts-graphviz/jest-graphviz)\n  - Jest matchers that supports graphviz integration.\n- [setup-graphviz](https://github.com/ts-graphviz/setup-graphviz)\n  - GitHub Action to set up Graphviz cross-platform(Linux, macOS, Windows).\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tr>\n    <td align=\"center\"><a href=\"http://blog.kamiazya.tech/\"><img src=\"https://avatars.githubusercontent.com/u/35218186?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Yuki Yamazaki</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/parser/commits?author=kamiazya\" title=\"Code\">💻</a> <a href=\"https://github.com/ts-graphviz/parser/commits?author=kamiazya\" title=\"Documentation\">📖</a> <a href=\"https://github.com/ts-graphviz/parser/commits?author=kamiazya\" title=\"Tests\">⚠️</a></td>\n    <td align=\"center\"><a href=\"https://github.com/ChristianMurphy\"><img src=\"https://avatars.githubusercontent.com/u/3107513?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Christian Murphy</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/parser/commits?author=ChristianMurphy\" title=\"Code\">💻</a> <a href=\"#ideas-ChristianMurphy\" title=\"Ideas, Planning, & Feedback\">🤔</a> <a href=\"https://github.com/ts-graphviz/parser/commits?author=ChristianMurphy\" title=\"Documentation\">📖</a></td>\n  </tr>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n## License\n\nThis software is released under the MIT License, see [LICENSE](./LICENSE)."},"npm":{"downloads":[{"from":"2022-12-12T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":0},{"from":"2022-12-06T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":57},{"from":"2022-11-13T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":451},{"from":"2022-09-14T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":1516},{"from":"2022-06-16T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":3105},{"from":"2021-12-13T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":7112}],"starsCount":0},"github":{"homepage":"https://www.npmjs.com/package/@ts-graphviz/parser","starsCount":4,"forksCount":2,"subscribersCount":1,"issues":{"count":34,"openCount":3,"distribution":{"3600":19,"10800":1,"32400":2,"97200":5,"291600":2,"874800":1,"2624400":2,"7873200":2,"23619600":0,"70858800":0,"212576400":0},"isDisabled":false},"contributors":[{"username":"kamiazya","commitsCount":63},{"username":"dependabot[bot]","commitsCount":7},{"username":"allcontributors[bot]","commitsCount":4},{"username":"ChristianMurphy","commitsCount":2}],"commits":[{"from":"2022-12-06T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":2},{"from":"2022-11-13T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":2},{"from":"2022-09-14T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":2},{"from":"2022-06-16T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":3},{"from":"2021-12-13T00:00:00.000Z","to":"2022-12-13T00:00:00.000Z","count":4}]},"source":{"files":{"readmeSize":10162,"testsSize":61753357,"hasNpmIgnore":true},"badges":[{"urls":{"original":"https://nodei.co/npm/@ts-graphviz/parser.png","shields":"https://img.shields.io/npm/v/@ts-graphviz/parser.svg","content":"https://img.shields.io/npm/v/@ts-graphviz/parser.json"},"info":{"service":"npm","type":"version"}}],"linters":["editorconfig","eslint","prettier"],"outdatedDependencies":{"ts-graphviz":{"required":"^0.16.0","stable":"1.3.2","latest":"1.3.3-dev.328c75216"}}}},"evaluation":{"quality":{"carefulness":0,"tests":0.6,"health":0.75,"branding":0.15},"popularity":{"communityInterest":11,"downloadsCount":505.3333333333333,"downloadsAcceleration":-1.6716324200913237,"dependentsCount":0},"maintenance":{"releasesFrequency":1,"commitsFrequency":0.6935273972602739,"openIssues":1,"issuesDistribution":1}},"score":{"final":0.618957902380265,"detail":{"quality":0.8389283188634583,"popularity":0.04966965206628622,"maintenance":0.9997000814229355}}}