From dc04ca93060443a3ce6263a476f4dafc66afc6b3 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Sat, 28 Oct 2023 07:21:00 +0200 Subject: Add arkose_token to OpenaiChat --- .../@fastify/busboy/lib/utils/decodeText.js | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 g4f/Provider/npm/node_modules/@fastify/busboy/lib/utils/decodeText.js (limited to 'g4f/Provider/npm/node_modules/@fastify/busboy/lib/utils/decodeText.js') diff --git a/g4f/Provider/npm/node_modules/@fastify/busboy/lib/utils/decodeText.js b/g4f/Provider/npm/node_modules/@fastify/busboy/lib/utils/decodeText.js new file mode 100644 index 00000000..ee376062 --- /dev/null +++ b/g4f/Provider/npm/node_modules/@fastify/busboy/lib/utils/decodeText.js @@ -0,0 +1,26 @@ +'use strict' + +// Node has always utf-8 +const utf8Decoder = new TextDecoder('utf-8') +const textDecoders = new Map([ + ['utf-8', utf8Decoder], + ['utf8', utf8Decoder] +]) + +function decodeText (text, textEncoding, destEncoding) { + if (text) { + if (textDecoders.has(destEncoding)) { + try { + return textDecoders.get(destEncoding).decode(Buffer.from(text, textEncoding)) + } catch (e) { } + } else { + try { + textDecoders.set(destEncoding, new TextDecoder(destEncoding)) + return textDecoders.get(destEncoding).decode(Buffer.from(text, textEncoding)) + } catch (e) { } + } + } + return text +} + +module.exports = decodeText -- cgit v1.2.3