unikvs 0.0.9 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +3 -0
  2. package/dist/src/_logger.d.ts.map +1 -1
  3. package/dist/src/_merge-variables.d.ts +13 -0
  4. package/dist/src/_merge-variables.d.ts.map +1 -0
  5. package/dist/src/_merge-variables.js +12 -0
  6. package/dist/src/_storage.d.ts +11 -11
  7. package/dist/src/_storage.d.ts.map +1 -1
  8. package/dist/src/_storage.js +31 -22
  9. package/dist/src/_streams.d.ts +20 -0
  10. package/dist/src/_streams.d.ts.map +1 -0
  11. package/dist/src/_streams.js +36 -0
  12. package/dist/src/_to-value-stream.d.ts.map +1 -1
  13. package/dist/src/_to-value-stream.js +44 -6
  14. package/dist/src/_transformer.d.ts +7 -7
  15. package/dist/src/_transformer.d.ts.map +1 -1
  16. package/dist/src/_transformer.js +12 -12
  17. package/dist/src/_valibot.d.ts +6 -7
  18. package/dist/src/_valibot.d.ts.map +1 -1
  19. package/dist/src/_valibot.js +1 -1
  20. package/dist/src/_value-schemas.d.ts +179 -0
  21. package/dist/src/_value-schemas.d.ts.map +1 -0
  22. package/dist/src/_value-schemas.js +150 -0
  23. package/dist/src/errors.d.ts +218 -27
  24. package/dist/src/errors.d.ts.map +1 -1
  25. package/dist/src/errors.js +102 -47
  26. package/dist/src/index.d.ts +3 -3
  27. package/dist/src/index.d.ts.map +1 -1
  28. package/dist/src/index.js +2 -2
  29. package/dist/src/unikvs-config.d.ts +58 -139
  30. package/dist/src/unikvs-config.d.ts.map +1 -1
  31. package/dist/src/unikvs-config.js +41 -46
  32. package/dist/src/unikvs.d.ts +86 -161
  33. package/dist/src/unikvs.d.ts.map +1 -1
  34. package/dist/src/unikvs.js +374 -171
  35. package/dist/src/utils.types.d.ts +1 -3
  36. package/dist/src/utils.types.d.ts.map +1 -1
  37. package/dist/src/value-stream.types.d.ts +5 -6
  38. package/dist/src/value-stream.types.d.ts.map +1 -1
  39. package/dist/src/variables.types.d.ts +11 -0
  40. package/dist/src/variables.types.d.ts.map +1 -0
  41. package/package.json +26 -25
  42. package/src/_merge-variables.ts +19 -0
  43. package/src/_storage.ts +47 -24
  44. package/src/_streams.ts +47 -0
  45. package/src/_to-value-stream.ts +47 -8
  46. package/src/_transformer.ts +13 -13
  47. package/src/_valibot.ts +8 -6
  48. package/src/_value-schemas.ts +362 -0
  49. package/src/errors.ts +280 -68
  50. package/src/index.ts +2 -3
  51. package/src/unikvs-config.ts +142 -167
  52. package/src/unikvs.ts +523 -285
  53. package/src/utils.types.ts +1 -3
  54. package/src/value-stream.types.ts +5 -6
  55. package/src/variables.types.ts +13 -0
  56. package/dist/src/_merge-context.d.ts +0 -13
  57. package/dist/src/_merge-context.d.ts.map +0 -1
  58. package/dist/src/_merge-context.js +0 -12
  59. package/dist/src/context.types.d.ts +0 -17
  60. package/dist/src/context.types.d.ts.map +0 -1
  61. package/src/_merge-context.ts +0 -19
  62. package/src/context.types.ts +0 -19
  63. /package/dist/src/{context.types.js → variables.types.js} +0 -0
@@ -1,19 +1,45 @@
1
1
  import type {
2
- Context,
3
- IReadableStreamStorage,
4
2
  IStorage,
3
+ Variables,
4
+ ITransformer,
5
+ IReadableStreamStorage,
5
6
  IWritableStreamStorage,
6
7
  IDecodableStreamTransformer,
7
8
  IEncodableStreamTransformer,
8
- ITransformer,
9
9
  } from "@unikvs/core";
