(
x: CborStreamInput,
)
| 116 | } |
| 117 | |
| 118 | async *#encode( |
| 119 | x: CborStreamInput, |
| 120 | ): AsyncGenerator<Uint8Array> { |
| 121 | if ( |
| 122 | x instanceof CborByteEncoderStream || |
| 123 | x instanceof CborTextEncoderStream || |
| 124 | x instanceof CborArrayEncoderStream || |
| 125 | x instanceof CborMapEncoderStream |
| 126 | ) { |
| 127 | for await (const y of x.readable) { |
| 128 | yield y; |
| 129 | } |
| 130 | } else if (x instanceof Array) { |
| 131 | for await (const y of this.#encodeArray(x)) { |
| 132 | yield y; |
| 133 | } |
| 134 | } else if (x instanceof CborTag) { |
| 135 | for await (const y of this.#encodeTag(x)) { |
| 136 | yield y; |
| 137 | } |
| 138 | } else if (typeof x === "object" && x !== null) { |
| 139 | if (x instanceof Date || x instanceof Uint8Array) yield encodeCbor(x); |
| 140 | else { |
| 141 | for await (const y of this.#encodeObject(x)) { |
| 142 | yield y; |
| 143 | } |
| 144 | } |
| 145 | } else yield encodeCbor(x); |
| 146 | } |
| 147 | |
| 148 | async *#encodeArray(x: CborStreamInput[]): AsyncGenerator<Uint8Array> { |
| 149 | if (x.length < 24) yield new Uint8Array([0b100_00000 + x.length]); |
no test coverage detected