This is an automated email from the ASF dual-hosted git repository.
suyanhanx pushed a commit to branch nodejs-stream
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/nodejs-stream by this push:
new 5dce709da remove buffer stream(no need)
5dce709da is described below
commit 5dce709da5e83fde1890a7826fc098dc5d3eecbc
Author: suyanhanx <[email protected]>
AuthorDate: Mon Nov 27 16:35:14 2023 +0800
remove buffer stream(no need)
Signed-off-by: suyanhanx <[email protected]>
---
bindings/nodejs/tests/suites/sync.suite.mjs | 5 +++--
bindings/nodejs/tests/utils.mjs | 20 --------------------
2 files changed, 3 insertions(+), 22 deletions(-)
diff --git a/bindings/nodejs/tests/suites/sync.suite.mjs
b/bindings/nodejs/tests/suites/sync.suite.mjs
index 66a26cbac..aab6df45f 100644
--- a/bindings/nodejs/tests/suites/sync.suite.mjs
+++ b/bindings/nodejs/tests/suites/sync.suite.mjs
@@ -20,7 +20,8 @@
import { randomUUID } from 'node:crypto'
import { test } from 'vitest'
import { WriterStream, ReaderStream } from '../../index.js'
-import { BufferStream, generateFixedBytes } from '../utils.mjs'
+import { generateFixedBytes } from '../utils.mjs'
+import { Readable } from 'node:stream'
export function run(op) {
describe.runIf(op.capability().blocking)('sync tests', () => {
@@ -37,7 +38,7 @@ export function run(op) {
test.runIf(op.capability().write &&
op.capability().writeCanMulti)('blocking writer stream', async () => {
const filename = `random_file_${randomUUID()}`
const buf = generateFixedBytes(5 * 1024 * 1024)
- const r = new BufferStream(buf, {
+ const r = Readable.from(buf, {
highWaterMark: 5 * 1024 * 1024, // to buffer 5MB data to read
})
const w = new WriterStream(op, filename)
diff --git a/bindings/nodejs/tests/utils.mjs b/bindings/nodejs/tests/utils.mjs
index 874b3f67d..657221371 100644
--- a/bindings/nodejs/tests/utils.mjs
+++ b/bindings/nodejs/tests/utils.mjs
@@ -54,23 +54,3 @@ export function loadConfigFromEnv(scheme) {
.map(([key, value]) => [key.replace(prefix, ''), value]),
)
}
-
-// A readable stream that reads from a buffer
-export class BufferStream extends Readable {
- constructor(buffer, options) {
- super(options)
- this.buffer = buffer
- this.offset = 0
- }
-
- _read(size) {
- if (this.offset >= this.buffer.length) {
- this.push(null) // readable stream end, push `null` to end the stream
- return
- }
-
- const chunk = this.buffer.slice(this.offset, this.offset + size)
- this.push(chunk)
- this.offset += size
- }
-}