
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@cumulus/pvl
Advanced tools
Parse and serialize Parameter Value Language, a data markup language used by NASA
Cumulus is a cloud-based data ingest, archive, distribution and management prototype for NASA's future Earth science data streams.
A JS module to parse and serialize Parameter Value Language, a data markup language used by NASA.
> const pvl = require('./pvl/index.js')
> const input = (`
ORIGINATING_SYSTEM = "ASTER_FTP";
OBJECT = "FILE_GROUP";
DATA_TYPE = "AST_L1A";
OBJECT = "FILE_SPEC";
FILE_ID = "pg-PR1A0000-2017040601_000_001";
FILE_TYPE = "SCIENCE";
FILE_SIZE = 116503123;
END_OBJECT = "FILE_SPEC";
OBJECT = "FILE_SPEC";
FILE_ID = "pg-BR1A0000-2017040601_000_001";
FILE_TYPE = "BROWSE";
FILE_SIZE = 166428;
END_OBJECT = "FILE_SPEC";
END_OBJECT = "FILE_GROUP"
`)
> const parsed = pvl.pvlToJS(input)
> parsed
PVLRoot {
store: [ [ 'ORIGINATING_SYSTEM', [Object] ], [ 'OBJECT', [Object] ] ],
type: 'ROOT',
depth: 0 }
> JSON.stringify(parsed)
'{"store":[["ORIGINATING_SYSTEM",{"value":"ASTER_FTP","type":"text string"}],["OBJECT",{"store":[["DATA_TYPE",{"value":"AST_L1A","type":"text string"}],["OBJECT",{"store":[["FILE_ID",{"value":"pg-PR1A0000-2017040601_000_001","type":"text string"}],["FILE_TYPE",{"value":"SCIENCE","type":"text string"}],["FILE_SIZE",{"value":116503123,"type":"numeric"}]],"identifier":"FILE_SPEC","type":"OBJECT"}],["OBJECT",{"store":[["FILE_ID",{"value":"pg-BR1A0000-2017040601_000_001","type":"text string"}],["FILE_TYPE",{"value":"BROWSE","type":"text string"}],["FILE_SIZE",{"value":166428,"type":"numeric"}]],"identifier":"FILE_SPEC","type":"OBJECT"}]],"identifier":"FILE_GROUP","type":"OBJECT"}]],"type":"ROOT","depth":0}'
...
> const serialized = pvl.jsToPVL(parsed)
> console.log(serialized)
ORIGINATING_SYSTEM = "ASTER_FTP";
OBJECT = FILE_GROUP;
DATA_TYPE = "AST_L1A";
OBJECT = FILE_SPEC;
FILE_ID = "pg-PR1A0000-2017040601_000_001";
FILE_TYPE = "SCIENCE";
FILE_SIZE = 116503123;
END_OBJECT = FILE_SPEC;
OBJECT = FILE_SPEC;
FILE_ID = "pg-BR1A0000-2017040601_000_001";
FILE_TYPE = "BROWSE";
FILE_SIZE = 166428;
END_OBJECT = FILE_SPEC;
END_OBJECT = FILE_GROUP;
...
> parsed.get('ORIGINATING_SYSTEM') // Get the item with the given key
PVLTextString { value: 'ASTER_FTP', type: 'text string' }
> parsed.get('ORIGINATING_SYSTEM').value // Access its value
'ASTER_FTP'
> parsed.getAll('ORIGINATING_SYSTEM') // Since PVL allows duplicate keys
[ PVLTextString { value: 'ASTER_FTP', type: 'text string' } ]
> parsed.aggregates() // Get all OBJECTs and GROUPs
[ PVLObject {
store: [ [Object], [Object], [Object] ],
identifier: 'FILE_GROUP',
type: 'OBJECT' } ]
> parsed.objects() // Get all OBJECTs
[ PVLObject {
store: [ [Object], [Object], [Object] ],
identifier: 'FILE_GROUP',
type: 'OBJECT' } ]
> parsed.objects('FILE_GROUP') // Get all OBJECTs with a given name
[ PVLObject {
store: [ [Object], [Object], [Object] ],
identifier: 'FILE_GROUP',
type: 'OBJECT' } ]
> parsed.aggregates()[0].aggregates()[1].get('FILE_ID').value // Dig deep
'pg-BR1A0000-2017040601_000_001'
...
> const PVLRoot = pvl.models.PVLRoot
> const PVLTextString = pvl.models.PVLTextString
> const PVLGroup = pvl.models.PVLGroup
> const simple = new PVLRoot().add('FOO', new PVLTextString('BAR')).add('BAZ', new PVLTextString('QUX'))
> simple
PVLRoot {
store: [ [ 'FOO', [Object] ], [ 'BAZ', [Object] ] ],
type: 'ROOT',
depth: 0 }
> console.log(pvl.jsToPVL(simple))
FOO = "BAR";
BAZ = "QUX";
> const complex = new PVLRoot().addAggregate(new PVLGroup('FOO').add('BAR', new PVLTextString('BAZ'))).addAggregate(new PVLGroup('QUX').add('BAR', new PVLTextString('FIZZ')))
> complex
PVLRoot {
store: [ [ 'GROUP', [Object] ], [ 'GROUP', [Object] ] ],
type: 'ROOT',
depth: 0 }
> console.log(pvl.jsToPVL(complex))
GROUP = FOO;
BAR = "BAZ";
END_GROUP = FOO;
GROUP = QUX;
BAR = "FIZZ";
END_GROUP = QUX;
Run tests with npm test.
To make a contribution, please see our contributing guidelines.
FAQs
Parse and serialize Parameter Value Language, a data markup language used by NASA
We found that @cumulus/pvl demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers 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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.