rdf-environment.js
/**
   The function decode accepts a document, a content type and an optional continuation,
   It parses the document and returns or continues with the result, by
   retrieving the respective decoder and delegating the operation
   to that function.
   It is defined as an instance function rather than static for the case where it would
   cache retrieval or decoding state.
   */
The function decode accepts a document, a content type and an optional continuation,
It parses the document and returns or continues with the result, by
retrieving the respective decoder and delegating the operation
to that function.
It is defined as an instance function rather than static for the case where it would
cache retrieval or decoding state.
The function decode accepts a document a content type and an optional continuation It parses the document and returns or continues with the result by retrieving the respective decoder and delegating the operation to that function . It is defined as an instance function rather than static for the case where it would cache retrieval or decoding state .
decode(document, mediaType, continuation = null) {
    var contentTypeStem;
    if (contentTypeStem = mediaTypeStem(mediaType)) {
      var decoder = decode[contentTypeStem];
      if (!decoder) {
        throw (new Error(`RDFEnvironment.decode: unsupported media type: ${mediaType}`));
      }
      var decoded = decoder(document, mediaType, continuation);
      if (decoded) {
        decoded.contentType = contentTypeStem;
      } else {
        console.warn("RDFEnvironment.decode: failed: ", mediaType, typeof(document));
      }
      return (decoded);
    } else {
      console.warn(`RDFEnvironment.decode: decoder not found: ${mediaType}`);
      return (null);
    }
  }
decode ( document , mediaType , continuation = null ) { var contentTypeStem ; if ( contentTypeStem = mediaTypeStem ( mediaType ) ) { var decoder = decode [ contentTypeStem ] ; if ( ! decoder ) { throw ( new Error ( ` ${ mediaType } ` ) ) ; } var decoded = decoder ( document , mediaType , continuation ) ; if ( decoded ) { decoded . contentType = contentTypeStem ; } else { console . warn ( "RDFEnvironment.decode: failed: " , mediaType , typeof ( document ) ) ; } return ( decoded ) ; } else { console . warn ( ` ${ mediaType } ` ) ; return ( null ) ; } }
The function decode accepts a document, a content type and an optional continuation,
It parses the document and returns or continues with the result, by
retrieving the respective decoder and delegating the operation
to that function.
The function decode accepts a document a content type and an optional continuation It parses the document and returns or continues with the result by retrieving the respective decoder and delegating the operation to that function .
// console.log("rdfenv.decode: for", mediaType, document); // console.log("rdfenv.decode: decoder", decoder); // must pass the content type as it can include arguments // console.log("rdfenv.decode: decoded", decoded);