How to use the @shexjs/parser.construct function in @shexjs/parser

To help you get started, we’ve selected a few @shexjs/parser 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 shexSpec / shex.js / packages / shex-loader / shex-loader.js View on Github external
function parseShExC (text, mediaType, url, schema, meta, schemaOptions, loadImports) {
  var parser = schemaOptions && "parser" in schemaOptions ?
      schemaOptions.parser :
      ShExParser.construct(url, {}, schemaOptions);
  try {
    var s = parser.parse(text);
    // !! horrible hack until I set a variable to know if there's a BASE.
    if (s.base === url) delete s.base;
    meta.prefixes = s._prefixes;
    meta.base = s._base || meta.base;
    ShExUtil.merge(schema, loadImports(s), false, true);
    return Promise.resolve([mediaType, url]);
  } catch (e) {
    e.message = "error parsing ShEx " + url + ": " + e.message;
    return Promise.reject(e);
  }
}

@shexjs/parser

Shape Expressions Compact Syntax (ShExC) parser.

MIT
Latest version published 1 year ago

Package Health Score

58 / 100
Full package analysis

Popular @shexjs/parser functions