10
10
 
11
11
  import UniKvsStorage from "./_storage.js";
12
12
  import UniKvsTransformer from "./_transformer.js";
13
- import type { ContextSource } from "./context.types.js";
13
+ import * as v from "./_valibot.js";
14
+ import {
15
+ type Value,
16
+ type UniKvsSchema,
17
+ type $InferPlainValueData,
18
+ type IValueSchemaResolver,
19
+ type $InferStreamValueChunkData,
20
+ UniKvsSchemaSchema,
21
+ createValueSchemaResolver,
22
+ } from "./_value-schemas.js";
14
23
  import { MissingStorageError } from "./errors.js";
15
24
  import type UniKvs from "./unikvs.js";
16
25
  import type { ValueOf } from "./utils.types.js";
26
+ import type { VariablesSource } from "./variables.types.js";
27
+
28
+ export {
29
+ type UniKvsSchema,
30
+ type ValueSchemaInfo,
31
+ type UniKvsSchemaRecord,
32
+ type UniKvsSchemaEntries,
33
+ type $InferPlainValueData,
34
+ type IValueSchemaResolver,
35
+ type $InferKeyValueMapping,
36
+ type $InferPlainValueInput,
37
+ type $InferStreamValueChunkData,
38
+ type $InferStreamValueChunkInput,
39
+ Value,
40
+ PlainValue,
41
+ StreamValue,
42
+ } from "./_value-schemas.js";
17
43
 
18
44
  /**
19
45
  * トランスフォーマーから、デコード時の入力データの型を推論するユーティリティー型です。
@@ -68,81 +94,18 @@ type $InferReadChunkOutput<TStorage extends IStorage> =
68
94
  TStorage extends IReadableStreamStorage<infer TReadChunkOutput> ? TReadChunkOutput : never;
69
95
 
70
96
  /**
71
- * プレーンな値を識別するための固有のシンボルです。
72
- */
73
- declare const PLAIN_VALUE: unique symbol;
74
-
75
- /**
76
- * ストリームではない通常の値を表す型定義です。
77
- *
78
- * @template TData 保持するデータの型です。
79
- */
80
- export type PlainValue<TData = any> = [Type: typeof PLAIN_VALUE, Data: TData];
81
-
82
- /**
83
- * ストリーム形式の値を識別するための固有のシンボルです。
84
- */
85
- declare const STREAM_VALUE: unique symbol;
86
-
87
- /**
88
- * ストリームとして扱われる値を表す型定義です。
89
- *
90
- * @template TChunkData ストリームのチャンクデータの型です。
91
- */
92
- export type StreamValue<TChunkData = any> = [Type: typeof STREAM_VALUE, ChunkData: TChunkData];
93
-
94
- /**
95
- * UniKvs で扱う値の抽象型です。プレーンな値かストリーム値のいずれかになります。
96
- *
97
- * @template TData データまたはチャンクデータの型です。
98
- */
99
- export type Value<TData = any> = PlainValue<TData> | StreamValue<TData>;
100
-
101
- /**
102
- * キーと値のマッピングを定義するオブジェクトの型です。
103
- *
104
- * @template T マッピングされる値の型です。
97
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#value-types)
105
98
  */
106
99
  export type KeyValueMapping<T = any> = { readonly [key: IStorage.Key]: Value<T> };
107
100
 
108
101
  /**
109
- * PlainValue 型から内部のデータ型を抽出します。
110
- *
111
- * @template TPlainValue 対象となる PlainValue 型です。
112
- */
113
- export type $InferPlainValueData<TPlainValue> =
114
- TPlainValue extends PlainValue<infer TData> ? TData : never;
115
-
116
- /**
117
- * StreamValue 型から内部のチャンクデータ型を抽出します。
118
- *
119
- * @template TStremValue 対象となる StreamValue 型です。
120
- */
121
- export type $InferStreamValueChunkData<TStremValue> =
122
- TStremValue extends StreamValue<infer TChunkData> ? TChunkData : never;
123
-
124
- /**
125
- * KeyValueMapping から有効なキーの型を抽出します。
126
- *
127
- * @template TKeyValueMapping 対象となるマッピング型です。
102
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#value-types)
128
103
  */
