from static method

JsonLdGraphEncoderOptions from(
  1. RdfGraphEncoderOptions options
)

Creates a JSON-LD encoder options object from generic RDF encoder options

This factory method ensures that when generic RdfGraphEncoderOptions are provided to a method expecting JSON-LD-specific options, they are properly converted.

If the provided options are already a JsonLdGraphEncoderOptions instance, they are returned as-is. Otherwise, a new instance is created with the custom prefixes and default values for generateMissingPrefixes and includeBaseDeclaration.

Implementation

static JsonLdGraphEncoderOptions from(RdfGraphEncoderOptions options) =>
    switch (options) {
      JsonLdGraphEncoderOptions _ => options,
      _ => JsonLdGraphEncoderOptions(
          customPrefixes: options.customPrefixes,
          iriRelativization: options.iriRelativization,
        ),
    };