Gathering detailed insights and metrics for pnml-moddle-converter
Gathering detailed insights and metrics for pnml-moddle-converter
Gathering detailed insights and metrics for pnml-moddle-converter
Gathering detailed insights and metrics for pnml-moddle-converter
npm install pnml-moddle-converter
Typescript
Module System
Node Version
NPM Version
67.8
Supply Chain
98.5
Quality
81.9
Maintenance
100
Vulnerability
100
License
TypeScript (50.58%)
JavaScript (49.42%)
Total Downloads
1,471
Last Day
2
Last Week
23
Last Month
132
Last Year
1,471
1 Stars
14 Commits
1 Watching
1 Branches
4 Contributors
Latest Version
0.2.7
Package Id
pnml-moddle-converter@0.2.7
Unpacked Size
66.42 kB
Size
12.49 kB
File Count
51
NPM Version
10.8.3
Node Version
20.11.1
Publised On
10 Sept 2024
Cumulative downloads
Total Downloads
Last day
-60%
2
Compared to previous day
Last week
-14.8%
23
Compared to previous week
Last month
-18%
132
Compared to previous month
Last year
0%
1,471
Compared to previous year
1
2
This module provides a parser and serializer for .pnml files and Moddle.js XML files specifying place transition nets. In addition, a converter has been implemented to transform each of the representations into another.
Use the following command to add this package as a dependency to your node project.
1npm i --save pnml-moddle-converter
The package can be used as follows (the example can be found in dev.ts
):
1import { 2 parseModdleXml, 3 parsePnmlXml, 4 convertModdleToPnml, 5 convertPnmlToModdle, 6 convertModdleXmlToPnmlXml, 7 convertPnmlXmlToModdleXml, 8} from "pnml-moddle-converter"; 9 10const moddleXml = '<?xml version="1.0" encoding="UTF-8"?>...'; 11const pnmlXml = '<?xml version="1.0" encoding="UTF-8"?>...'; 12 13// Parse a XML file including a Moddle.js place transition net specification 14const moddleDefinitions = parseModdleXml(moddleXml); 15// Serialize a ModdleDefinitions object into a string 16const moddleXml2 = moddleDefinitions.serialize(); 17// Convert a ModdleDefinitions object into a PnmlDocument object 18const pnmlDocumentFromModdle = convertModdleToPnml(moddleDefinitions); 19// Directly convert a Moddle XML to a PNML 20const pnmlXmlFromModdleXml = convertModdleXmlToPnmlXml(moddleXml); 21 22// Parse a PNML file specifying a place transition net 23const pnmlDocument = parsePnmlXml(pnmlXml); 24// Serialize a PnmlDocument object into a string 25const pnmlXml2 = pnmlDocument.serialize(); 26// Convert a PnmlDocument object into a ModdleDefinitions object 27const moddleDefinitionsFromPnml = convertPnmlToModdle(pnmlDocument); 28// Directly convert a PNML to a Moddle XML 29const moddleXmlFromPnmlXml = convertPnmlXmlToModdleXml(pnmlXml);
The library can also be used to create models that can be serialized to the corresponding format.
Example
1const places: ModdlePlace[] = [ 2 new ModdlePlace({ id: 'place_1', name: 'p_1', marking: 2 }), 3 new ModdlePlace({ id: 'place_2', name: 'p_2', marking: 0 }), 4]; 5const transitions: ModdleTransition[] = [ 6 new ModdleTransition({ id: 'transition_1', name: 't_1' }), 7]; 8const arcs: ModdleArc[] = [ 9 new ModdleArc({ id: 'arc_1', source: 'place_1', target: 'transition_1', weight: 2}), 10 new ModdleArc({ id: 'arc_2', source: 'transition_1', target: 'place_2', weight: 1}), 11]; 12 13const moddle = new ModdleDefinitions({ 14 ptNet: new ModdlePTNet({ 15 id: 'ptnet_id_1', 16 name: 'ptnet_name_1', 17 places, 18 transitions, 19 arcs 20 }) 21}); 22 23moddle.serialize();
Example
1const places: PnmlPlace[] = [ 2 new PnmlPlace({id: "place_1", label: "p_1", initialMarking: 2}), 3 new PnmlPlace({id: "place_2", label: "p_2", initialMarking: 0}), 4]; 5const transitions: PnmlTransition[] = [ 6 new PnmlTransition({id: "transition_1", label: "t_1"}), 7]; 8const arcs: PnmlArc[] = [ 9 new PnmlArc({id: "arc_1", source: "place_1", target: "transition_1", weight: 2}), 10 new PnmlArc({id: "arc_2", source: "transition_1", target: "place_2", weight: 1}), 11]; 12 13const pnml = new PnmlDocument({ 14 nets: [ 15 new PnmlNet({ 16 id: "net_1", 17 name: "net_1", 18 type: "http://www.pnml.org/version-2009/grammar/ptnet", 19 pages: [ 20 new PnmlPage({ 21 id: "page_1", 22 places, 23 transitions, 24 arcs, 25 }) 26 ] 27 }) 28 ] 29}); 30 31pnml.serialize();
Feel free to contribute to the repository https://github.com/bptlab/pnml-moddle-converter.
You can use the file dev.ts
as a sandbox to develop new features. Use the following command to execute the file:
npm run dev
No vulnerabilities found.
No security vulnerabilities found.