129
104
  export type KeyofKeyValueMapping<TKeyValueMapping extends KeyValueMapping = KeyValueMapping> =
130
105
  Extract<keyof TKeyValueMapping, IStorage.Key>;
131
106
 
132
107
  /**
133
- * UniKvs の設定を構築するためのビルダーインターフェースです。
134
- *
135
- * トランスフォーマーの追加やストレージの登録を型安全に行うための流れるようなインターフェースを提供します。
136
- *
137
- * @template TKeyValueMapping キーと値のマッピング型です。
138
- * @template TUniKvsDataInput UniKvs への入力データの型です。
139
- * @template TUniKvsDataOutput UniKvs からの出力データの型です。
140
- * @template TUniKvsChunkInput UniKvs への入力チャンクデータの型です。
141
- * @template TUniKvsChunkOutput UniKvs からのストリーム出力チャンクデータの型です。
142
- * @template TLastTransformerDecodeDataInput 最後に適用されたトランスフォーマーのデコード入力データの型です。
143
- * @template TLastTransformerEncodeDataOutput 最後に適用されたトランスフォーマーのエンコード出力データの型です。
144
- * @template TLastTransformerDecodeChunkInput 最後に適用されたトランスフォーマーのデコード入力チャンクデータの型です。
145
- * @template TLastTransformerEncodeChunkOutput 最後に適用されたトランスフォーマーのエンコード出力チャンクデータの型です。
108
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
146
109
  */
147
110
  export interface IUniKvsConfigBuilder<
148
111
  TKeyValueMapping extends KeyValueMapping = KeyValueMapping,
@@ -162,21 +125,12 @@ export interface IUniKvsConfigBuilder<
162
125
  TLastTransformerEncodeChunkOutput = TUniKvsChunkInput,
163
126
  > {
164
127
  /**
165
- * コンテキスト情報を設定します。
166
- *
167
- * @param context 設定するコンテキストのソースです。
168
- * @returns インスタンス自身を返します。
128
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
169
129
  */
170
- setContext(context: ContextSource): this;
130
+ setVariables(vars: VariablesSource): this;
171
131
 
172
132
  /**
173
- * ストレージをパイプラインの終端に追加します。
174
- *
175
- * ストレージが追加されると、設定はファイナライズ段階に移行します。
176
- *
177
- * @template TStorage 追加するストレージの型です。
178
- * @param storage ストレージのインスタンスです。
179
- * @returns ファイナライザーインターフェースを返します。
133
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
180
134
  */
181
135
  appendStorage<
182
136
  TStorage extends IStorage<
@@ -200,17 +154,15 @@ export interface IUniKvsConfigBuilder<
200
154
  ? never
201
155
  : [$InferReadChunkOutput<TStorage>] extends [never]
202
156
  ? never
203
- : TLastTransformerDecodeChunkInput
157
+ : TLastTransformerDecodeChunkInput,
158
+ TLastTransformerDecodeDataInput,
159
+ TLastTransformerEncodeDataOutput,
160
+ TLastTransformerDecodeChunkInput,
161
+ TLastTransformerEncodeChunkOutput
204
162
  >;
205
163
 
206
164
  /**
207
- * トランスフォーマーをパイプラインに追加します。
208
- *
209
- * データ変換の層を積み重ねることで、シリアライズなどの処理を定義できます。
210
- *
211
- * @template TTransformer 追加するトランスフォーマーの型です。
212
- * @param transformer トランスフォーマーのインスタンスです。
213
- * @returns 新しい型情報を持つビルダーを返します。
165
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
214
166
  */
215
167
  appendTransformer<
216
168
  TTransformer extends ITransformer<
@@ -255,13 +207,7 @@ export interface IUniKvsConfigBuilder<
255
207
  }
