module Sprockets::EncodingUtils

def unmarshaled_deflated(str, window_bits = -Zlib::MAX_WBITS)

Experimental RBS support (using type sampling data from the type_fusion project).

def unmarshaled_deflated: (String str, ?Integer window_bits) -> (Array[Set] | String)

This signature was generated using 41 samples from 2 applications.

Returns unmarshaled Object or raises an Exception.

window_bits - Integer deflate window size. See ZLib::Inflate.new()
str - Marshaled String

otherwise inflate the data an unmarshal.
Checks leading marshal header to see if the bytes are uncompressed

Internal: Unmarshal optionally deflated data.
def unmarshaled_deflated(str, window_bits = -Zlib::MAX_WBITS)
  major, minor = str[0], str[1]
  if major && major.ord == Marshal::MAJOR_VERSION &&
      minor && minor.ord <= Marshal::MINOR_VERSION
    marshaled = str
  else
    begin
      marshaled = Zlib::Inflate.new(window_bits).inflate(str)
    rescue Zlib::DataError
      marshaled = str
    end
  end
  Marshal.load(marshaled)
end