error: Attempt to export a nullable value for "TextDecoderStream"
Unanswered
English Setter posted this in #help-forum
English SetterOP
Hello, I want to know if its normal that while using the middleware with bun.sh, I get this error
thanks for any help!
error: Attempt to export a nullable value for "TextDecoderStream" thanks for any help!
11 Replies
Egyptian Mau
Hi
Bun developer here
Basically we have not implemented some function yet like this one
They're exported but undefined
c++
class TextEncoderStream {
private:
std::u16string pendingHighSurrogate;
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
std::stringstream stream;
public:
TextEncoderStream() {
}
std::string encode(const std::u16string& chunk) {
std::u16string finalChunk;
for (const auto& item : chunk) {
uint16_t codeUnit = item;
if (!pendingHighSurrogate.empty()) {
const auto highSurrogate = pendingHighSurrogate;
pendingHighSurrogate.clear();
if (0xDC00 <= codeUnit && codeUnit <= 0xDFFF) {
finalChunk += highSurrogate + item;
continue;
}
finalChunk += u'\uFFFD';
}
if (0xD800 <= codeUnit && codeUnit <= 0xDBFF) {
pendingHighSurrogate = item;
continue;
}
if (0xDC00 <= codeUnit && codeUnit <= 0xDFFF) {
finalChunk += u'\uFFFD';
continue;
}
finalChunk += item;
}
if (!finalChunk.empty()) {
stream << converter.to_bytes(finalChunk);
}
return stream.str();
}
std::string flush() {
if (!pendingHighSurrogate.empty()) {
return "\xEF\xBF\xBD";
}
return "";
}
std::string getEncoding() const {
return "utf-8";
}
std::string getReadable() const {
return "ReadableStream";
}
std::string getWritable() const {
return "WritableStream";
}
};I suggest you go from here and implement it yourself
@English Setter
English SetterOP
@Egyptian Mau how could i implement that?
Egyptian Mau
Idk
What I'd do if I were you is to start by changing from undefined to sum dummy temp function
@Rafael Almeida What do you think should be done here?