256
208
 
257
209
  /**
258
- * UniKvs の設定を完了させるためのファイナライザーインターフェースです。
259
- *
260
- * @template TKeyValueMapping キーと値のマッピング型です。
261
- * @template TWriteDataInput ストレージへの書き込み入力データの型です。
262
- * @template TReadDataOutput ストレージからの読み込み出力データの型です。
263
- * @template TWriteChunkInput ストレージへの書き込みチャンクデータの型です。
264
- * @template TReadChunkOutput ストレージからの読み込みチャンクデータの型です。
210
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
265
211
  */
266
212
  export interface IUniKvsConfigFinalizer<
267
213
  TKeyValueMapping extends KeyValueMapping = KeyValueMapping,
@@ -269,35 +215,30 @@ export interface IUniKvsConfigFinalizer<
269
215
  TReadDataOutput = any,
270
216
  TWriteChunkInput = any,
271
217
  TReadChunkOutput = any,
218
+ TLastTransformerDecodeDataInput = TReadDataOutput,
219
+ TLastTransformerEncodeDataOutput = TWriteDataInput,
220
+ TLastTransformerDecodeChunkInput = TReadChunkOutput,
221
+ TLastTransformerEncodeChunkOutput = TWriteChunkInput,
272
222
  > {
273
223
  /**
274
- * 設定に基づいて UniKvs インスタンスを作成します。
275
- *
276
- * @returns 作成された UniKvs のインスタンスです。
224
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
277
225
  */
278
226
  create(): UniKvs<TKeyValueMapping>;
279
227
 
280
228
  /**
281
- * コンテキスト情報を設定します。
282
- *
283
- * @param context 設定するコンテキストのソースです。
284
- * @returns インスタンス自身を返します。
229
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
285
230
  */
286
- setContext(context: ContextSource): this;
231
+ setVariables(vars: VariablesSource): this;
287
232
 
288
233
  /**
289
- * 追加のストレージを登録します。UniKvs は複数のストレージへのマルチキャスト書き込みをサポートします。
290
- *
291
- * @template TStorage 追加するストレージの型です。
292
- * @param storage ストレージのインスタンスです。
293
- * @returns ファイナライザーインターフェースを返します。
234
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
294
235
  */
295
236
  appendStorage<
296
237
  TStorage extends IStorage<
297
- [TWriteDataInput] extends [never] ? any : TWriteDataInput,
298
- [TReadDataOutput] extends [never] ? any : TReadDataOutput,
299
- [TWriteChunkInput] extends [never] ? any : TWriteChunkInput,
300
- [TReadChunkOutput] extends [never] ? any : TReadChunkOutput
238
+ [TLastTransformerEncodeDataOutput] extends [never] ? any : TLastTransformerEncodeDataOutput,
239
+ [TLastTransformerDecodeDataInput] extends [never] ? any : TLastTransformerDecodeDataInput,
240
+ [TLastTransformerEncodeChunkOutput] extends [never] ? any : TLastTransformerEncodeChunkOutput,
241
+ [TLastTransformerDecodeChunkInput] extends [never] ? any : TLastTransformerDecodeChunkInput
301
242
  >,
302
243
  >(
303
244
  storage: TStorage,
@@ -314,14 +255,63 @@ export interface IUniKvsConfigFinalizer<
314
255
  ? never
315
256
  : [$InferReadChunkOutput<TStorage>] extends [never]
316
257
  ? never
317
- : TReadChunkOutput
258
+ : TReadChunkOutput,
259
+ TLastTransformerDecodeDataInput,
260
+ TLastTransformerEncodeDataOutput,
261
+ TLastTransformerDecodeChunkInput,
262
+ TLastTransformerEncodeChunkOutput
263
+ >;
264
+
265
+ /**
266
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
267
+ */
268
+ appendTransformer<
269
+ TTransformer extends ITransformer<
270
+ [TLastTransformerEncodeDataOutput] extends [never] ? any : TLastTransformerEncodeDataOutput,
271
+ any,
272
+ any,
273
+ [TLastTransformerDecodeDataInput] extends [never] ? any : TLastTransformerDecodeDataInput,
274
+ [TLastTransformerEncodeChunkOutput] extends [never] ? any : TLastTransformerEncodeChunkOutput,
275
+ any,
276
+ any,
277
+ [TLastTransformerDecodeChunkInput] extends [never] ? any : TLastTransformerDecodeChunkInput
278
+ >,
279
+ >(
280
+ transformer: TTransformer,
281
+ ): IUniKvsConfigFinalizer<
282
+ TKeyValueMapping,
283
+ TWriteDataInput,
284
+ TReadDataOutput,
285
+ TWriteChunkInput,
286
+ TReadChunkOutput,
287
+ $InferDecodeDataInput<TTransformer>,
288
+ $InferEncodeDataOutput<TTransformer>,
289
+ $InferDecodeChunkInput<TTransformer>,
290
+ $InferEncodeChunkOutput<TTransformer>
318
291
  >;
319
292
  }
320
293
 
321
294
  /**
322
- * UniKvs の構成を管理する設定クラスです。
323
- *
324
- * ビルダーパターンを用いて、コンテキスト、トランスフォーマー、ストレージの順で設定を積み上げます。
295
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
296
+ */
297
+ export type UniKvsConfigOptions = {
298
+ /**
299
+ * キーと値のスキーマ定義です。指定すると入出力値が検証されます。
300
+ */
301
+ readonly schema?: UniKvsSchema | undefined;
302
+ };
303
+
304
+ const UniKvsConfigOptionsSchema = v.object({
305
+ /**
306
+ * キーと値のスキーマ定義です。
307
+ */
308
+ schema: v.optional(UniKvsSchemaSchema),
309
+ });
310
+
311
+ const UniKvsConfigArgsSchema = v.tuple([v.optional(UniKvsConfigOptionsSchema)]);
312
+
313
+ /**
314
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
325
315
  */
326
316
  export default class UniKvsConfig implements IUniKvsConfigBuilder, IUniKvsConfigFinalizer {
327
317
  /**
@@ -330,95 +320,80 @@ export default class UniKvsConfig implements IUniKvsConfigBuilder, IUniKvsConfig
330
320
  readonly #UniKvs: typeof UniKvs;
331
321
 
332
322
  /**
333
- * アプリケーションの実行時情報を保持するコンテキストオブジェクトです。
323
+ * アプリケーションの実行時情報を保持する変数オブジェクトです。
334
324
  */
335
- #context: Context;
325
+ #vars: Variables;
336
326
 
337
327
  /**
338
- * データの永続化先となるストレージのリストです。
328
+ * データの永続化先となるストレージのリストです。各ストレージは登録時点のトランスフォーマー数を保持します。
339
329
  */
340
- readonly #destinations: IStorage[];
330
+ readonly #destinations: { readonly storage: IStorage; readonly transformerCount: number }[];
341
331
 
342
332
  /**
343
- * データを変換するためのトランスフォーマーのリストです。
333
+ * データを変換するためのトランスフォーマーのリストです。登録順に保持します。
344
334
  */
345
335
  readonly #transformers: ITransformer[];
346
336
 
347
337
  /**
348
- * UniKvsConfig インスタンスを初期化します。
349
- *
350
- * @param UniKvsConstructor UniKvs のクラスコンストラクターです。
338
+ * キーに対応する値のスキーマ情報を解決するリゾルバーです。スキーマ未設定時は null となります。
339
+ */
340
+ readonly #valueSchemaResolver: IValueSchemaResolver | null;
341
+
342
+ /**
343
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
351
344
  */
352
- public constructor(UniKvsConstructor: typeof UniKvs) {
345
+ public constructor(UniKvsConstructor: typeof UniKvs, options?: UniKvsConfigOptions) {
346
+ const [parsed = {}] = v.parseInput(UniKvsConfigArgsSchema, [options]);
347
+
353
348
  this.#UniKvs = UniKvsConstructor;
354
- this.#context = {};
349
+ this.#vars = {};
355
350
  this.#destinations = [];
356
351
  this.#transformers = [];
352
+ this.#valueSchemaResolver = parsed.schema ? createValueSchemaResolver(parsed.schema) : null;
357
353
  }
358
354
 
359
355
  /**
360
- * 現在の設定を使用して UniKvs インスタンスを作成します。
361
- *
362
- * @returns 作成された UniKvs インスタンスです。
363
- * @throws ストレージが一つも登録されていない場合にエラーを投げます。
356
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
364
357
  */
365
358
  public create(): UniKvs {
366
- // 登録されたストレージから先頭の要素を取得します。
367
- const [dest, ...destinations] = this.#destinations.map((io) => new UniKvsStorage(io));
359
+ const transformers = this.#transformers.map((tf) => new UniKvsTransformer(tf));
360
+
361
+ const [first, ...rest] = this.#destinations.map(({ storage, transformerCount }) => ({
362
+ storage: new UniKvsStorage(storage),
363
+ transformers: transformers.slice(0, transformerCount),
364
+ }));
368
365
 
369
366
  // ストレージが空の場合は UniKvs として機能できないため、例外を投げます。
370
- if (!dest) {
367
+ if (!first) {
371
368
  throw new MissingStorageError();
372
369
  }
373
370
 
374
- // コンテキストの参照を切り離すために浅いコピーを作成して UniKvs を初期化します。
375
- // トランスフォーマーの配列もスライスしてコピーを渡し、内部状態の安全性を確保します。
376
- return new this.#UniKvs(
377
- this.#context,
378
- [dest, ...destinations],
379
- this.#transformers.map((tf) => new UniKvsTransformer(tf)),
380
- );
371
+ // 変数の参照を切り離すために浅いコピーを作成して UniKvs を初期化します。
372
+ return new this.#UniKvs(this.#vars, [first, ...rest], transformers, this.#valueSchemaResolver);
381
373
  }
