@@ -516,6 +516,8 @@ jsonld.link = util.callbackify(async function(input, ctx, options) {
516
516
* `URGNA2012` (default: `URGNA2012`).
517
517
* [base] the base IRI to use.
518
518
* [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.
519
521
* [inputFormat] the format if input is not JSON-LD:
520
522
* 'application/n-quads' for N-Quads.
521
523
* [format] the format if output is a string:
@@ -534,7 +536,8 @@ jsonld.normalize = jsonld.canonize = util.callbackify(async function(
534
536
// set default options
535
537
options = _setDefaults ( options , {
536
538
base : _isString ( input ) ? input : '' ,
537
- algorithm : 'URDNA2015'
539
+ algorithm : 'URDNA2015' ,
540
+ skipExpansion : false
538
541
} ) ;
539
542
if ( 'inputFormat' in options ) {
540
543
if ( options . inputFormat !== 'application/n-quads' &&
@@ -639,6 +642,8 @@ jsonld.fromRDF = util.callbackify(async function(dataset, options) {
639
642
* @param [options] the options to use:
640
643
* [base] the base IRI to use.
641
644
* [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.
642
647
* [format] the format to use to output a string:
643
648
* 'application/n-quads' for N-Quads.
644
649
* [produceGeneralizedRdf] true to output generalized RDF, false
@@ -655,13 +660,18 @@ jsonld.toRDF = util.callbackify(async function(input, options) {
655
660
656
661
// set default options
657
662
options = _setDefaults ( options , {
658
- base : _isString ( input ) ? input : ''
663
+ base : _isString ( input ) ? input : '' ,
664
+ skipExpansion : false
659
665
} ) ;
660
666
661
667
// 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
+ }
665
675
666
676
// output RDF dataset
667
677
const dataset = _toRDF ( expanded , options ) ;
0 commit comments