diff options
Diffstat (limited to 'src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp')
-rw-r--r-- | src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp index 830fbfd51..03dcd26cb 100644 --- a/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp +++ b/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp @@ -211,6 +211,106 @@ const char* const s_readableStreamReadableStreamToBlobCode = "})\n" \ ; +const JSC::ConstructAbility s_readableStreamReadableStreamToNodeReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamReadableStreamToNodeReadableCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamReadableStreamToNodeReadableCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_readableStreamReadableStreamToNodeReadableCodeLength = 2476; +static const JSC::Intrinsic s_readableStreamReadableStreamToNodeReadableCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamReadableStreamToNodeReadableCode = + "(function (stream) {\n" \ + " \"use strict\";\n" \ + " var {Readable} = @require(\"node:stream\");\n" \ + "\n" \ + " var Prototype = class ReadableNodeStream extends Readable {\n" \ + " #reader;\n" \ + " #stream;\n" \ + " #pushed;\n" \ + " #boundOnData;\n" \ + " #scheduledRead;\n" \ + " constructor(stream) {\n" \ + " super();\n" \ + " this.#stream = stream;\n" \ + " this.#reader = @undefined;\n" \ + " this.#pushed = [];\n" \ + " this.#boundOnData = (result) => this.#onData(result);\n" \ + " this.#scheduledRead = false;\n" \ + " }\n" \ + "\n" \ + " _read(size = 0) {\n" \ + " if (!this.#reader) {\n" \ + " this.#reader = this.#stream.getReader();\n" \ + " }\n" \ + "\n" \ + " const pushed = this.#pushed;\n" \ + " const pending = pushed.length;\n" \ + " for (let i = 0; i < pending; i++) {\n" \ + " if (!this.push(pushed[i])) {\n" \ + " pushed.splice(0, i);\n" \ + " return;\n" \ + " }\n" \ + " }\n" \ + "\n" \ + " this.#scheduleRead();\n" \ + " }\n" \ + "\n" \ + " #handleData(value) {\n" \ + " var i = 0;\n" \ + " const expectedCount = this.#pushed.length;\n" \ + " var pushed = this.#pushed;\n" \ + " try {\n" \ + " for (i; i < expectedCount; i++) {\n" \ + " var item = pushed[i];\n" \ + " if (!this.push(item)) {\n" \ + " return false;\n" \ + " }\n" \ + " }\n" \ + " } catch(e) {\n" \ + " this.error(e);\n" \ + " return false;\n" \ + " } finally {\n" \ + " this.#pushed.splice(0, i);\n" \ + " if (this.#pushed.length > 0) {\n" \ + " this.#pushed.push(...value);\n" \ + " return false;\n" \ + " }\n" \ + "\n" \ + " }\n" \ + "\n" \ + " const valueLength = value.length;\n" \ + " for (i = 0; i < valueLength; i++) {\n" \ + " if (!this.push(value[i])) {\n" \ + " this.#pushed.push(...value.slice(i));\n" \ + " return false;\n" \ + " }\n" \ + " }\n" \ + "\n" \ + " return true;\n" \ + " }\n" \ + "\n" \ + " #onData({done, value}) {\n" \ + " this.#scheduledRead = false;\n" \ + "\n" \ + " if (done) {\n" \ + " this.destroy(@undefined);\n" \ + " return;\n" \ + " }\n" \ + "\n" \ + " if (!this.#handleData(value)) {\n" \ + " return;\n" \ + " }\n" \ + "\n" \ + " this.#scheduleRead();\n" \ + " }\n" \ + "\n" \ + " #scheduleRead() {\n" \ + " if (this.#scheduledRead) return;\n" \ + " this.#scheduledRead = true;\n" \ + " this.#reader.readMany().@then(this.#onData, this.error);\n" \ + " }\n" \ + " };\n" \ + "})\n" \ +; + const JSC::ConstructAbility s_readableStreamConsumeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_readableStreamConsumeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_readableStreamConsumeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private; @@ -563,6 +663,40 @@ const char* const s_readableStreamLockedCode = "})\n" \ ; +const JSC::ConstructAbility s_readableStreamValuesCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamValuesCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamValuesCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamValuesCodeLength = 249; +static const JSC::Intrinsic s_readableStreamValuesCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamValuesCode = + "(function (options) {\n" \ + " \"use strict\";\n" \ + " var prototype = this?.constructor?.prototype;\n" \ + " if (!prototype) {\n" \ + " return @undefined;\n" \ + " }\n" \ + " @readableStreamDefineLazyIterators(prototype);\n" \ + " return prototype.values.@call(this, options);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_readableStreamLazyAsyncIteratorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamLazyAsyncIteratorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamLazyAsyncIteratorCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_readableStreamLazyAsyncIteratorCodeLength = 259; +static const JSC::Intrinsic s_readableStreamLazyAsyncIteratorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamLazyAsyncIteratorCode = + "(function () {\n" \ + " \"use strict\";\n" \ + " var prototype = this?.constructor?.prototype;\n" \ + " if (!prototype) {\n" \ + " return @undefined;\n" \ + " }\n" \ + " @readableStreamDefineLazyIterators(prototype);\n" \ + " return prototype[globalThis.Symbol.asyncIterator].@call(this);\n" \ + "})\n" \ +; + #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ |