All files / json-patch/codec/binary Encoder.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 1/1
100% Lines 7/7

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 132x     2x   166x 166x 166x 166x 166x      
import {MsgPackEncoderFast as EncoderMessagePack} from '@jsonjoy.com/json-pack/lib/msgpack/MsgPackEncoderFast';
import type {Op} from '../../op';
 
export class Encoder extends EncoderMessagePack {
  public encode(patch: Op[]): Uint8Array {
    this.writer.reset();
    this.encodeArrayHeader(patch.length);
    const length = patch.length;
    for (let i = 0; i < length; i++) patch[i].encode(this);
    return this.writer.flush();
  }
}