import { array , chain , Decoder , fields , fieldsAuto , number , optional , string , } from ".." ; test ( "decoding to a Set" , ( ) => { const data = [ 1 , 2 , 1 , 3 , 2 ] ; expect ( new Set ( array ( number ) ( data ) ) ) . toMatchInlineSnapshot ( `
    Set {
      1,
      2,
      3,
    }
  ` ) ; const obj = { id : "123" , numbers : data , } ; const objDecoder1 = fields ( ( field ) => ( { id : field ( "id" , string ) , numbers : new Set ( field ( "numbers" , array ( number ) ) ) , } ) ) ; expect ( objDecoder1 ( obj ) ) . toMatchInlineSnapshot ( `
    Object {
      "id": "123",
      "numbers": Set {
        1,
        2,
        3,
      },
    }
  ` ) ; const objDecoder2 = fields ( ( field ) => ( { id : field ( "id" , string ) , numbers : field ( "numbers" , optional ( chain ( array ( number ) , ( arr ) => new Set ( arr ) ) ) ) , } ) ) ; expect ( objDecoder2 ( obj ) ) . toEqual ( objDecoder1 ( obj ) ) ; const objDecoder3 = fieldsAuto ( { id : string , numbers : chain ( array ( number ) , ( arr ) => new Set ( arr ) ) , } ) ; expect ( objDecoder3 ( obj ) ) . toEqual ( objDecoder1 ( obj ) ) ; const decoder = chain ( number , Math . round ) ; expect ( decoder ( 4.9 ) ) . toMatchInlineSnapshot ( `5` ) ; } ) ;