All files / json-pack/src/cbor CborEncoderDag.ts

100% Statements 11/11
100% Branches 3/3
100% Functions 3/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 193x   3x   1x       2076x 2075x 2073x       6x 6x      
import {CborEncoderStable} from './CborEncoderStable';
 
export class CborEncoderDag extends CborEncoderStable {
  public writeUndef(): void {
    this.writeNull();
  }
 
  public writeFloat(float: number): void {
    if (float !== float) return this.writeNull();
    if (!Number.isFinite(float)) return this.writeNull();
    this.writer.u8f64(0xfb, float);
  }
 
  public writeTag(tag: number, value: unknown): void {
    if (tag === 42) this.writeTagHdr(tag);
    this.writeAny(value);
  }
}