@@ -516,6 +516,8 @@ jsonld.link = util.callbackify(async function(input, ctx, options) {
516516 * `URGNA2012` (default: `URGNA2012`).
517517 * [base] the base IRI to use.
518518 * [expandContext] a context to expand with.
519+ * [skipExpansion] true to assume the input is expanded and skip
520+ * expansion, false not to, defaults to false.
519521 * [inputFormat] the format if input is not JSON-LD:
520522 * 'application/n-quads' for N-Quads.
521523 * [format] the format if output is a string:
@@ -534,7 +536,8 @@ jsonld.normalize = jsonld.canonize = util.callbackify(async function(
534536 // set default options
535537 options = _setDefaults ( options , {
536538 base : _isString ( input ) ? input : '' ,
537- algorithm : 'URDNA2015'
539+ algorithm : 'URDNA2015' ,
540+ skipExpansion : false
538541 } ) ;
539542 if ( 'inputFormat' in options ) {
540543 if ( options . inputFormat !== 'application/n-quads' &&
@@ -639,6 +642,8 @@ jsonld.fromRDF = util.callbackify(async function(dataset, options) {
639642 * @param [options] the options to use:
640643 * [base] the base IRI to use.
641644 * [expandContext] a context to expand with.
645+ * [skipExpansion] true to assume the input is expanded and skip
646+ * expansion, false not to, defaults to false.
642647 * [format] the format to use to output a string:
643648 * 'application/n-quads' for N-Quads.
644649 * [produceGeneralizedRdf] true to output generalized RDF, false
@@ -655,13 +660,18 @@ jsonld.toRDF = util.callbackify(async function(input, options) {
655660
656661 // set default options
657662 options = _setDefaults ( options , {
658- base : _isString ( input ) ? input : ''
663+ base : _isString ( input ) ? input : '' ,
664+ skipExpansion : false
659665 } ) ;
660666
661667 // TODO: support toRDF custom map?
662-
663- // expand input
664- const expanded = await jsonld . expand ( input , options ) ;
668+ let expanded ;
669+ if ( options . skipExpansion ) {
670+ expanded = input ;
671+ } else {
672+ // expand input
673+ expanded = await jsonld . expand ( input , options ) ;
674+ }
665675
666676 // output RDF dataset
667677 const dataset = _toRDF ( expanded , options ) ;
0 commit comments