Type Alias EntryContentTypeFormatData

EntryContentTypeFormatData: (
    | {
        type: | "JSON"
        | "SNBT"
        | "ASCII"
        | "binary"
        | "binaryPlainText"
        | "hex"
        | "UTF-8"
        | "unknown";
    }
    | { format?: "BE"
    | "LE"
    | "LEV"; type: "NBT" }
    | { bytes: number; format: "BE" | "LE"; signed: boolean; type: "int" }
    | {
        resultType: "JSONNBT";
        type: "custom";
        parse(data: Buffer): Compound | Promise<Compound>;
        serialize(
            data: Compound,
        ): Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>;
    }
    | {
        resultType: "SNBT";
        type: "custom";
        parse(data: Buffer): string | Promise<string>;
        serialize(
            data: string,
        ): Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>;
    }
    | {
        resultType: "buffer";
        type: "custom";
        parse(
            data: Buffer,
        ): Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>;
        serialize(
            data: Buffer,
        ): Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>;
    }
    | {
        resultType: "unknown";
        type: "custom";
        parse(data: Buffer): any;
        serialize(
            data: any,
        ): Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>;
    }
) & { defaultValue?: Buffer; rawFileExtension?: string }

The format data for an entry content type.

Use this type if you want to have support for content type formats that aren't currently is use but may be in the future.

This is used in the entryContentTypeToFormatMap object.

Type declaration

  • {
        type:
            | "JSON"
            | "SNBT"
            | "ASCII"
            | "binary"
            | "binaryPlainText"
            | "hex"
            | "UTF-8"
            | "unknown";
    }
    • Readonlytype:
          | "JSON"
          | "SNBT"
          | "ASCII"
          | "binary"
          | "binaryPlainText"
          | "hex"
          | "UTF-8"
          | "unknown"

      The format type of the data.

  • { format?: "BE" | "LE" | "LEV"; type: "NBT" }
    • Optional Readonlyformat?: "BE" | "LE" | "LEV"

      The endianness of the data.

      If not present, "LE" should be assumed.

      • "BE": Big Endian
      • "LE": Little Endian
      • "LEV": Little Varint
      "LE"
      
    • Readonlytype: "NBT"

      The format type of the data.

  • { bytes: number; format: "BE" | "LE"; signed: boolean; type: "int" }
    • Readonlybytes: number

      How many bytes this integer is.

    • Readonlyformat: "BE" | "LE"

      The endianness of the data.

    • Readonlysigned: boolean

      The signedness of the data.

    • Readonlytype: "int"

      The format type of the data.

  • {
        resultType: "JSONNBT";
        type: "custom";
        parse(data: Buffer): Compound | Promise<Compound>;
        serialize(
            data: Compound,
        ): Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>;
    }
    • ReadonlyresultType: "JSONNBT"

      The format type that results from the parse method.

    • Readonlytype: "custom"

      The format type of the data.

    • parse:function
      • The function to parse the data.

        The data parameter should be the buffer read directly from the file or LevelDB entry.

        Parameters

        • data: Buffer

          The data to parse, as a buffer.

        Returns Compound | Promise<Compound>

        The parsed data.

    • serialize:function
      • The function to serialize the data.

        This result of this can be written directly to the file or LevelDB entry.

        Parameters

        Returns Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>

        The serialized data, as a buffer.

  • {
        resultType: "SNBT";
        type: "custom";
        parse(data: Buffer): string | Promise<string>;
        serialize(
            data: string,
        ): Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>;
    }
    • ReadonlyresultType: "SNBT"

      The format type that results from the parse method.

    • Readonlytype: "custom"

      The format type of the data.

    • parse:function
      • The function to parse the data.

        The data parameter should be the buffer read directly from the file or LevelDB entry.

        Parameters

        • data: Buffer

          The data to parse, as a buffer.

        Returns string | Promise<string>

        The parsed data.

    • serialize:function
      • The function to serialize the data.

        This result of this can be written directly to the file or LevelDB entry.

        Parameters

        • data: string

          The data to serialize.

        Returns Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>

        The serialized data, as a buffer.

  • {
        resultType: "buffer";
        type: "custom";
        parse(
            data: Buffer,
        ): Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>;
        serialize(
            data: Buffer,
        ): Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>;
    }
    • ReadonlyresultType: "buffer"

      The format type that results from the parse method.

    • Readonlytype: "custom"

      The format type of the data.

    • parse:function
      • The function to parse the data.

        The data parameter should be the buffer read directly from the file or LevelDB entry.

        Parameters

        • data: Buffer

          The data to parse, as a buffer.

        Returns Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>

        The parsed data.

    • serialize:function
      • The function to serialize the data.

        This result of this can be written directly to the file or LevelDB entry.

        Parameters

        • data: Buffer

          The data to serialize.

        Returns Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>

        The serialized data, as a buffer.

  • {
        resultType: "unknown";
        type: "custom";
        parse(data: Buffer): any;
        serialize(
            data: any,
        ): Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>;
    }
    • ReadonlyresultType: "unknown"

      The format type that results from the parse method.

    • Readonlytype: "custom"

      The format type of the data.

    • parse:function
      • The function to parse the data.

        The data parameter should be the buffer read directly from the file or LevelDB entry.

        Parameters

        • data: Buffer

          The data to parse, as a buffer.

        Returns any

        The parsed data.

    • serialize:function
      • The function to serialize the data.

        This result of this can be written directly to the file or LevelDB entry.

        Parameters

        • data: any

          The data to serialize.

        Returns Buffer<ArrayBufferLike> | Promise<Buffer<ArrayBufferLike>>

        The serialized data, as a buffer.

  • Optional ReadonlydefaultValue?: Buffer

    The default value to use when initializing a new entry.

    undefined
    
  • Optional ReadonlyrawFileExtension?: string

    The raw file extension of the data.

    If not present, "bin" should be assumed.

    "bin"