@metreeca/qest - v0.10.0
    Preparing search index...

    Function encodeResource

    • Encodes a resource state as a JSON string.

      Serialises a Resource into a JSON string, recursively internalising absolute IRIs against the provided base.

      Parameters

      • resource: Resource

        The resource state to encode

      • options: EncoderOpts = {}

        Encoding options

        Configuration options for encoding operations.

        • Optional Readonlybase?: IRI

          Base IRI for IRI internalisation (must be absolute and hierarchical).

          Converts absolute IRIs to internal (root-relative) form.

          If omitted, IRIs are internalised against app.

        • Optional Readonlyindent?: boolean | number

          Indentation level for pretty-printing encoded output.

          • When true, uses default indentation
          • When a positive number, indents with that many spaces
          • When false or a number less than or equal to 0, disables indentation

          If omitted, output is not indented.

      Returns string

      The JSON string with internalised IRIs

      TypeError If base is not a hierarchical IRI

      encodeResource(
      { id: "https://example.com/products/42", name: "Widget", price: 29.99 },
      { base: "https://example.com/" }
      );
      // → '{"id":"/products/42","name":"Widget","price":29.99}'