From 4217fed9549a77d1ef0feafa9a8466920d9bf9e7 Mon Sep 17 00:00:00 2001 From: kezhaofeng Date: Thu, 10 Oct 2024 18:03:02 +0800 Subject: [PATCH] =?UTF-8?q?:book:=20=E6=96=87=E6=A1=A3=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deno.json | 2 +- src/readable_stream.ts | 7 +++++++ src/shared_flow.ts | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/deno.json b/deno.json index b858630..4671e76 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@gaubee/util", - "version": "0.9.0", + "version": "0.9.1", "tasks": { "build": "deno run -A ./dnt.ts", "npm": "deno task build && deno task pub-npm", diff --git a/src/readable_stream.ts b/src/readable_stream.ts index 0c5071f..574d9c8 100644 --- a/src/readable_stream.ts +++ b/src/readable_stream.ts @@ -17,6 +17,13 @@ interface ReadableByteWithController { (strategy?: QueuingStrategy & { type?: undefined }): ReadableDefaultStreamWithController; (strategy?: QueuingStrategy & { type: "bytes" }): ReadableByteStreamWithController; } +/** + * 一个易用的 ReadableStream 构造函数 + * - 直接暴露了 controller 对象 + * - pull/cancel 使用 SharedFlow 来暴露 + * @param strategy + * @returns + */ const withController: ReadableByteWithController = (strategy?: QueuingStrategy & { type?: "bytes" }) => { const result = obj_lazify({ get onPull() { diff --git a/src/shared_flow.ts b/src/shared_flow.ts index c668e17..eb02e3f 100644 --- a/src/shared_flow.ts +++ b/src/shared_flow.ts @@ -1,5 +1,5 @@ import { iter_map_async } from "./collections.ts"; -import { Func } from "./func.ts"; +import type { Func } from "./func.ts"; import { type ReadableDefaultStreamWithController, rs_with_controller } from "./readable_stream.ts"; /** SharedFlow 的监听函数定义 */