'use strict' ; import { JSEDINotation } from './JSEDINotation' ; import { X12Interchange } from './X12Interchange' ; import { defaultSerializationOptions , X12SerializationOptions } from './X12SerializationOptions' ; export class X12FatInterchange extends Array < X12Interchange > { description param { X12Interchange [ ] | X12SerializationOptions } items param { X12SerializationOptions } options constructor ( items ? , options ? ) { if ( Array . isArray ( items ) ) { super ( ... items ) ; } else { super ( ) ; options = items ; } this . options = defaultSerializationOptions ( options ) ; this . interchanges = this ; } interchanges : X12Interchange [ ] ; options : X12SerializationOptions ; description param { X12SerializationOptions } options returns { string } toString ( options ? ) { options = options !== undefined ? defaultSerializationOptions ( options ) : this . options ; let edi = '' ; for ( let i = 0 ; i < this . interchanges . length ; i ++ ) { edi += this . interchanges [ i ] . toString ( options ) ; if ( options . format ) { edi += options . endOfLine ; } } return edi ; } description returns { JSEDINotation [ ] } toJSEDINotation ( ) { const jsen = new Array < JSEDINotation > ( ) ; this . interchanges . forEach ( interchange => { jsen . push ( interchange . toJSEDINotation ( ) ) ; } ) ; return jsen ; } description returns { object [ ] } toJSON ( ) { return this . toJSEDINotation ( ) ; } }