How to use the @cumulus/pvl/t.pvlToJS function in @cumulus/pvl

To help you get started, we’ve selected a few @cumulus/pvl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nasa / cumulus / packages / ingest / parse-pdr.js View on Github external
const pdrFile = await fs.readFile(pdrFilePath, 'utf8');

  // Investigating CUMULUS-423
  if (pdrFile.trim().length === 0) throw new Error(`PDR file had no contents: ${pdrFilePath}`);

  // because MODAPS PDRs do not follow the standard ODL spec
  // we have to make sure there are spaces before and after every
  // question mark
  let pdrString = pdrFile.replace(/((\w*)=(\w*))/g, '$2 = $3');

  // temporary fix for PVL not recognizing quoted strings as symbols
  pdrString = pdrString.replace(/"/g, '');

  let parsed;
  try {
    parsed = pvl.pvlToJS(pdrString);
  }
  catch (e) {
    throw new PDRParsingError(e.message);
  }

  return parsed;
}

@cumulus/pvl

Parse and serialize Parameter Value Language, a data markup language used by NASA

Apache-2.0
Latest version published 1 month ago

Package Health Score

79 / 100
Full package analysis