export class Blob { type = 'application/json' ; } export class File extends Blob { name = 'file.json' ; } type FormDataEntryValue = File | string ; export interface HttpParameterCodec { encodeKey ( key ) : string ; encodeValue ( value ) : string ; decodeKey ( key ) : string ; decodeValue ( value ) : string ; } export interface HttpParamsOptions { encoder ? : HttpParameterCodec ; } abstract class ParamContainer < T > { private map = new Map < string , T [ ] > ( ) ; constructor ( ) { } has ( param ) { return this . map . has ( param ) ; } get ( param ) { const value = this . map . get ( param ) ; return value === undefined ? null : value [ 0 ] ; } getAll ( param ) { const value = this . map . get ( param ) ; return value === undefined ? null : value ; } keys ( ) { return Array . from ( this . map . keys ( ) ) ; } append ( param , value ) { if ( ! this . map . has ( param ) ) { this . map . set ( param , [ value ] ) ; } else { this . map . set ( param , [ ... ( this . map . get ( param ) || [ ] ) , value ] ) ; } return this ; } set ( param , value ) { this . map . set ( param , [ value ] ) ; return this ; } delete ( param , value ? ) { if ( value ) { this . map . set ( param , [ ... ( this . map . get ( param ) || [ ] ) ] . filter ( v => v !== value ) ) ; } else { this . map . delete ( param ) ; } return this ; } toString ( ) { return this . map . toString ( ) ; } } export class HttpParams extends ParamContainer < string > { constructor ( _options ? ) { super ( ) ; } } export class HttpHeaders extends ParamContainer < string > { } export class HttpRequest < _T > { constructor ( public method , public url , public body , public options ) { } } export class FormData extends ParamContainer < FormDataEntryValue > { forEach ( callbackfn , thisArg ? ) { for ( const key of this . keys ( ) ) { const value = this . get ( key ) ; if ( value ) { callbackfn . apply ( thisArg || this , [ value , key , this ] ) ; } } } }