Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@statebox/pnpro.js
Advanced tools
Convert PNPRO to JSON or statebox specific representations of Petri nets
Simple JS library to work with .pnpro
files.
These files contain multiple "pages", to select a single net and convert it, run:
let pnproNet = parse(xml).nets["page title"]
let nll = to_nll(pnproNet)
let nbpt = to_nbpt(pnproNet)
Assuming you have the contents of a PNPRO file as a string called pnproProject
, here is an overview of the functions exported by this library.
Peek into the project file and pick "pages" (nets) out of it:
parse(pnproProject)
Convert a net into some target:
to_nll(pnproNet) : NLL
to_nbpt(pnproNet) : NBPT
For Node:
let PNPRO = require('@statebox/pnpro.js')
let R = require('ramda')
// load a file as a string
let xmlStr = fs.readFileSync('file.pnpro', {encoding:'utf8'})
let project = PNPRO.parse(xmlStr)
let nlls = R.map(PNPRO.to_nll, project.nets) // {name => nll}
let nbpts = R.map(PNPRO.to_nll, project.nets) // {name => nbpt}
The two main keys are:
.title
~ project title.nets
~ dictionary of {title => net}Here is the full output of parse(..)
:
{
"title": "Project Title",
"nets": {
"page title": {
"title": "page title",
"net": {
"marking": {
"placeLabel": 1
},
"transitions": [
{
"label": "buy",
"x": 32.55,
"y": 11,
"pre": {
"Fresh": 1
},
"post": {
"Sold": 1
}
}
],
"places": [
{
"label": "Fresh",
"x": 42,
"y": 22
}
]
}
}
}
}
We have various repo's that deal with PNRO
And now also https://github.com/statebox/pnpro.js
There are some issues with the current approaches, mainly related to the library used to parse the XML.
js-pnpro-parser
uses the browser provided DOMParser()
js-pnro-parser
is used from Node, xmldom
is usedgspn-parser
uses cheerio which cannot be bundled well for the browser (due to cyclic dependencies)Instead I propose we use this 100% JS + regex based one:
We need a simple library that works from node or the browser and doesn't have any complicated (native) dependencies and can be bundled properly.
It's just an XML parser anyway!
FAQs
Convert PNPRO to JSON or Statebox specific representations of Petri nets
The npm package @statebox/pnpro.js receives a total of 0 weekly downloads. As such, @statebox/pnpro.js popularity was classified as not popular.
We found that @statebox/pnpro.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.