All files Map.ts

100% Statements 9/9
100% Branches 2/2
100% Functions 3/3
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 171x   1x         1x 1x 1x     1x 1x   1x  
import Decoder, { Decoded } from './Decoder';
 
export default class Map<a, b> extends Decoder<b> {
  private fn: (value: a) => b;
  private decoder: Decoder<a>;
 
  constructor(fn: (value: a) => b, decoder: Decoder<a>) {
    super();
    this.decoder = decoder;
    this.fn = fn;
  }
 
  public run(value: unknown): Decoded<b> {
    return this.decoder.run(value).map(this.fn);
  }
}