382
374
 
383
375
  /**
384
- * コンテキスト情報を設定します。既存のコンテキストは上書きされます。
385
- *
386
- * @param context 設定するコンテキストのソースデータです。
387
- * @returns インスタンス自身を返します。
376
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
388
377
  */
389
- public setContext(context: ContextSource): this {
390
- this.#context = Array.isArray(context) ? Object.fromEntries(context) : { ...context };
378
+ public setVariables(vars: VariablesSource): this {
379
+ this.#vars = Array.isArray(vars) ? Object.fromEntries(vars) : { ...vars };
391
380
 
392
381
  return this;
393
382
  }
394
383
 
395
384
  /**
396
- * ストレージを登録リストに追加します。
397
- *
398
- * @param storage 追加するストレージインスタンスです。
399
- * @returns ファイナライザーとして自身を返します。
385
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
400
386
  */
401
- public appendStorage(storage: IStorage): IUniKvsConfigFinalizer {
402
- this.#destinations.push(storage);
387
+ public appendStorage(storage: IStorage): this {
388
+ this.#destinations.push({ storage, transformerCount: this.#transformers.length });
403
389
 
404
390
  return this;
405
391
  }
406
392
 
407
393
  /**
408
- * トランスフォーマーを変換パイプラインに追加します。
409
- *
410
- * ストレージが登録された後には追加できない制約があります。
411
- *
412
- * @param transformer 追加するトランスフォーマーインスタンスです。
413
- * @returns ビルダーとして自身を返します。
414
- * @throws すでにストレージが登録されている状態で呼び出された場合にエラーを投げます。
394
+ * [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#config-builder)
415
395
  */
416
- public appendTransformer(transformer: ITransformer): IUniKvsConfigBuilder {
417
- // パイプラインの順序を守るため、終端であるストレージが登録済みでないか確認します。
418
- if (this.#destinations.length > 0) {
419
- throw new TransformStreamDefaultController();
420
- }
421
-
396
+ public appendTransformer(transformer: ITransformer): this {
422
397
  this.#transformers.push(transformer);
423
398
 
424
399
  return this;