diff --git a/api/classes/abstractwriter.abstractwriter-1.html b/api/classes/abstractwriter.abstractwriter-1.html index d7716964..7d73f76f 100644 --- a/api/classes/abstractwriter.abstractwriter-1.html +++ b/api/classes/abstractwriter.abstractwriter-1.html @@ -165,7 +165,7 @@

addAnnotation

@@ -195,7 +195,7 @@

close

@@ -224,7 +224,7 @@

depth

@@ -247,7 +247,7 @@

getBytes

@@ -277,7 +277,7 @@

setAnnotations

@@ -308,7 +308,7 @@

stepIn

@@ -343,7 +343,7 @@

stepOut

@@ -371,7 +371,7 @@

writeBlob

@@ -403,7 +403,7 @@

writeBoolean

@@ -435,7 +435,7 @@

writeClob

@@ -467,7 +467,7 @@

writeDecimal

@@ -499,7 +499,7 @@

writeFieldName

@@ -534,7 +534,7 @@

writeFloat32

@@ -568,7 +568,7 @@

writeFloat64

@@ -600,7 +600,7 @@

writeInt

@@ -634,7 +634,7 @@

writeNull

@@ -663,7 +663,7 @@

writeString

@@ -695,7 +695,7 @@

writeSymbol

@@ -727,7 +727,7 @@

writeTimestamp

@@ -759,7 +759,7 @@

writeValue

@@ -793,7 +793,7 @@

writeValues

diff --git a/api/classes/bigintserde.bigintserde-1.html b/api/classes/bigintserde.bigintserde-1.html index 3dd51ea0..4688aa1f 100644 --- a/api/classes/bigintserde.bigintserde-1.html +++ b/api/classes/bigintserde.bigintserde-1.html @@ -135,7 +135,7 @@

Static fromUnsignedByt
  • @@ -167,7 +167,7 @@

    Static getUnsignedInt<
  • Parameters

    @@ -190,7 +190,7 @@

    Static toSignedInt
    @@ -229,7 +229,7 @@

    Static toUnsignedInt
    diff --git a/api/classes/comparisonresult.comparisonresult-1.html b/api/classes/comparisonresult.comparisonresult-1.html index 0e544079..9bf0d97f 100644 --- a/api/classes/comparisonresult.comparisonresult-1.html +++ b/api/classes/comparisonresult.comparisonresult-1.html @@ -117,7 +117,7 @@

    constructor

  • Parameters

    @@ -148,7 +148,7 @@

    actualIndex

    actualIndex: number
    @@ -158,7 +158,7 @@

    expectedIndex

    expectedIndex: number
    @@ -168,7 +168,7 @@

    message

    message: string
    @@ -178,7 +178,7 @@

    result

    diff --git a/api/classes/dom_blob.blob.html b/api/classes/dom_blob.blob.html index b6a58726..c15ea7c5 100644 --- a/api/classes/dom_blob.blob.html +++ b/api/classes/dom_blob.blob.html @@ -191,7 +191,7 @@

    constructor

    @@ -255,7 +255,7 @@

    _ionAnnotations

    @@ -266,7 +266,7 @@

    _ionType

    @@ -382,7 +382,7 @@

    _setAnnotations

    Parameters

    @@ -406,7 +406,7 @@

    _unsupportedOperation

    Type parameters

    @@ -436,7 +436,7 @@

    _valueEquals

    Parameters

    @@ -477,7 +477,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -495,7 +495,7 @@

    as

    Type parameters

    @@ -525,7 +525,7 @@

    bigIntValue

    Returns null | bigint

    @@ -543,7 +543,7 @@

    booleanValue

    Returns null | boolean

    @@ -608,7 +608,7 @@

    dateValue

    Returns null | Date

    @@ -626,7 +626,7 @@

    decimalValue

    Returns null | Decimal

    @@ -644,7 +644,7 @@

    deleteField

    Parameters

    @@ -668,7 +668,7 @@

    elements

    Returns Value[]

    @@ -709,7 +709,7 @@

    equals

    @@ -811,7 +811,7 @@

    fieldNames

    Returns string[]

    @@ -829,7 +829,7 @@

    fields

    Returns [string, Value][]

    @@ -1153,7 +1153,7 @@

    get

    Parameters

    @@ -1177,7 +1177,7 @@

    getAll

    Parameters

    @@ -1201,7 +1201,7 @@

    getAnnotations

    Returns string[]

    @@ -1219,7 +1219,7 @@

    getType

    Returns IonType

    @@ -1314,7 +1314,7 @@

    ionEquals

    @@ -1357,7 +1357,7 @@

    isNull

    Returns boolean

    @@ -1535,7 +1535,7 @@

    numberValue

    Returns null | number

    @@ -2126,7 +2126,7 @@

    stringValue

    Returns null | string

    @@ -2183,7 +2183,7 @@

    timestampValue

    Returns null | Timestamp

    @@ -2200,7 +2200,7 @@

    toJSON

  • @@ -2269,7 +2269,7 @@

    uInt8ArrayValue

    Returns Uint8Array

    @@ -2348,7 +2348,7 @@

    writeTo

    Parameters

    @@ -2372,7 +2372,7 @@

    Static _fromJsValue

    Parameters

    @@ -2399,7 +2399,7 @@

    Static _getIonType

    Inherited from Lob(IonTypes.BLOB)._getIonType

    Returns IonType

    diff --git a/api/classes/dom_boolean.boolean.html b/api/classes/dom_boolean.boolean.html index a3adf79a..1a3d208a 100644 --- a/api/classes/dom_boolean.boolean.html +++ b/api/classes/dom_boolean.boolean.html @@ -173,7 +173,7 @@

    constructor

    @@ -210,7 +210,7 @@

    _ionAnnotations

    @@ -221,7 +221,7 @@

    _ionType

    @@ -239,7 +239,7 @@

    _setAnnotations

    Parameters

    @@ -263,7 +263,7 @@

    _unsupportedOperation

    Type parameters

    @@ -293,7 +293,7 @@

    _valueEquals

    Parameters

    @@ -334,7 +334,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -352,7 +352,7 @@

    as

    Type parameters

    @@ -382,7 +382,7 @@

    bigIntValue

    Returns null | bigint

    @@ -400,7 +400,7 @@

    booleanValue

    Returns boolean

    @@ -418,7 +418,7 @@

    dateValue

    Returns null | Date

    @@ -436,7 +436,7 @@

    decimalValue

    Returns null | Decimal

    @@ -454,7 +454,7 @@

    deleteField

    Parameters

    @@ -478,7 +478,7 @@

    elements

    Returns Value[]

    @@ -496,7 +496,7 @@

    equals

    @@ -533,7 +533,7 @@

    fieldNames

    Returns string[]

    @@ -551,7 +551,7 @@

    fields

    Returns [string, Value][]

    @@ -569,7 +569,7 @@

    get

    Parameters

    @@ -593,7 +593,7 @@

    getAll

    Parameters

    @@ -617,7 +617,7 @@

    getAnnotations

    Returns string[]

    @@ -635,7 +635,7 @@

    getType

    Returns IonType

    @@ -653,7 +653,7 @@

    ionEquals

    @@ -696,7 +696,7 @@

    isNull

    Returns boolean

    @@ -714,7 +714,7 @@

    numberValue

    Returns null | number

    @@ -732,7 +732,7 @@

    stringValue

    Returns null | string

    @@ -750,7 +750,7 @@

    timestampValue

    Returns null | Timestamp

    @@ -768,7 +768,7 @@

    uInt8ArrayValue

    Returns null | Uint8Array

    @@ -824,7 +824,7 @@

    writeTo

    Parameters

    @@ -848,7 +848,7 @@

    Static _fromJsValue

    Parameters

    @@ -875,7 +875,7 @@

    Static _getIonType

    Inherited from Value(_NativeJsBoolean,IonTypes.BOOL,_fromJsConstructor)._getIonType

    Returns IonType

    diff --git a/api/classes/dom_clob.clob.html b/api/classes/dom_clob.clob.html index e5f10280..dde72b84 100644 --- a/api/classes/dom_clob.clob.html +++ b/api/classes/dom_clob.clob.html @@ -191,7 +191,7 @@

    constructor

    @@ -255,7 +255,7 @@

    _ionAnnotations

    @@ -266,7 +266,7 @@

    _ionType

    @@ -382,7 +382,7 @@

    _setAnnotations

    Parameters

    @@ -406,7 +406,7 @@

    _unsupportedOperation

    Type parameters

    @@ -436,7 +436,7 @@

    _valueEquals

    Parameters

    @@ -477,7 +477,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -495,7 +495,7 @@

    as

    Type parameters

    @@ -525,7 +525,7 @@

    bigIntValue

    Returns null | bigint

    @@ -543,7 +543,7 @@

    booleanValue

    Returns null | boolean

    @@ -608,7 +608,7 @@

    dateValue

    Returns null | Date

    @@ -626,7 +626,7 @@

    decimalValue

    Returns null | Decimal

    @@ -644,7 +644,7 @@

    deleteField

    Parameters

    @@ -668,7 +668,7 @@

    elements

    Returns Value[]

    @@ -709,7 +709,7 @@

    equals

    @@ -811,7 +811,7 @@

    fieldNames

    Returns string[]

    @@ -829,7 +829,7 @@

    fields

    Returns [string, Value][]

    @@ -1153,7 +1153,7 @@

    get

    Parameters

    @@ -1177,7 +1177,7 @@

    getAll

    Parameters

    @@ -1201,7 +1201,7 @@

    getAnnotations

    Returns string[]

    @@ -1219,7 +1219,7 @@

    getType

    Returns IonType

    @@ -1314,7 +1314,7 @@

    ionEquals

    @@ -1357,7 +1357,7 @@

    isNull

    Returns boolean

    @@ -1535,7 +1535,7 @@

    numberValue

    Returns null | number

    @@ -2126,7 +2126,7 @@

    stringValue

    Returns null | string

    @@ -2183,7 +2183,7 @@

    timestampValue

    Returns null | Timestamp

    @@ -2200,7 +2200,7 @@

    toJSON

  • Returns string

    @@ -2264,7 +2264,7 @@

    uInt8ArrayValue

    Returns Uint8Array

    @@ -2343,7 +2343,7 @@

    writeTo

    Parameters

    @@ -2367,7 +2367,7 @@

    Static _fromJsValue

    Parameters

    @@ -2394,7 +2394,7 @@

    Static _getIonType

    Inherited from Lob(IonTypes.CLOB)._getIonType

    Returns IonType

    diff --git a/api/classes/dom_decimal.decimal.html b/api/classes/dom_decimal.decimal.html index 5fc304d9..a5f82f73 100644 --- a/api/classes/dom_decimal.decimal.html +++ b/api/classes/dom_decimal.decimal.html @@ -176,7 +176,7 @@

    constructor

    @@ -205,7 +205,7 @@

    Returns

    Overrides Value(Number,IonTypes.DECIMAL,_fromJsConstructor).constructor

    @@ -234,7 +234,7 @@

    Returns

    Overrides Value(Number,IonTypes.DECIMAL,_fromJsConstructor).constructor

    @@ -271,7 +271,7 @@

    _ionAnnotations

    @@ -282,7 +282,7 @@

    _ionType

    @@ -437,7 +437,7 @@

    _setAnnotations

    Parameters

    @@ -461,7 +461,7 @@

    _unsupportedOperation

    Type parameters

    @@ -491,7 +491,7 @@

    _valueEquals

    Parameters

    @@ -535,7 +535,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -553,7 +553,7 @@

    as

    Type parameters

    @@ -583,7 +583,7 @@

    bigIntValue

    Returns null | bigint

    @@ -601,7 +601,7 @@

    booleanValue

    Returns null | boolean

    @@ -619,7 +619,7 @@

    dateValue

    Returns null | Date

    @@ -637,7 +637,7 @@

    decimalValue

    Returns Decimal

    @@ -655,7 +655,7 @@

    deleteField

    Parameters

    @@ -679,7 +679,7 @@

    elements

    Returns Value[]

    @@ -697,7 +697,7 @@

    equals

    @@ -734,7 +734,7 @@

    fieldNames

    Returns string[]

    @@ -752,7 +752,7 @@

    fields

    Returns [string, Value][]

    @@ -770,7 +770,7 @@

    get

    Parameters

    @@ -794,7 +794,7 @@

    getAll

    Parameters

    @@ -818,7 +818,7 @@

    getAnnotations

    Returns string[]

    @@ -836,7 +836,7 @@

    getType

    Returns IonType

    @@ -854,7 +854,7 @@

    ionEquals

    @@ -897,7 +897,7 @@

    isNull

    Returns boolean

    @@ -915,7 +915,7 @@

    numberValue

    Returns number

    @@ -933,7 +933,7 @@

    stringValue

    Returns null | string

    @@ -951,7 +951,7 @@

    timestampValue

    Returns null | Timestamp

    @@ -1118,7 +1118,7 @@

    toString

    Returns string

    @@ -1136,7 +1136,7 @@

    uInt8ArrayValue

    Returns null | Uint8Array

    @@ -1154,7 +1154,7 @@

    valueOf

    Returns number

    @@ -1172,7 +1172,7 @@

    writeTo

    Parameters

    @@ -1196,7 +1196,7 @@

    Static _fromJsValue

    Parameters

    @@ -1223,7 +1223,7 @@

    Static _getIonType

    Inherited from Value(Number,IonTypes.DECIMAL,_fromJsConstructor)._getIonType

    Returns IonType

    diff --git a/api/classes/dom_float.float.html b/api/classes/dom_float.float.html index bbcc99be..e38e4d81 100644 --- a/api/classes/dom_float.float.html +++ b/api/classes/dom_float.float.html @@ -174,7 +174,7 @@

    constructor

    @@ -211,7 +211,7 @@

    _ionAnnotations

    @@ -222,7 +222,7 @@

    _ionType

    @@ -377,7 +377,7 @@

    _setAnnotations

    Parameters

    @@ -401,7 +401,7 @@

    _unsupportedOperation

    Type parameters

    @@ -431,7 +431,7 @@

    _valueEquals

    Parameters

    @@ -475,7 +475,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -493,7 +493,7 @@

    as

    Type parameters

    @@ -523,7 +523,7 @@

    bigIntValue

    Returns null | bigint

    @@ -541,7 +541,7 @@

    booleanValue

    Returns null | boolean

    @@ -559,7 +559,7 @@

    dateValue

    Returns null | Date

    @@ -577,7 +577,7 @@

    decimalValue

    Returns null | Decimal

    @@ -595,7 +595,7 @@

    deleteField

    Parameters

    @@ -619,7 +619,7 @@

    elements

    Returns Value[]

    @@ -637,7 +637,7 @@

    equals

    @@ -674,7 +674,7 @@

    fieldNames

    Returns string[]

    @@ -692,7 +692,7 @@

    fields

    Returns [string, Value][]

    @@ -710,7 +710,7 @@

    get

    Parameters

    @@ -734,7 +734,7 @@

    getAll

    Parameters

    @@ -758,7 +758,7 @@

    getAnnotations

    Returns string[]

    @@ -776,7 +776,7 @@

    getType

    Returns IonType

    @@ -794,7 +794,7 @@

    ionEquals

    @@ -837,7 +837,7 @@

    isNull

    Returns boolean

    @@ -855,7 +855,7 @@

    numberValue

    Returns number

    @@ -873,7 +873,7 @@

    stringValue

    Returns null | string

    @@ -891,7 +891,7 @@

    timestampValue

    Returns null | Timestamp

    @@ -1105,7 +1105,7 @@

    uInt8ArrayValue

    Returns null | Uint8Array

    @@ -1161,7 +1161,7 @@

    writeTo

    Parameters

    @@ -1185,7 +1185,7 @@

    Static _fromJsValue

    Parameters

    @@ -1212,7 +1212,7 @@

    Static _getIonType

    Inherited from Value(Number, IonTypes.FLOAT, _fromJsConstructor)._getIonType

    Returns IonType

    diff --git a/api/classes/dom_fromjsconstructor.fromjsconstructor-1.html b/api/classes/dom_fromjsconstructor.fromjsconstructor-1.html index 38622ea0..f967e054 100644 --- a/api/classes/dom_fromjsconstructor.fromjsconstructor-1.html +++ b/api/classes/dom_fromjsconstructor.fromjsconstructor-1.html @@ -127,7 +127,7 @@

    constructor

  • @@ -174,7 +174,7 @@

    construct

  • diff --git a/api/classes/dom_integer.integer.html b/api/classes/dom_integer.integer.html index 8c274518..725ba1b6 100644 --- a/api/classes/dom_integer.integer.html +++ b/api/classes/dom_integer.integer.html @@ -174,7 +174,7 @@

    constructor

    @@ -211,7 +211,7 @@

    _ionAnnotations

    @@ -222,7 +222,7 @@

    _ionType

    @@ -377,7 +377,7 @@

    _setAnnotations

    Parameters

    @@ -401,7 +401,7 @@

    _unsupportedOperation

    Type parameters

    @@ -431,7 +431,7 @@

    _valueEquals

    Parameters

    @@ -472,7 +472,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -490,7 +490,7 @@

    as

    Type parameters

    @@ -520,7 +520,7 @@

    bigIntValue

    Returns bigint

    @@ -538,7 +538,7 @@

    booleanValue

    Returns null | boolean

    @@ -556,7 +556,7 @@

    dateValue

    Returns null | Date

    @@ -574,7 +574,7 @@

    decimalValue

    Returns null | Decimal

    @@ -592,7 +592,7 @@

    deleteField

    Parameters

    @@ -616,7 +616,7 @@

    elements

    Returns Value[]

    @@ -634,7 +634,7 @@

    equals

    @@ -671,7 +671,7 @@

    fieldNames

    Returns string[]

    @@ -689,7 +689,7 @@

    fields

    Returns [string, Value][]

    @@ -707,7 +707,7 @@

    get

    Parameters

    @@ -731,7 +731,7 @@

    getAll

    Parameters

    @@ -755,7 +755,7 @@

    getAnnotations

    Returns string[]

    @@ -773,7 +773,7 @@

    getType

    Returns IonType

    @@ -791,7 +791,7 @@

    ionEquals

    @@ -834,7 +834,7 @@

    isNull

    Returns boolean

    @@ -852,7 +852,7 @@

    numberValue

    Returns number

    @@ -870,7 +870,7 @@

    stringValue

    Returns null | string

    @@ -888,7 +888,7 @@

    timestampValue

    Returns null | Timestamp

    @@ -1055,7 +1055,7 @@

    toString

    Returns string

    @@ -1073,7 +1073,7 @@

    uInt8ArrayValue

    Returns null | Uint8Array

    @@ -1091,7 +1091,7 @@

    valueOf

    Returns number

    @@ -1109,7 +1109,7 @@

    writeTo

    Parameters

    @@ -1133,7 +1133,7 @@

    Static _fromJsValue

    Parameters

    @@ -1160,7 +1160,7 @@

    Static _getIonType

    Inherited from Value(Number, IonTypes.INT, _fromJsConstructor)._getIonType

    Returns IonType

    diff --git a/api/classes/dom_list.list.html b/api/classes/dom_list.list.html index b39c2388..93997515 100644 --- a/api/classes/dom_list.list.html +++ b/api/classes/dom_list.list.html @@ -192,7 +192,7 @@

    constructor

    @@ -229,7 +229,7 @@

    _ionAnnotations

    @@ -240,7 +240,7 @@

    _ionType

    @@ -355,7 +355,7 @@

    _setAnnotations

    Parameters

    @@ -379,7 +379,7 @@

    _unsupportedOperation

    Type parameters

    @@ -409,7 +409,7 @@

    _valueEquals

    Parameters

    @@ -450,7 +450,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -468,7 +468,7 @@

    as

    Type parameters

    @@ -498,7 +498,7 @@

    bigIntValue

    Returns null | bigint

    @@ -516,7 +516,7 @@

    booleanValue

    Returns null | boolean

    @@ -637,7 +637,7 @@

    dateValue

    Returns null | Date

    @@ -655,7 +655,7 @@

    decimalValue

    Returns null | Decimal

    @@ -673,7 +673,7 @@

    deleteField

    Parameters

    @@ -697,7 +697,7 @@

    elements

    Returns Value[]

    @@ -738,7 +738,7 @@

    equals

    @@ -840,7 +840,7 @@

    fieldNames

    Returns string[]

    @@ -858,7 +858,7 @@

    fields

    Returns [string, Value][]

    @@ -1404,7 +1404,7 @@

    get

    Parameters

    @@ -1428,7 +1428,7 @@

    getAll

    Parameters

    @@ -1452,7 +1452,7 @@

    getAnnotations

    Returns string[]

    @@ -1470,7 +1470,7 @@

    getType

    Returns IonType

    @@ -1564,7 +1564,7 @@

    ionEquals

    @@ -1607,7 +1607,7 @@

    isNull

    Returns boolean

    @@ -1786,7 +1786,7 @@

    numberValue

    Returns null | number

    @@ -2475,7 +2475,7 @@

    stringValue

    Returns null | string

    @@ -2493,7 +2493,7 @@

    timestampValue

    Returns null | Timestamp

    @@ -2534,7 +2534,7 @@

    toString

    Returns string

    @@ -2552,7 +2552,7 @@

    uInt8ArrayValue

    Returns null | Uint8Array

    @@ -2625,7 +2625,7 @@

    writeTo

    Parameters

    @@ -2649,7 +2649,7 @@

    Static _fromJsValue

    Parameters

    @@ -2676,7 +2676,7 @@

    Static _getIonType

    Inherited from Sequence(IonTypes.LIST)._getIonType

    Returns IonType

    diff --git a/api/classes/dom_null.null.html b/api/classes/dom_null.null.html index 703bc9d0..a4b3d71f 100644 --- a/api/classes/dom_null.null.html +++ b/api/classes/dom_null.null.html @@ -200,7 +200,7 @@

    constructor

    @@ -237,7 +237,7 @@

    _ionAnnotations

    @@ -248,7 +248,7 @@

    _ionType

    @@ -275,7 +275,7 @@

    should

    @@ -293,7 +293,7 @@

    _setAnnotations

    Parameters

    @@ -317,7 +317,7 @@

    _unsupportedOperation

    Type parameters

    @@ -347,7 +347,7 @@

    _valueEquals

    Parameters

    @@ -388,7 +388,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -406,7 +406,7 @@

    as

    Type parameters

    @@ -436,7 +436,7 @@

    bigIntValue

    Returns null | bigint

    @@ -454,7 +454,7 @@

    booleanValue

    Returns null | boolean

    @@ -472,7 +472,7 @@

    dateValue

    Returns null | Date

    @@ -490,7 +490,7 @@

    decimalValue

    Returns null | Decimal

    @@ -508,7 +508,7 @@

    deleteField

    Parameters

    @@ -532,7 +532,7 @@

    elements

    Returns Value[]

    @@ -550,7 +550,7 @@

    equals

    @@ -587,7 +587,7 @@

    fieldNames

    Returns string[]

    @@ -605,7 +605,7 @@

    fields

    Returns [string, Value][]

    @@ -623,7 +623,7 @@

    get

    Parameters

    @@ -647,7 +647,7 @@

    getAll

    Parameters

    @@ -671,7 +671,7 @@

    getAnnotations

    Returns string[]

    @@ -689,7 +689,7 @@

    getType

    Returns IonType

    @@ -739,7 +739,7 @@

    ionEquals

    @@ -782,7 +782,7 @@

    isNull

    Returns boolean

    @@ -832,7 +832,7 @@

    numberValue

    Returns null | number

    @@ -882,7 +882,7 @@

    stringValue

    Returns null | string

    @@ -900,7 +900,7 @@

    timestampValue

    Returns null | Timestamp

    @@ -917,7 +917,7 @@

    toJSON

  • @@ -963,7 +963,7 @@

    toString

    Returns string

    @@ -981,7 +981,7 @@

    uInt8ArrayValue

    Returns null | Uint8Array

    @@ -1022,7 +1022,7 @@

    writeTo

    Parameters

    @@ -1046,7 +1046,7 @@

    Static _fromJsValue

    Parameters

    @@ -1073,7 +1073,7 @@

    Static _getIonType

    Inherited from Value(Object, IonTypes.NULL, FromJsConstructor.NONE)._getIonType

    Returns IonType

    diff --git a/api/classes/dom_sexpression.sexpression.html b/api/classes/dom_sexpression.sexpression.html index a537f5f4..b18e716b 100644 --- a/api/classes/dom_sexpression.sexpression.html +++ b/api/classes/dom_sexpression.sexpression.html @@ -192,7 +192,7 @@

    constructor

    @@ -229,7 +229,7 @@

    _ionAnnotations

    @@ -240,7 +240,7 @@

    _ionType

    @@ -355,7 +355,7 @@

    _setAnnotations

    Parameters

    @@ -379,7 +379,7 @@

    _unsupportedOperation

    Type parameters

    @@ -409,7 +409,7 @@

    _valueEquals

    Parameters

    @@ -450,7 +450,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -468,7 +468,7 @@

    as

    Type parameters

    @@ -498,7 +498,7 @@

    bigIntValue

    Returns null | bigint

    @@ -516,7 +516,7 @@

    booleanValue

    Returns null | boolean

    @@ -637,7 +637,7 @@

    dateValue

    Returns null | Date

    @@ -655,7 +655,7 @@

    decimalValue

    Returns null | Decimal

    @@ -673,7 +673,7 @@

    deleteField

    Parameters

    @@ -697,7 +697,7 @@

    elements

    Returns Value[]

    @@ -738,7 +738,7 @@

    equals

    @@ -840,7 +840,7 @@

    fieldNames

    Returns string[]

    @@ -858,7 +858,7 @@

    fields

    Returns [string, Value][]

    @@ -1404,7 +1404,7 @@

    get

    Parameters

    @@ -1428,7 +1428,7 @@

    getAll

    Parameters

    @@ -1452,7 +1452,7 @@

    getAnnotations

    Returns string[]

    @@ -1470,7 +1470,7 @@

    getType

    Returns IonType

    @@ -1564,7 +1564,7 @@

    ionEquals

    @@ -1607,7 +1607,7 @@

    isNull

    Returns boolean

    @@ -1786,7 +1786,7 @@

    numberValue

    Returns null | number

    @@ -2475,7 +2475,7 @@

    stringValue

    Returns null | string

    @@ -2493,7 +2493,7 @@

    timestampValue

    Returns null | Timestamp

    @@ -2534,7 +2534,7 @@

    toString

    Returns string

    @@ -2552,7 +2552,7 @@

    uInt8ArrayValue

    Returns null | Uint8Array

    @@ -2625,7 +2625,7 @@

    writeTo

    Parameters

    @@ -2649,7 +2649,7 @@

    Static _fromJsValue

    Parameters

    @@ -2676,7 +2676,7 @@

    Static _getIonType

    Inherited from Sequence(IonTypes.SEXP)._getIonType

    Returns IonType

    diff --git a/api/classes/dom_string.string.html b/api/classes/dom_string.string.html index 36e81fe8..6412abad 100644 --- a/api/classes/dom_string.string.html +++ b/api/classes/dom_string.string.html @@ -207,7 +207,7 @@

    constructor

    @@ -244,7 +244,7 @@

    _ionAnnotations

    @@ -255,7 +255,7 @@

    _ionType

    @@ -312,7 +312,7 @@

    _setAnnotations

    Parameters

    @@ -336,7 +336,7 @@

    _unsupportedOperation

    Type parameters

    @@ -366,7 +366,7 @@

    _valueEquals

    Parameters

    @@ -407,7 +407,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -456,7 +456,7 @@

    as

    Type parameters

    @@ -509,7 +509,7 @@

    bigIntValue

    Returns null | bigint

    @@ -573,7 +573,7 @@

    booleanValue

    Returns null | boolean

    @@ -687,7 +687,7 @@

    compareValue

  • Parameters

    @@ -743,7 +743,7 @@

    dateValue

    Returns null | Date

    @@ -761,7 +761,7 @@

    decimalValue

    Returns null | Decimal

    @@ -779,7 +779,7 @@

    deleteField

    Parameters

    @@ -803,7 +803,7 @@

    elements

    Returns Value[]

    @@ -855,7 +855,7 @@

    equals

    @@ -892,7 +892,7 @@

    fieldNames

    Returns string[]

    @@ -910,7 +910,7 @@

    fields

    Returns [string, Value][]

    @@ -1030,7 +1030,7 @@

    get

    Parameters

    @@ -1054,7 +1054,7 @@

    getAll

    Parameters

    @@ -1078,7 +1078,7 @@

    getAnnotations

    Returns string[]

    @@ -1096,7 +1096,7 @@

    getType

    Returns IonType

    @@ -1192,7 +1192,7 @@

    ionEquals

    @@ -1235,7 +1235,7 @@

    isNull

    Returns boolean

    @@ -1585,7 +1585,7 @@

    numberValue

    Returns null | number

    @@ -2348,7 +2348,7 @@

    stringValue

    Returns string

    @@ -2489,7 +2489,7 @@

    timestampValue

    Returns null | Timestamp

    @@ -2809,7 +2809,7 @@

    uInt8ArrayValue

    Returns null | Uint8Array

    @@ -2865,7 +2865,7 @@

    writeTo

    Parameters

    @@ -2889,7 +2889,7 @@

    Static _fromJsValue

    Parameters

    @@ -2916,7 +2916,7 @@

    Static _getIonType

    Inherited from Value(_NativeJsString,IonTypes.STRING,_fromJsConstructor)._getIonType

    Returns IonType

    diff --git a/api/classes/dom_struct.struct.html b/api/classes/dom_struct.struct.html index 757eb613..3c1af444 100644 --- a/api/classes/dom_struct.struct.html +++ b/api/classes/dom_struct.struct.html @@ -200,7 +200,7 @@

    constructor

    @@ -237,7 +237,7 @@

    _ionAnnotations

    @@ -248,7 +248,7 @@

    _ionType

    @@ -275,7 +275,7 @@

    should

    @@ -292,7 +292,7 @@

    [Symbol.iterator]

  • Returns IterableIterator<[string, Value]>

    @@ -309,7 +309,7 @@

    _ionValueEquals

  • Parameters

    @@ -339,7 +339,7 @@

    _setAnnotations

    Parameters

    @@ -363,7 +363,7 @@

    _unsupportedOperation

    Type parameters

    @@ -393,7 +393,7 @@

    _valueEquals

    Parameters

    @@ -434,7 +434,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -452,7 +452,7 @@

    as

    Type parameters

    @@ -482,7 +482,7 @@

    bigIntValue

    Returns null | bigint

    @@ -500,7 +500,7 @@

    booleanValue

    Returns null | boolean

    @@ -518,7 +518,7 @@

    dateValue

    Returns null | Date

    @@ -536,7 +536,7 @@

    decimalValue

    Returns null | Decimal

    @@ -554,7 +554,7 @@

    deleteField

    Parameters

    @@ -578,7 +578,7 @@

    elements

    Returns Value[]

    @@ -596,7 +596,7 @@

    equals

    @@ -633,7 +633,7 @@

    fieldNames

    Returns string[]

    @@ -651,7 +651,7 @@

    fields

    Returns [string, Value][]

    @@ -669,7 +669,7 @@

    get

    Parameters

    @@ -693,7 +693,7 @@

    getAll

    Parameters

    @@ -717,7 +717,7 @@

    getAnnotations

    Returns string[]

    @@ -735,7 +735,7 @@

    getType

    Returns IonType

    @@ -785,7 +785,7 @@

    ionEquals

    @@ -828,7 +828,7 @@

    isNull

    Returns boolean

    @@ -878,7 +878,7 @@

    numberValue

    Returns null | number

    @@ -928,7 +928,7 @@

    stringValue

    Returns null | string

    @@ -946,7 +946,7 @@

    timestampValue

    Returns null | Timestamp

    @@ -963,7 +963,7 @@

    toJSON

  • Returns any

    @@ -1004,7 +1004,7 @@

    toString

    Returns string

    @@ -1022,7 +1022,7 @@

    uInt8ArrayValue

    Returns null | Uint8Array

    @@ -1063,7 +1063,7 @@

    writeTo

    Parameters

    @@ -1087,7 +1087,7 @@

    Static _fromJsValue

    Parameters

    @@ -1114,7 +1114,7 @@

    Static _getIonType

    Inherited from Value(Object,IonTypes.STRUCT,FromJsConstructor.NONE)._getIonType

    Returns IonType

    diff --git a/api/classes/dom_symbol.symbol.html b/api/classes/dom_symbol.symbol.html index be178f67..a5a6d002 100644 --- a/api/classes/dom_symbol.symbol.html +++ b/api/classes/dom_symbol.symbol.html @@ -207,7 +207,7 @@

    constructor

    @@ -244,7 +244,7 @@

    _ionAnnotations

    @@ -255,7 +255,7 @@

    _ionType

    @@ -312,7 +312,7 @@

    _setAnnotations

    Parameters

    @@ -336,7 +336,7 @@

    _unsupportedOperation

    Type parameters

    @@ -366,7 +366,7 @@

    _valueEquals

    Parameters

    @@ -407,7 +407,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -456,7 +456,7 @@

    as

    Type parameters

    @@ -509,7 +509,7 @@

    bigIntValue

    Returns null | bigint

    @@ -573,7 +573,7 @@

    booleanValue

    Returns null | boolean

    @@ -687,7 +687,7 @@

    compareValue

  • Parameters

    @@ -743,7 +743,7 @@

    dateValue

    Returns null | Date

    @@ -761,7 +761,7 @@

    decimalValue

    Returns null | Decimal

    @@ -779,7 +779,7 @@

    deleteField

    Parameters

    @@ -803,7 +803,7 @@

    elements

    Returns Value[]

    @@ -855,7 +855,7 @@

    equals

    @@ -892,7 +892,7 @@

    fieldNames

    Returns string[]

    @@ -910,7 +910,7 @@

    fields

    Returns [string, Value][]

    @@ -1030,7 +1030,7 @@

    get

    Parameters

    @@ -1054,7 +1054,7 @@

    getAll

    Parameters

    @@ -1078,7 +1078,7 @@

    getAnnotations

    Returns string[]

    @@ -1096,7 +1096,7 @@

    getType

    Returns IonType

    @@ -1192,7 +1192,7 @@

    ionEquals

    @@ -1235,7 +1235,7 @@

    isNull

    Returns boolean

    @@ -1585,7 +1585,7 @@

    numberValue

    Returns null | number

    @@ -2348,7 +2348,7 @@

    stringValue

    Returns string

    @@ -2489,7 +2489,7 @@

    timestampValue

    Returns null | Timestamp

    @@ -2809,7 +2809,7 @@

    uInt8ArrayValue

    Returns null | Uint8Array

    @@ -2865,7 +2865,7 @@

    writeTo

    Parameters

    @@ -2889,7 +2889,7 @@

    Static _fromJsValue

    Parameters

    @@ -2916,7 +2916,7 @@

    Static _getIonType

    Inherited from Value(String, IonTypes.SYMBOL, _fromJsConstructor)._getIonType

    Returns IonType

    diff --git a/api/classes/dom_timestamp.timestamp.html b/api/classes/dom_timestamp.timestamp.html index 3b6d9fc2..df52e79b 100644 --- a/api/classes/dom_timestamp.timestamp.html +++ b/api/classes/dom_timestamp.timestamp.html @@ -201,7 +201,7 @@

    constructor

    @@ -238,7 +238,7 @@

    _ionAnnotations

    @@ -249,7 +249,7 @@

    _ionType

    @@ -368,7 +368,7 @@

    _setAnnotations

    Parameters

    @@ -392,7 +392,7 @@

    _unsupportedOperation

    Type parameters

    @@ -422,7 +422,7 @@

    _valueEquals

    Parameters

    @@ -463,7 +463,7 @@

    allFields

    Returns [string, Value[]][]

    @@ -481,7 +481,7 @@

    as

    Type parameters

    @@ -511,7 +511,7 @@

    bigIntValue

    Returns null | bigint

    @@ -529,7 +529,7 @@

    booleanValue

    Returns null | boolean

    @@ -547,7 +547,7 @@

    dateValue

    Returns Date

    @@ -565,7 +565,7 @@

    decimalValue

    Returns null | Decimal

    @@ -583,7 +583,7 @@

    deleteField

    Parameters

    @@ -607,7 +607,7 @@

    elements

    Returns Value[]

    @@ -625,7 +625,7 @@

    equals

    @@ -662,7 +662,7 @@

    fieldNames

    Returns string[]

    @@ -680,7 +680,7 @@

    fields

    Returns [string, Value][]

    @@ -698,7 +698,7 @@

    get

    Parameters

    @@ -722,7 +722,7 @@

    getAll

    Parameters

    @@ -746,7 +746,7 @@

    getAnnotations

    Returns string[]

    @@ -994,7 +994,7 @@

    getType

    Returns IonType

    @@ -1196,7 +1196,7 @@

    ionEquals

    @@ -1239,7 +1239,7 @@

    isNull

    Returns boolean

    @@ -1257,7 +1257,7 @@

    numberValue

    Returns null | number

    @@ -1863,7 +1863,7 @@

    stringValue

    Returns null | string

    @@ -1881,7 +1881,7 @@

    timestampValue

    Returns Timestamp

    @@ -2196,7 +2196,7 @@

    uInt8ArrayValue

    Returns null | Uint8Array

    @@ -2252,7 +2252,7 @@

    writeTo

    Parameters

    @@ -2344,7 +2344,7 @@

    Static _fromJsValue

    Parameters

    @@ -2371,7 +2371,7 @@

    Static _getIonType

    Inherited from Value(Date,IonTypes.TIMESTAMP,_fromJsConstructor)._getIonType

    Returns IonType

    diff --git a/api/classes/events_eventstreamerror.eventstreamerror.html b/api/classes/events_eventstreamerror.eventstreamerror.html index 89a2d811..11825dcb 100644 --- a/api/classes/events_eventstreamerror.eventstreamerror.html +++ b/api/classes/events_eventstreamerror.eventstreamerror.html @@ -126,7 +126,7 @@

    constructor

    Parameters

    @@ -157,7 +157,7 @@

    eventstream

    eventstream: IonEvent[]
    @@ -167,7 +167,7 @@

    index

    index: number
    @@ -210,7 +210,7 @@

    type

    type: string
    diff --git a/api/classes/events_ionevent.ioneventfactory.html b/api/classes/events_ionevent.ioneventfactory.html index b2003480..cb9fd46c 100644 --- a/api/classes/events_ionevent.ioneventfactory.html +++ b/api/classes/events_ionevent.ioneventfactory.html @@ -124,7 +124,7 @@

    makeEvent

  • Parameters

    diff --git a/api/classes/events_ioneventstream.ioneventstream.html b/api/classes/events_ioneventstream.ioneventstream.html index f9860361..27b2b1c5 100644 --- a/api/classes/events_ioneventstream.ioneventstream.html +++ b/api/classes/events_ioneventstream.ioneventstream.html @@ -119,7 +119,7 @@

    constructor

  • Parameters

    @@ -141,7 +141,7 @@

    events

    events: IonEvent[]
    @@ -151,7 +151,7 @@

    isEventStream

    isEventStream: boolean
    @@ -168,7 +168,7 @@

    compare

  • @@ -196,7 +196,7 @@

    equals

  • Parameters

    @@ -219,7 +219,7 @@

    getEvents

  • Returns IonEvent[]

    @@ -236,7 +236,7 @@

    isEmbedded

  • Parameters

    @@ -259,7 +259,7 @@

    writeEventStream

  • Parameters

    @@ -282,7 +282,7 @@

    writeIon

  • Parameters

    diff --git a/api/classes/ionbinaryreader.binaryreader.html b/api/classes/ionbinaryreader.binaryreader.html index e265090c..8f7df53f 100644 --- a/api/classes/ionbinaryreader.binaryreader.html +++ b/api/classes/ionbinaryreader.binaryreader.html @@ -132,7 +132,7 @@

    constructor

  • Parameters

    @@ -162,7 +162,7 @@

    annotations

    @@ -185,7 +185,7 @@

    bigIntValue

    @@ -208,7 +208,7 @@

    booleanValue

    @@ -231,7 +231,7 @@

    decimalValue

    @@ -254,7 +254,7 @@

    depth

    @@ -277,7 +277,7 @@

    fieldName

    @@ -299,7 +299,7 @@

    getAnnotation

  • Parameters

    @@ -322,7 +322,7 @@

    hasAnnotations

  • Returns boolean

    @@ -340,7 +340,7 @@

    intSize

    @@ -364,7 +364,7 @@

    isNull

    @@ -387,7 +387,7 @@

    next

    @@ -410,7 +410,7 @@

    numberValue

    @@ -434,7 +434,7 @@

    position

    @@ -469,7 +469,7 @@

    stepIn

    @@ -493,7 +493,7 @@

    stepOut

    @@ -519,7 +519,7 @@

    stringValue

    @@ -543,7 +543,7 @@

    timestampValue

    @@ -566,7 +566,7 @@

    type

    @@ -589,7 +589,7 @@

    uInt8ArrayValue

    @@ -613,7 +613,7 @@

    value

    diff --git a/api/classes/ionbinarywriter.abstractnode.html b/api/classes/ionbinarywriter.abstractnode.html index e0e1e4cd..e8c5bc3d 100644 --- a/api/classes/ionbinarywriter.abstractnode.html +++ b/api/classes/ionbinarywriter.abstractnode.html @@ -129,7 +129,7 @@

    typeCode

  • Returns number

    @@ -146,7 +146,7 @@

    writer

  • Returns LowLevelBinaryWriter

    @@ -167,7 +167,7 @@

    Abstract addChild

    Parameters

    @@ -193,7 +193,7 @@

    getAnnotatedContainerLength

  • Returns number

    @@ -210,7 +210,7 @@

    getAnnotationsLength

  • Returns number

    @@ -227,7 +227,7 @@

    getContainedValueLength

  • Returns number

    @@ -245,7 +245,7 @@

    getLength

    Returns number

    @@ -262,7 +262,7 @@

    Abstract getValueLen
  • Returns number

    @@ -280,7 +280,7 @@

    Abstract isContainer

    Returns boolean

    @@ -298,7 +298,7 @@

    Abstract write

    Returns void

    @@ -315,7 +315,7 @@

    writeAnnotations

  • Returns void

    @@ -332,7 +332,7 @@

    writeTypeDescriptorAndLength

  • Parameters

    @@ -361,7 +361,7 @@

    Static getLengthLength
  • Parameters

    diff --git a/api/classes/ionbinarywriter.binarywriter.html b/api/classes/ionbinarywriter.binarywriter.html index c6e8d3db..33a7bcbc 100644 --- a/api/classes/ionbinarywriter.binarywriter.html +++ b/api/classes/ionbinarywriter.binarywriter.html @@ -147,7 +147,7 @@

    constructor

    Parameters

    @@ -177,7 +177,7 @@

    addAnnotation

    Parameters

    @@ -201,7 +201,7 @@

    close

    Returns void

    @@ -219,7 +219,7 @@

    depth

    Returns number

    @@ -237,7 +237,7 @@

    getBytes

    Returns Uint8Array

    @@ -255,7 +255,7 @@

    setAnnotations

    Parameters

    @@ -279,7 +279,7 @@

    stepIn

    Parameters

    @@ -303,7 +303,7 @@

    stepOut

    Returns void

    @@ -321,7 +321,7 @@

    writeBlob

    Parameters

    @@ -345,7 +345,7 @@

    writeBoolean

    Parameters

    @@ -369,7 +369,7 @@

    writeClob

    Parameters

    @@ -393,7 +393,7 @@

    writeDecimal

    Parameters

    @@ -417,7 +417,7 @@

    writeFieldName

    Parameters

    @@ -441,7 +441,7 @@

    writeFloat32

    Parameters

    @@ -465,7 +465,7 @@

    writeFloat64

    Parameters

    @@ -489,7 +489,7 @@

    writeInt

    Parameters

    @@ -513,7 +513,7 @@

    writeNull

    Parameters

    @@ -537,7 +537,7 @@

    writeString

    Parameters

    @@ -561,7 +561,7 @@

    writeSymbol

    Parameters

    @@ -585,7 +585,7 @@

    writeTimestamp

    Parameters

    @@ -609,7 +609,7 @@

    writeValue

    Parameters

    @@ -633,7 +633,7 @@

    writeValues

    Parameters

    diff --git a/api/classes/ionbinarywriter.leafnode.html b/api/classes/ionbinarywriter.leafnode.html index 08ba3aa7..331e73bf 100644 --- a/api/classes/ionbinarywriter.leafnode.html +++ b/api/classes/ionbinarywriter.leafnode.html @@ -128,7 +128,7 @@

    typeCode

  • Returns number

    @@ -145,7 +145,7 @@

    writer

  • Returns LowLevelBinaryWriter

    @@ -166,7 +166,7 @@

    addChild

    Parameters

    @@ -193,7 +193,7 @@

    getAnnotatedContainerLength

    Returns number

    @@ -211,7 +211,7 @@

    getAnnotationsLength

    Returns number

    @@ -229,7 +229,7 @@

    getContainedValueLength

    Returns number

    @@ -247,7 +247,7 @@

    getLength

    Returns number

    @@ -265,7 +265,7 @@

    Abstract getValueLen

    Returns number

    @@ -283,7 +283,7 @@

    isContainer

    Returns boolean

    @@ -301,7 +301,7 @@

    Abstract write

    Returns void

    @@ -319,7 +319,7 @@

    writeAnnotations

    Returns void

    @@ -337,7 +337,7 @@

    writeTypeDescriptorAndLength

    Parameters

    @@ -367,7 +367,7 @@

    Static getLengthLength

    Parameters

    diff --git a/api/classes/ionbinarywriter.nullnode.html b/api/classes/ionbinarywriter.nullnode.html index e0c1a2e6..15ae09da 100644 --- a/api/classes/ionbinarywriter.nullnode.html +++ b/api/classes/ionbinarywriter.nullnode.html @@ -130,7 +130,7 @@

    constructor

    Parameters

    @@ -165,7 +165,7 @@

    typeCode

  • Returns number

    @@ -182,7 +182,7 @@

    writer

  • Returns LowLevelBinaryWriter

    @@ -203,7 +203,7 @@

    addChild

    Parameters

    @@ -230,7 +230,7 @@

    getAnnotatedContainerLength

    Returns number

    @@ -248,7 +248,7 @@

    getAnnotationsLength

    Returns number

    @@ -266,7 +266,7 @@

    getContainedValueLength

    Returns number

    @@ -284,7 +284,7 @@

    getLength

    Returns number

    @@ -302,7 +302,7 @@

    getValueLength

    Returns number

    @@ -320,7 +320,7 @@

    isContainer

    Returns boolean

    @@ -338,7 +338,7 @@

    write

    Returns void

    @@ -356,7 +356,7 @@

    writeAnnotations

    Returns void

    @@ -374,7 +374,7 @@

    writeTypeDescriptorAndLength

    Parameters

    @@ -404,7 +404,7 @@

    Static getLengthLength

    Parameters

    diff --git a/api/classes/ioncatalog.catalog.html b/api/classes/ioncatalog.catalog.html index e29f7c7e..d32f957a 100644 --- a/api/classes/ioncatalog.catalog.html +++ b/api/classes/ioncatalog.catalog.html @@ -121,7 +121,7 @@

    constructor

  • @@ -146,7 +146,7 @@

    add

  • @@ -174,7 +174,7 @@

    getTable

  • @@ -203,7 +203,7 @@

    getVersion

  • diff --git a/api/classes/iondecimal.decimal.html b/api/classes/iondecimal.decimal.html index e8310575..a1dfdefc 100644 --- a/api/classes/iondecimal.decimal.html +++ b/api/classes/iondecimal.decimal.html @@ -147,7 +147,7 @@

    constructor

  • @@ -169,7 +169,7 @@

    Returns
    @@ -197,7 +197,7 @@

    Returns
    @@ -243,7 +243,7 @@

    Static ONE: Decimal = ...

    @@ -253,7 +253,7 @@

    Static ZERO: Decimal = ...

    @@ -270,7 +270,7 @@

    compareTo

  • @@ -304,7 +304,7 @@

    equals

  • @@ -335,7 +335,7 @@

    getCoefficient

  • @@ -359,7 +359,7 @@

    getExponent

  • @@ -381,7 +381,7 @@

    intValue

  • @@ -404,7 +404,7 @@

    isNegative

  • @@ -426,7 +426,7 @@

    numberValue

  • @@ -450,7 +450,7 @@

    toJSON

  • @@ -472,7 +472,7 @@

    toString

  • @@ -495,7 +495,7 @@

    Static parse

  • diff --git a/api/classes/ionimport.import.html b/api/classes/ionimport.import.html index 93f09d57..57811f0f 100644 --- a/api/classes/ionimport.import.html +++ b/api/classes/ionimport.import.html @@ -134,7 +134,7 @@

    constructor

  • Parameters

    @@ -166,7 +166,7 @@

    length

  • Returns number

    @@ -183,7 +183,7 @@

    offset

  • Returns number

    @@ -200,7 +200,7 @@

    parent

  • Returns null | Import

    @@ -217,7 +217,7 @@

    symbolTable

  • Returns SharedSymbolTable

    @@ -237,7 +237,7 @@

    getSymbolId

  • Parameters

    @@ -260,7 +260,7 @@

    getSymbolText

  • Parameters

    diff --git a/api/classes/ionlocalsymboltable.localsymboltable.html b/api/classes/ionlocalsymboltable.localsymboltable.html index 92dd7774..444225dc 100644 --- a/api/classes/ionlocalsymboltable.localsymboltable.html +++ b/api/classes/ionlocalsymboltable.localsymboltable.html @@ -126,7 +126,7 @@

    constructor

  • Parameters

    @@ -155,7 +155,7 @@

    import

  • Returns Import

    @@ -172,7 +172,7 @@

    maxId

  • Returns number

    @@ -189,7 +189,7 @@

    symbols

  • Returns (null | string)[]

    @@ -209,7 +209,7 @@

    addSymbol

  • Parameters

    @@ -232,7 +232,7 @@

    getSymbolId

  • Parameters

    @@ -255,7 +255,7 @@

    getSymbolText

  • Parameters

    @@ -278,7 +278,7 @@

    numberOfSymbols

  • Returns number

    diff --git a/api/classes/ionlowlevelbinarywriter.lowlevelbinarywriter.html b/api/classes/ionlowlevelbinarywriter.lowlevelbinarywriter.html index eeb247ac..24234a3d 100644 --- a/api/classes/ionlowlevelbinarywriter.lowlevelbinarywriter.html +++ b/api/classes/ionlowlevelbinarywriter.lowlevelbinarywriter.html @@ -130,7 +130,7 @@

    constructor

  • Parameters

    @@ -156,7 +156,7 @@

    getBytes

  • Returns Uint8Array

    @@ -173,7 +173,7 @@

    writeByte

  • Parameters

    @@ -196,7 +196,7 @@

    writeBytes

  • Parameters

    @@ -219,7 +219,7 @@

    writeSignedInt

  • Parameters

    @@ -242,7 +242,7 @@

    writeUnsignedInt

  • Parameters

    @@ -265,7 +265,7 @@

    writeVariableLengthSignedInt

  • Parameters

    @@ -288,7 +288,7 @@

    writeVariableLengthUnsignedInt

  • Parameters

    @@ -311,7 +311,7 @@

    Static getSignedInt

    Parameters

    @@ -334,7 +334,7 @@

    Static getUnsignedInt<
  • Parameters

    @@ -357,7 +357,7 @@

    Static getVariableLeng
  • Parameters

    @@ -380,7 +380,7 @@

    Static getVariableLeng
  • Parameters

    diff --git a/api/classes/ionparserbinaryraw.parserbinaryraw.html b/api/classes/ionparserbinaryraw.parserbinaryraw.html index 91191bbb..752de74c 100644 --- a/api/classes/ionparserbinaryraw.parserbinaryraw.html +++ b/api/classes/ionparserbinaryraw.parserbinaryraw.html @@ -131,7 +131,7 @@

    constructor

  • Parameters

    @@ -157,7 +157,7 @@

    _getSid

  • Returns null | number

    @@ -174,7 +174,7 @@

    bigIntValue

  • Returns null | bigint

    @@ -191,7 +191,7 @@

    booleanValue

  • Returns null | boolean

    @@ -208,7 +208,7 @@

    byteValue

  • Returns null | Uint8Array

    @@ -225,7 +225,7 @@

    decimalValue

  • Returns null | Decimal

    @@ -242,7 +242,7 @@

    depth

  • Returns number

    @@ -259,7 +259,7 @@

    getAnnotation

  • Parameters

    @@ -282,7 +282,7 @@

    getAnnotations

  • Returns any

    @@ -299,7 +299,7 @@

    getFieldId

  • Returns null | number

    @@ -316,7 +316,7 @@

    hasAnnotations

  • Returns boolean

    @@ -333,7 +333,7 @@

    ionType

  • Returns IonType

    @@ -350,7 +350,7 @@

    isNull

  • Returns boolean

    @@ -367,7 +367,7 @@

    next

  • Returns any

    @@ -384,7 +384,7 @@

    numberValue

  • Returns null | number

    @@ -401,7 +401,7 @@

    source

  • Returns BinarySpan

    @@ -418,7 +418,7 @@

    stepIn

  • Returns void

    @@ -435,7 +435,7 @@

    stepOut

  • Returns void

    @@ -452,7 +452,7 @@

    stringValue

  • Returns null | string

    @@ -469,7 +469,7 @@

    timestampValue

  • Returns null | Timestamp

    @@ -486,7 +486,7 @@

    uInt8ArrayValue

  • Returns null | Uint8Array

    @@ -503,7 +503,7 @@

    Static _readFloatFrom<
  • Parameters

    @@ -529,7 +529,7 @@

    Static _readSignedInt<
  • Parameters

    @@ -555,7 +555,7 @@

    Static _readUnsignedIn
  • Parameters

    @@ -581,7 +581,7 @@

    Static _readVarSigned<
  • Parameters

    @@ -604,7 +604,7 @@

    Static _readVarUnsigne
  • Parameters

    diff --git a/api/classes/ionparsertextraw.parsertextraw.html b/api/classes/ionparsertextraw.parsertextraw.html index 3bebd76d..617f10e4 100644 --- a/api/classes/ionparsertextraw.parsertextraw.html +++ b/api/classes/ionparsertextraw.parsertextraw.html @@ -118,7 +118,7 @@

    constructor

  • Parameters

    @@ -144,7 +144,7 @@

    annotations

  • Returns SymbolToken[]

    @@ -161,7 +161,7 @@

    bigIntValue

  • Returns null | bigint

    @@ -178,7 +178,7 @@

    booleanValue

  • Returns null | boolean

    @@ -195,7 +195,7 @@

    clearFieldName

  • Returns void

    @@ -212,7 +212,7 @@

    fieldName

  • Returns null | string

    @@ -229,7 +229,7 @@

    fieldNameType

  • Returns null | number

    @@ -246,7 +246,7 @@

    get_value_as_string

  • Parameters

    @@ -269,7 +269,7 @@

    get_value_as_uint8array

  • Parameters

    @@ -292,7 +292,7 @@

    isNull

  • Returns boolean

    @@ -309,7 +309,7 @@

    next

  • Returns undefined | number

    @@ -326,7 +326,7 @@

    numberValue

  • Returns null | number

    @@ -343,7 +343,7 @@

    source

  • Returns StringSpan

    diff --git a/api/classes/ionprettytextwriter.prettytextwriter.html b/api/classes/ionprettytextwriter.prettytextwriter.html index d3ea172d..382c2b4c 100644 --- a/api/classes/ionprettytextwriter.prettytextwriter.html +++ b/api/classes/ionprettytextwriter.prettytextwriter.html @@ -142,7 +142,7 @@

    constructor

    Parameters

    @@ -171,7 +171,7 @@

    isTopLevel

  • Returns boolean

    @@ -192,7 +192,7 @@

    _serializeValue

    Type parameters

    @@ -228,7 +228,7 @@

    addAnnotation

    Parameters

    @@ -252,7 +252,7 @@

    close

    Returns void

    @@ -270,7 +270,7 @@

    depth

    Returns number

    @@ -288,7 +288,7 @@

    getBytes

    Returns Uint8Array

    @@ -306,7 +306,7 @@

    handleSeparator

    Returns void

    @@ -324,7 +324,7 @@

    setAnnotations

    Parameters

    @@ -348,7 +348,7 @@

    stepIn

    Parameters

    @@ -372,7 +372,7 @@

    stepOut

    Returns void

    @@ -390,7 +390,7 @@

    writeBlob

    Parameters

    @@ -414,7 +414,7 @@

    writeBoolean

    Parameters

    @@ -438,7 +438,7 @@

    writeClob

    Parameters

    @@ -462,7 +462,7 @@

    writeContainer

    Parameters

    @@ -489,7 +489,7 @@

    writeDecimal

    Parameters

    @@ -513,7 +513,7 @@

    writeFieldName

    Parameters

    @@ -537,7 +537,7 @@

    writeFloat32

    Parameters

    @@ -561,7 +561,7 @@

    writeFloat64

    Parameters

    @@ -585,7 +585,7 @@

    writeInt

    Parameters

    @@ -609,7 +609,7 @@

    writeNull

    Parameters

    @@ -633,7 +633,7 @@

    writeString

    Parameters

    @@ -657,7 +657,7 @@

    writeSymbol

    Parameters

    @@ -681,7 +681,7 @@

    writeTimestamp

    Parameters

    @@ -705,7 +705,7 @@

    writeValue

    Parameters

    @@ -729,7 +729,7 @@

    writeValues

    Parameters

    diff --git a/api/classes/ionsharedsymboltable.sharedsymboltable.html b/api/classes/ionsharedsymboltable.sharedsymboltable.html index 1ee05131..1c0ad398 100644 --- a/api/classes/ionsharedsymboltable.sharedsymboltable.html +++ b/api/classes/ionsharedsymboltable.sharedsymboltable.html @@ -133,7 +133,7 @@

    constructor

  • Parameters

    @@ -165,7 +165,7 @@

    name

  • Returns string

    @@ -182,7 +182,7 @@

    numberOfSymbols

  • Returns number

    @@ -199,7 +199,7 @@

    version

  • Returns number

    @@ -219,7 +219,7 @@

    getSymbolId

  • Parameters

    @@ -242,7 +242,7 @@

    getSymbolText

  • Parameters

    diff --git a/api/classes/ionspan.binaryspan.html b/api/classes/ionspan.binaryspan.html index 69c18907..a827400f 100644 --- a/api/classes/ionspan.binaryspan.html +++ b/api/classes/ionspan.binaryspan.html @@ -126,7 +126,7 @@

    constructor

    Parameters

    @@ -153,7 +153,7 @@

    chunk

    Parameters

    @@ -177,7 +177,7 @@

    clone

    Parameters

    @@ -204,7 +204,7 @@

    getRemaining

    Returns number

    @@ -222,7 +222,7 @@

    is_empty

    Returns boolean

    @@ -240,7 +240,7 @@

    next

    Returns number

    @@ -258,7 +258,7 @@

    peek

    Returns number

    @@ -276,7 +276,7 @@

    position

    Returns number

    @@ -294,7 +294,7 @@

    setRemaining

    Parameters

    @@ -318,7 +318,7 @@

    skip

    Parameters

    @@ -342,7 +342,7 @@

    unread

    Parameters

    @@ -366,7 +366,7 @@

    valueAt

    Parameters

    @@ -389,7 +389,7 @@

    view

  • Parameters

    @@ -413,7 +413,7 @@

    write

    Parameters

    @@ -437,7 +437,7 @@

    Static error

    Returns void

    diff --git a/api/classes/ionspan.span.html b/api/classes/ionspan.span.html index 5e1a4d58..1e704467 100644 --- a/api/classes/ionspan.span.html +++ b/api/classes/ionspan.span.html @@ -126,7 +126,7 @@

    constructor

  • Parameters

    @@ -152,7 +152,7 @@

    Abstract chunk

  • Parameters

    @@ -175,7 +175,7 @@

    Abstract getRemaining

    Returns number

    @@ -192,7 +192,7 @@

    Abstract is_empty

  • Returns boolean

    @@ -209,7 +209,7 @@

    Abstract next

  • Returns number

    @@ -226,7 +226,7 @@

    Abstract peek

  • Returns number

    @@ -243,7 +243,7 @@

    Abstract position

  • Returns number

    @@ -260,7 +260,7 @@

    Abstract setRemaining

    Parameters

    @@ -283,7 +283,7 @@

    Abstract skip

  • Parameters

    @@ -306,7 +306,7 @@

    Abstract unread

  • Parameters

    @@ -329,7 +329,7 @@

    Abstract valueAt

  • Parameters

    @@ -352,7 +352,7 @@

    write

  • Parameters

    @@ -375,7 +375,7 @@

    Static error

  • Returns void

    diff --git a/api/classes/ionspan.stringspan.html b/api/classes/ionspan.stringspan.html index b8d412fc..82d69838 100644 --- a/api/classes/ionspan.stringspan.html +++ b/api/classes/ionspan.stringspan.html @@ -130,7 +130,7 @@

    constructor

    Parameters

    @@ -156,7 +156,7 @@

    _inc_line

  • Returns void

    @@ -174,7 +174,7 @@

    chunk

    Parameters

    @@ -198,7 +198,7 @@

    clone

    Parameters

    @@ -221,7 +221,7 @@

    getCodePoint

  • Parameters

    @@ -245,7 +245,7 @@

    getRemaining

    Returns number

    @@ -263,7 +263,7 @@

    is_empty

    Returns boolean

    @@ -280,7 +280,7 @@

    line_number

  • Returns number

    @@ -298,7 +298,7 @@

    next

    Returns number

    @@ -315,7 +315,7 @@

    offset

  • Returns number

    @@ -333,7 +333,7 @@

    peek

    Returns number

    @@ -351,7 +351,7 @@

    position

    Returns number

    @@ -369,7 +369,7 @@

    setRemaining

    Parameters

    @@ -393,7 +393,7 @@

    skip

    Parameters

    @@ -417,7 +417,7 @@

    unread

    Parameters

    @@ -441,7 +441,7 @@

    valueAt

    Parameters

    @@ -464,7 +464,7 @@

    viewSource

  • Returns string

    @@ -482,7 +482,7 @@

    write

    Parameters

    @@ -506,7 +506,7 @@

    Static error

    Returns void

    diff --git a/api/classes/ionsubstitutesymboltable.substitutesymboltable.html b/api/classes/ionsubstitutesymboltable.substitutesymboltable.html index bfa4914d..d627f7c6 100644 --- a/api/classes/ionsubstitutesymboltable.substitutesymboltable.html +++ b/api/classes/ionsubstitutesymboltable.substitutesymboltable.html @@ -135,7 +135,7 @@

    constructor

    Parameters

    @@ -161,7 +161,7 @@

    name

  • Returns string

    @@ -178,7 +178,7 @@

    numberOfSymbols

  • Returns number

    @@ -195,7 +195,7 @@

    version

  • Returns number

    @@ -216,7 +216,7 @@

    getSymbolId

    Parameters

    @@ -240,7 +240,7 @@

    getSymbolText

    Parameters

    diff --git a/api/classes/ionsymbol.symbol.html b/api/classes/ionsymbol.symbol.html index 8120a555..38104688 100644 --- a/api/classes/ionsymbol.symbol.html +++ b/api/classes/ionsymbol.symbol.html @@ -114,7 +114,7 @@

    constructor

  • Parameters

    @@ -139,7 +139,7 @@

    name

    name: string
    @@ -149,7 +149,7 @@

    sid

    sid: number
    @@ -166,7 +166,7 @@

    toString

  • Returns string

    diff --git a/api/classes/ionsymboltoken.symboltoken.html b/api/classes/ionsymboltoken.symboltoken.html index ae70c4a8..80ee41f6 100644 --- a/api/classes/ionsymboltoken.symboltoken.html +++ b/api/classes/ionsymboltoken.symboltoken.html @@ -117,7 +117,7 @@

    constructor

  • Parameters

    @@ -146,7 +146,7 @@

    getSid

  • @@ -168,7 +168,7 @@

    getText

  • diff --git a/api/classes/iontextreader.textreader.html b/api/classes/iontextreader.textreader.html index fe79de33..4efac57f 100644 --- a/api/classes/iontextreader.textreader.html +++ b/api/classes/iontextreader.textreader.html @@ -135,7 +135,7 @@

    constructor

  • Parameters

    @@ -164,7 +164,7 @@

    _stringRepresentation

  • Returns null | string

    @@ -182,7 +182,7 @@

    annotations

    @@ -206,7 +206,7 @@

    bigIntValue

    @@ -230,7 +230,7 @@

    booleanValue

    @@ -254,7 +254,7 @@

    decimalValue

    @@ -278,7 +278,7 @@

    depth

    @@ -301,7 +301,7 @@

    fieldName

    @@ -325,7 +325,7 @@

    intSize

    @@ -349,7 +349,7 @@

    isIVM

  • Parameters

    @@ -378,7 +378,7 @@

    isLikeIVM

  • Returns boolean

    @@ -396,7 +396,7 @@

    isNull

    @@ -418,7 +418,7 @@

    load_raw

  • Returns void

    @@ -436,7 +436,7 @@

    next

    @@ -461,7 +461,7 @@

    numberValue

    @@ -488,7 +488,7 @@

    position

    @@ -523,7 +523,7 @@

    skip_past_container

  • Returns void

    @@ -541,7 +541,7 @@

    stepIn

    @@ -565,7 +565,7 @@

    stepOut

    @@ -591,7 +591,7 @@

    stringValue

    @@ -616,7 +616,7 @@

    timestampValue

    @@ -640,7 +640,7 @@

    type

    @@ -664,7 +664,7 @@

    uInt8ArrayValue

    @@ -689,7 +689,7 @@

    value

    diff --git a/api/classes/iontextwriter.context.html b/api/classes/iontextwriter.context.html index 6cb887ff..08f8d378 100644 --- a/api/classes/iontextwriter.context.html +++ b/api/classes/iontextwriter.context.html @@ -109,7 +109,7 @@

    constructor

  • Parameters

    @@ -131,7 +131,7 @@

    clean

    clean: boolean
    @@ -141,7 +141,7 @@

    containerType

    containerType: null | IonType
    @@ -151,7 +151,7 @@

    state

    state: State
    diff --git a/api/classes/iontextwriter.textwriter.html b/api/classes/iontextwriter.textwriter.html index ad8bf842..d855b47b 100644 --- a/api/classes/iontextwriter.textwriter.html +++ b/api/classes/iontextwriter.textwriter.html @@ -144,7 +144,7 @@

    constructor

    Parameters

    @@ -170,7 +170,7 @@

    isTopLevel

  • Returns boolean

    @@ -191,7 +191,7 @@

    addAnnotation

    Parameters

    @@ -215,7 +215,7 @@

    close

    Returns void

    @@ -233,7 +233,7 @@

    depth

    Returns number

    @@ -251,7 +251,7 @@

    getBytes

    Returns Uint8Array

    @@ -269,7 +269,7 @@

    setAnnotations

    Parameters

    @@ -293,7 +293,7 @@

    stepIn

    Parameters

    @@ -317,7 +317,7 @@

    stepOut

    Returns void

    @@ -335,7 +335,7 @@

    writeBlob

    Parameters

    @@ -359,7 +359,7 @@

    writeBoolean

    Parameters

    @@ -383,7 +383,7 @@

    writeClob

    Parameters

    @@ -407,7 +407,7 @@

    writeDecimal

    Parameters

    @@ -431,7 +431,7 @@

    writeFieldName

    Parameters

    @@ -455,7 +455,7 @@

    writeFloat32

    Parameters

    @@ -479,7 +479,7 @@

    writeFloat64

    Parameters

    @@ -503,7 +503,7 @@

    writeInt

    Parameters

    @@ -527,7 +527,7 @@

    writeNull

    Parameters

    @@ -551,7 +551,7 @@

    writeString

    Parameters

    @@ -575,7 +575,7 @@

    writeSymbol

    Parameters

    @@ -599,7 +599,7 @@

    writeTimestamp

    Parameters

    @@ -623,7 +623,7 @@

    writeValue

    Parameters

    @@ -647,7 +647,7 @@

    writeValues

    Parameters

    diff --git a/api/classes/iontimestamp.timestamp.html b/api/classes/iontimestamp.timestamp.html index 2d2f3231..6524b6ae 100644 --- a/api/classes/iontimestamp.timestamp.html +++ b/api/classes/iontimestamp.timestamp.html @@ -124,7 +124,7 @@

    constructor

  • @@ -146,7 +146,7 @@

    Returns
    @@ -222,7 +222,7 @@

    compareTo

  • @@ -300,7 +300,7 @@

    equals

  • @@ -330,7 +330,7 @@

    getDate

  • @@ -365,7 +365,7 @@

    getLocalOffset

  • @@ -387,7 +387,7 @@

    getPrecision

  • @@ -409,7 +409,7 @@

    getSecondsDecimal

  • @@ -431,7 +431,7 @@

    getSecondsInt

  • @@ -453,7 +453,7 @@

    toJSON

  • @@ -476,7 +476,7 @@

    toString

  • @@ -498,7 +498,7 @@

    Static parse

  • diff --git a/api/classes/iontype.iontype-1.html b/api/classes/iontype.iontype-1.html index 8c169cd2..1827faf9 100644 --- a/api/classes/iontype.iontype-1.html +++ b/api/classes/iontype.iontype-1.html @@ -119,7 +119,7 @@

    constructor

  • Parameters

    diff --git a/api/classes/ionwriteable.writeable.html b/api/classes/ionwriteable.writeable.html index 6c78486e..153b897c 100644 --- a/api/classes/ionwriteable.writeable.html +++ b/api/classes/ionwriteable.writeable.html @@ -125,7 +125,7 @@

    constructor

  • Parameters

    @@ -151,7 +151,7 @@

    currentBuffer

  • Returns Uint8Array

    @@ -168,7 +168,7 @@

    totalSize

  • Returns number

    @@ -188,7 +188,7 @@

    getBytes

  • Returns Uint8Array

    @@ -205,7 +205,7 @@

    writeByte

  • Parameters

    @@ -228,7 +228,7 @@

    writeBytes

  • Parameters

    diff --git a/api/classes/signandmagnitudeint.default.html b/api/classes/signandmagnitudeint.default.html index c3a95f35..ae6680f7 100644 --- a/api/classes/signandmagnitudeint.default.html +++ b/api/classes/signandmagnitudeint.default.html @@ -132,7 +132,7 @@

    constructor

  • Parameters

    @@ -178,7 +178,7 @@

    isNegative

  • Returns boolean

    @@ -195,7 +195,7 @@

    magnitude

  • Returns bigint

    @@ -215,7 +215,7 @@

    equals

  • Parameters

    @@ -238,7 +238,7 @@

    Static fromNumber

  • Parameters

    diff --git a/api/enums/comparisonresult.comparisonresulttype.html b/api/enums/comparisonresult.comparisonresulttype.html index bbc350ae..3f5cc9a7 100644 --- a/api/enums/comparisonresult.comparisonresulttype.html +++ b/api/enums/comparisonresult.comparisonresulttype.html @@ -101,7 +101,7 @@

    EQUAL

    EQUAL: = "EQUAL"
    @@ -111,7 +111,7 @@

    ERROR

    ERROR: = "ERROR"
    @@ -121,7 +121,7 @@

    NOT_EQUAL

    NOT_EQUAL: = "NOT_EQUAL"
    diff --git a/api/enums/events_ionevent.ioneventtype.html b/api/enums/events_ionevent.ioneventtype.html index 4513edb1..4efe9239 100644 --- a/api/enums/events_ionevent.ioneventtype.html +++ b/api/enums/events_ionevent.ioneventtype.html @@ -93,7 +93,7 @@

    CONTAINER_END

    CONTAINER_END: = 2
    @@ -103,7 +103,7 @@

    CONTAINER_START

    CONTAINER_START: = 1
    @@ -113,7 +113,7 @@

    SCALAR

    SCALAR: = 0
    @@ -123,7 +123,7 @@

    STREAM_END

    STREAM_END: = 4
    @@ -133,7 +133,7 @@

    SYMBOL_TABLE

    SYMBOL_TABLE: = 3
    diff --git a/api/enums/intsize.intsize-1.html b/api/enums/intsize.intsize-1.html index 2938fd09..1962c414 100644 --- a/api/enums/intsize.intsize-1.html +++ b/api/enums/intsize.intsize-1.html @@ -97,7 +97,7 @@

    BigInt

    BigInt: = 1
    @@ -112,7 +112,7 @@

    Number

    Number: = 0
    diff --git a/api/enums/iontext.charcodes.html b/api/enums/iontext.charcodes.html index d5b1b78f..deb7890d 100644 --- a/api/enums/iontext.charcodes.html +++ b/api/enums/iontext.charcodes.html @@ -111,7 +111,7 @@

    BACKSLASH

    BACKSLASH: = 92
    @@ -121,7 +121,7 @@

    BACKSPACE

    BACKSPACE: = 8
    @@ -131,7 +131,7 @@

    BELL

    BELL: = 7
    @@ -141,7 +141,7 @@

    CARRIAGE_RETURN

    CARRIAGE_RETURN: = 13
    @@ -151,7 +151,7 @@

    COLON

    COLON: = 58
    @@ -161,7 +161,7 @@

    COMMA

    COMMA: = 44
    @@ -171,7 +171,7 @@

    DOUBLE_QUOTE

    DOUBLE_QUOTE: = 34
    @@ -181,7 +181,7 @@

    FORM_FEED

    FORM_FEED: = 12
    @@ -191,7 +191,7 @@

    FORWARD_SLASH

    FORWARD_SLASH: = 47
    @@ -201,7 +201,7 @@

    HORIZONTAL_TAB

    HORIZONTAL_TAB: = 9
    @@ -211,7 +211,7 @@

    LEFT_BRACE

    LEFT_BRACE: = 123
    @@ -221,7 +221,7 @@

    LEFT_BRACKET

    LEFT_BRACKET: = 91
    @@ -231,7 +231,7 @@

    LEFT_PARENTHESIS

    LEFT_PARENTHESIS: = 40
    @@ -241,7 +241,7 @@

    LINE_FEED

    LINE_FEED: = 10
    @@ -251,7 +251,7 @@

    LOWERCASE_X

    LOWERCASE_X: = 120
    @@ -261,7 +261,7 @@

    NULL

    NULL: = 0
    @@ -271,7 +271,7 @@

    QUESTION_MARK

    QUESTION_MARK: = 63
    @@ -281,7 +281,7 @@

    RIGHT_BRACE

    RIGHT_BRACE: = 125
    @@ -291,7 +291,7 @@

    RIGHT_BRACKET

    RIGHT_BRACKET: = 93
    @@ -301,7 +301,7 @@

    RIGHT_PARENTHESIS

    RIGHT_PARENTHESIS: = 41
    @@ -311,7 +311,7 @@

    SINGLE_QUOTE

    SINGLE_QUOTE: = 39
    @@ -321,7 +321,7 @@

    SPACE

    SPACE: = 32
    @@ -331,7 +331,7 @@

    VERTICAL_TAB

    VERTICAL_TAB: = 11
    diff --git a/api/enums/iontextwriter.state.html b/api/enums/iontextwriter.state.html index bceabe3a..f1d99162 100644 --- a/api/enums/iontextwriter.state.html +++ b/api/enums/iontextwriter.state.html @@ -90,7 +90,7 @@

    STRUCT_FIELD

    STRUCT_FIELD: = 1
    @@ -100,7 +100,7 @@

    VALUE

    VALUE: = 0
    diff --git a/api/enums/iontimestamp.timestampprecision.html b/api/enums/iontimestamp.timestampprecision.html index 0a99b35f..085b8a60 100644 --- a/api/enums/iontimestamp.timestampprecision.html +++ b/api/enums/iontimestamp.timestampprecision.html @@ -93,7 +93,7 @@

    DAY

    DAY: = 3
    @@ -103,7 +103,7 @@

    HOUR_AND_MINUTE

    HOUR_AND_MINUTE: = 4
    @@ -113,7 +113,7 @@

    MONTH

    MONTH: = 2
    @@ -123,7 +123,7 @@

    SECONDS

    SECONDS: = 5
    @@ -133,7 +133,7 @@

    YEAR

    YEAR: = 1
    diff --git a/api/interfaces/dom_jsvalueconversion.fromjsvalue.html b/api/interfaces/dom_jsvalueconversion.fromjsvalue.html index fefe3eb0..a8fc456d 100644 --- a/api/interfaces/dom_jsvalueconversion.fromjsvalue.html +++ b/api/interfaces/dom_jsvalueconversion.fromjsvalue.html @@ -101,7 +101,7 @@

    _fromJsValue

  • Parameters

    diff --git a/api/interfaces/dom_value.value-1.html b/api/interfaces/dom_value.value-1.html index 63dcd06c..543526fa 100644 --- a/api/interfaces/dom_value.value-1.html +++ b/api/interfaces/dom_value.value-1.html @@ -146,7 +146,7 @@

    allFields

  • @@ -180,7 +180,7 @@

    as

  • @@ -216,7 +216,7 @@

    bigIntValue

  • @@ -239,7 +239,7 @@

    booleanValue

  • @@ -262,7 +262,7 @@

    dateValue

  • @@ -287,7 +287,7 @@

    decimalValue

  • @@ -310,7 +310,7 @@

    deleteField

  • @@ -339,7 +339,7 @@

    elements

  • @@ -362,7 +362,7 @@

    equals

  • @@ -407,7 +407,7 @@

    fieldNames

  • @@ -430,7 +430,7 @@

    fields

  • @@ -453,7 +453,7 @@

    get

  • @@ -496,7 +496,7 @@

    getAll

  • @@ -539,7 +539,7 @@

    getAnnotations

  • @@ -562,7 +562,7 @@

    getType

  • @@ -584,7 +584,7 @@

    ionEquals

  • @@ -648,7 +648,7 @@

    isNull

  • @@ -670,7 +670,7 @@

    numberValue

  • @@ -695,7 +695,7 @@

    stringValue

  • @@ -718,7 +718,7 @@

    timestampValue

  • @@ -741,7 +741,7 @@

    uInt8ArrayValue

  • @@ -764,7 +764,7 @@

    writeTo

  • diff --git a/api/interfaces/events_ionevent.ionevent.html b/api/interfaces/events_ionevent.ionevent.html index e48409c6..f998ae3e 100644 --- a/api/interfaces/events_ionevent.ionevent.html +++ b/api/interfaces/events_ionevent.ionevent.html @@ -111,7 +111,7 @@

    annotations

    annotations: string[]
    @@ -121,7 +121,7 @@

    depth

    depth: number
    @@ -131,7 +131,7 @@

    eventType

    eventType: IonEventType
    @@ -141,7 +141,7 @@

    fieldName

    fieldName: null | string
    @@ -151,7 +151,7 @@

    ionType

    ionType: null | IonType
    @@ -161,7 +161,7 @@

    ionValue

    ionValue: any
    @@ -178,7 +178,7 @@

    compare

  • Parameters

    @@ -201,7 +201,7 @@

    equals

  • Parameters

    @@ -224,7 +224,7 @@

    write

  • Parameters

    @@ -247,7 +247,7 @@

    writeIonValue

  • Parameters

    diff --git a/api/interfaces/ionbinarywriter.node.html b/api/interfaces/ionbinarywriter.node.html index d53984ed..f6a8b3fe 100644 --- a/api/interfaces/ionbinarywriter.node.html +++ b/api/interfaces/ionbinarywriter.node.html @@ -110,7 +110,7 @@

    addChild

  • Parameters

    @@ -136,7 +136,7 @@

    getLength

  • Returns number

    @@ -153,7 +153,7 @@

    isContainer

  • Returns boolean

    @@ -170,7 +170,7 @@

    write

  • Returns void

    diff --git a/api/interfaces/ionreader.reader.html b/api/interfaces/ionreader.reader.html index aeb87821..e504eaa3 100644 --- a/api/interfaces/ionreader.reader.html +++ b/api/interfaces/ionreader.reader.html @@ -137,7 +137,7 @@

    annotations

  • @@ -160,7 +160,7 @@

    bigIntValue

  • @@ -188,7 +188,7 @@

    booleanValue

  • @@ -216,7 +216,7 @@

    decimalValue

  • @@ -244,7 +244,7 @@

    depth

  • @@ -266,7 +266,7 @@

    fieldName

  • @@ -289,7 +289,7 @@

    intSize

  • @@ -313,7 +313,7 @@

    isNull

  • @@ -335,7 +335,7 @@

    next

  • @@ -359,7 +359,7 @@

    numberValue

  • @@ -390,7 +390,7 @@

    position

  • @@ -425,7 +425,7 @@

    stepIn

  • @@ -453,7 +453,7 @@

    stepOut

  • @@ -483,7 +483,7 @@

    stringValue

  • @@ -512,7 +512,7 @@

    timestampValue

  • @@ -540,7 +540,7 @@

    type

  • @@ -563,7 +563,7 @@

    uInt8ArrayValue

  • @@ -592,7 +592,7 @@

    value

  • diff --git a/api/interfaces/ionwriter.writer.html b/api/interfaces/ionwriter.writer.html index 0ccd45ea..af995577 100644 --- a/api/interfaces/ionwriter.writer.html +++ b/api/interfaces/ionwriter.writer.html @@ -139,7 +139,7 @@

    addAnnotation

  • @@ -168,7 +168,7 @@

    close

  • @@ -196,7 +196,7 @@

    depth

  • @@ -218,7 +218,7 @@

    getBytes

  • @@ -247,7 +247,7 @@

    setAnnotations

  • @@ -277,7 +277,7 @@

    stepIn

  • @@ -311,7 +311,7 @@

    stepOut

  • @@ -338,7 +338,7 @@

    writeBlob

  • @@ -369,7 +369,7 @@

    writeBoolean

  • @@ -400,7 +400,7 @@

    writeClob

  • @@ -431,7 +431,7 @@

    writeDecimal

  • @@ -462,7 +462,7 @@

    writeFieldName

  • @@ -496,7 +496,7 @@

    writeFloat32

  • @@ -529,7 +529,7 @@

    writeFloat64

  • @@ -560,7 +560,7 @@

    writeInt

  • @@ -593,7 +593,7 @@

    writeNull

  • @@ -621,7 +621,7 @@

    writeString

  • @@ -652,7 +652,7 @@

    writeSymbol

  • @@ -683,7 +683,7 @@

    writeTimestamp

  • @@ -714,7 +714,7 @@

    writeValue

  • @@ -747,7 +747,7 @@

    writeValues

  • diff --git a/api/modules/dom_fromjsconstructor.fromjsconstructor.html b/api/modules/dom_fromjsconstructor.fromjsconstructor.html index 6a690c74..f4952038 100644 --- a/api/modules/dom_fromjsconstructor.fromjsconstructor.html +++ b/api/modules/dom_fromjsconstructor.fromjsconstructor.html @@ -89,7 +89,7 @@

    Const NONE

    NONE: FromJsConstructor = ...
    diff --git a/api/modules/dom_value.value.html b/api/modules/dom_value.value.html index 69343f0d..e671ce6b 100644 --- a/api/modules/dom_value.value.html +++ b/api/modules/dom_value.value.html @@ -93,7 +93,7 @@

    from

  • diff --git a/api/modules/ion.html b/api/modules/ion.html index e323fe49..c82dd8c7 100644 --- a/api/modules/ion.html +++ b/api/modules/ion.html @@ -251,7 +251,7 @@

    ReaderBuffer

    ReaderBuffer: ReaderOctetBuffer | string
    @@ -266,7 +266,7 @@

    ReaderOctetBuffer

    ReaderOctetBuffer: ArrayBufferLike | ArrayLike<number>
    @@ -288,7 +288,7 @@

    dumpBinary

  • @@ -319,7 +319,7 @@

    dumpPrettyText

  • @@ -351,7 +351,7 @@

    dumpText

  • @@ -382,7 +382,7 @@

    makeBinaryWriter

  • @@ -404,7 +404,7 @@

    makePrettyWriter

  • @@ -432,7 +432,7 @@

    makeReader

  • @@ -470,7 +470,7 @@

    makeTextWriter

  • diff --git a/api/modules/ionbinary.html b/api/modules/ionbinary.html index f1166d2f..fee8b17f 100644 --- a/api/modules/ionbinary.html +++ b/api/modules/ionbinary.html @@ -107,7 +107,7 @@

    Const BYTE_MASK

    BYTE_MASK: 255 = 0xff
    @@ -117,7 +117,7 @@

    Const BYTE_SHIFT

    BYTE_SHIFT: 8 = 8
    @@ -127,7 +127,7 @@

    Const LEN_MASK

    LEN_MASK: 15 = 0xf
    @@ -137,7 +137,7 @@

    Const LEN_NULL

    LEN_NULL: 15 = 15
    @@ -147,7 +147,7 @@

    Const LEN_VAR

    LEN_VAR: 14 = 14
    @@ -157,7 +157,7 @@

    Const NIBBLE_MASK

    NIBBLE_MASK: 15 = 0xf
    @@ -174,7 +174,7 @@

    Const TB_ANNOTATION

    TB_ANNOTATION: 14 = 14
    @@ -184,7 +184,7 @@

    Const TB_BLOB

    TB_BLOB: 10 = 10
    @@ -194,7 +194,7 @@

    Const TB_BOOL

    TB_BOOL: 1 = 1
    @@ -204,7 +204,7 @@

    Const TB_CLOB

    TB_CLOB: 9 = 9
    @@ -214,7 +214,7 @@

    Const TB_DECIMAL

    TB_DECIMAL: 5 = 5
    @@ -224,7 +224,7 @@

    Const TB_FLOAT

    TB_FLOAT: 4 = 4
    @@ -234,7 +234,7 @@

    Const TB_INT

    TB_INT: 2 = 2
    @@ -244,7 +244,7 @@

    Const TB_LIST

    TB_LIST: 11 = 11
    @@ -254,7 +254,7 @@

    Const TB_NEG_INT

    TB_NEG_INT: 3 = 3
    @@ -264,7 +264,7 @@

    Const TB_NULL

    TB_NULL: 0 = 0
    @@ -274,7 +274,7 @@

    Const TB_SEXP

    TB_SEXP: 12 = 12
    @@ -284,7 +284,7 @@

    Const TB_STRING

    TB_STRING: 8 = 8
    @@ -294,7 +294,7 @@

    Const TB_STRUCT

    TB_STRUCT: 13 = 13
    @@ -304,7 +304,7 @@

    Const TB_SYMBOL

    TB_SYMBOL: 7 = 7
    @@ -314,7 +314,7 @@

    Const TB_TIMESTAMP

    TB_TIMESTAMP: 6 = 6
    @@ -324,7 +324,7 @@

    Const TYPE_SHIFT

    TYPE_SHIFT: 4 = 4
    diff --git a/api/modules/ionconstants.html b/api/modules/ionconstants.html index ef15c012..8530a425 100644 --- a/api/modules/ionconstants.html +++ b/api/modules/ionconstants.html @@ -87,7 +87,7 @@

    Const EOF

    EOF: -1 = -1
    @@ -97,7 +97,7 @@

    Const IVM

    IVM: { binary: Uint8Array; sid: number; text: string } = ...
    diff --git a/api/modules/ionlocalsymboltable.html b/api/modules/ionlocalsymboltable.html index 977359a9..3ed28bda 100644 --- a/api/modules/ionlocalsymboltable.html +++ b/api/modules/ionlocalsymboltable.html @@ -96,7 +96,7 @@

    defaultLocalSymbolTable

  • Returns LocalSymbolTable

    diff --git a/api/modules/ionparsertextraw.html b/api/modules/ionparsertextraw.html index 3a438f5e..cb0e6830 100644 --- a/api/modules/ionparsertextraw.html +++ b/api/modules/ionparsertextraw.html @@ -96,7 +96,7 @@

    get_ion_type

  • Parameters

    diff --git a/api/modules/ionreader.html b/api/modules/ionreader.html index 2faf2ad3..054365e4 100644 --- a/api/modules/ionreader.html +++ b/api/modules/ionreader.html @@ -92,7 +92,7 @@

    ReaderScalarValue

    ReaderScalarValue: null | boolean | number | bigint | Decimal | Timestamp | string | Uint8Array
    diff --git a/api/modules/ionsymbols.html b/api/modules/ionsymbols.html index 56094ddf..4c5260d0 100644 --- a/api/modules/ionsymbols.html +++ b/api/modules/ionsymbols.html @@ -93,7 +93,7 @@

    Const ion_symbol_table<
    ion_symbol_table: "$ion_symbol_table" = "$ion_symbol_table"
    @@ -103,7 +103,7 @@

    Const ion_symbol_table_
    ion_symbol_table_sid: 3 = 3
    @@ -120,7 +120,7 @@

    makeSymbolTable

  • diff --git a/api/modules/ionsystemsymboltable.html b/api/modules/ionsystemsymboltable.html index f04c73fb..8ac9e062 100644 --- a/api/modules/ionsystemsymboltable.html +++ b/api/modules/ionsystemsymboltable.html @@ -91,7 +91,7 @@

    getSystemSymbolTable

  • Returns SharedSymbolTable

    @@ -108,7 +108,7 @@

    getSystemSymbolTableImport

  • Returns Import

    diff --git a/api/modules/iontext.html b/api/modules/iontext.html index 1675fe9f..cb665f74 100644 --- a/api/modules/iontext.html +++ b/api/modules/iontext.html @@ -129,7 +129,7 @@

    Let ClobEscapes

    ClobEscapes: EscapeIndex = ...
    @@ -139,7 +139,7 @@

    Const ESCAPED_NEWLINE

    ESCAPED_NEWLINE: -4 = -4
    @@ -149,7 +149,7 @@

    Let StringEscapes

    StringEscapes: EscapeIndex = ...
    @@ -159,7 +159,7 @@

    Let SymbolEscapes

    SymbolEscapes: EscapeIndex = ...
    @@ -169,7 +169,7 @@

    Const WHITESPACE_COMMENT1WHITESPACE_COMMENT1: -2 = -2

  • @@ -179,7 +179,7 @@

    Const WHITESPACE_COMMENT2WHITESPACE_COMMENT2: -3 = -3

    @@ -196,7 +196,7 @@

    asAscii

  • Parameters

    @@ -219,7 +219,7 @@

    escape

  • Parameters

    @@ -245,7 +245,7 @@

    escapeSequence

  • Parameters

    @@ -268,7 +268,7 @@

    escapeString

  • Parameters

    @@ -294,7 +294,7 @@

    fromBase64

  • Parameters

    @@ -317,7 +317,7 @@

    isDigit

  • Parameters

    @@ -340,7 +340,7 @@

    isIdentifier

  • Parameters

    @@ -363,7 +363,7 @@

    isNumericTerminator

  • Parameters

    @@ -386,7 +386,7 @@

    isOperator

  • Parameters

    @@ -409,7 +409,7 @@

    is_base64_char

  • Parameters

    @@ -432,7 +432,7 @@

    is_digit

  • Parameters

    @@ -455,7 +455,7 @@

    is_hex_digit

  • Parameters

    @@ -478,7 +478,7 @@

    is_keyword

  • Parameters

    @@ -501,7 +501,7 @@

    is_letter

  • Parameters

    @@ -524,7 +524,7 @@

    is_letter_or_digit

  • Parameters

    @@ -547,7 +547,7 @@

    is_operator_char

  • Parameters

    @@ -570,7 +570,7 @@

    is_whitespace

  • Parameters

    @@ -593,7 +593,7 @@

    needsEscape

  • Parameters

    @@ -616,7 +616,7 @@

    nextEscape

  • Parameters

    @@ -642,7 +642,7 @@

    toBase64

  • Parameters

    @@ -665,7 +665,7 @@

    toHex

  • Parameters

    diff --git a/api/modules/iontypes.html b/api/modules/iontypes.html index 8f6f600c..4f37df15 100644 --- a/api/modules/iontypes.html +++ b/api/modules/iontypes.html @@ -86,7 +86,7 @@

    Const IonTypes

    IonTypes: { BLOB: IonType; BOOL: IonType; CLOB: IonType; DECIMAL: IonType; FLOAT: IonType; INT: IonType; LIST: IonType; NULL: IonType; SEXP: IonType; STRING: IonType; STRUCT: IonType; SYMBOL: IonType; TIMESTAMP: IonType } = ...
    diff --git a/api/modules/ionunicode.html b/api/modules/ionunicode.html index 481ec45a..fdb43aa6 100644 --- a/api/modules/ionunicode.html +++ b/api/modules/ionunicode.html @@ -91,7 +91,7 @@

    decodeUtf8

  • Parameters

    @@ -114,7 +114,7 @@

    encodeUtf8

  • diff --git a/api/modules/util.html b/api/modules/util.html index e941b6b2..778edc8c 100644 --- a/api/modules/util.html +++ b/api/modules/util.html @@ -92,7 +92,7 @@

    _assertDefined

  • @@ -120,7 +120,7 @@

    _sign

  • @@ -148,7 +148,7 @@

    isSafeInteger

  • diff --git a/browser/scripts/ion-bundle.js b/browser/scripts/ion-bundle.js index 60590e64..589e8af1 100644 --- a/browser/scripts/ion-bundle.js +++ b/browser/scripts/ion-bundle.js @@ -15,155 +15,131 @@ * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); Object.defineProperty(exports, "__esModule", { value: true }); exports.AbstractWriter = void 0; -var IonTypes_1 = require("./IonTypes"); -var AbstractWriter = /*#__PURE__*/function () { - function AbstractWriter() { - (0, _classCallCheck2["default"])(this, AbstractWriter); +const IonTypes_1 = require("./IonTypes"); +class AbstractWriter { + constructor() { this._annotations = []; } - (0, _createClass2["default"])(AbstractWriter, [{ - key: "addAnnotation", - value: function addAnnotation(annotation) { - if (!this._isString(annotation)) { - throw new Error("Annotation must be of type string."); - } - this._annotations.push(annotation); - } - }, { - key: "setAnnotations", - value: function setAnnotations(annotations) { - if (annotations === undefined || annotations === null) { - throw new Error("Annotations were undefined or null."); - } else if (!this._validateAnnotations(annotations)) { - throw new Error("Annotations must be of type string[]."); - } else { - this._annotations = annotations; - } + addAnnotation(annotation) { + if (!this._isString(annotation)) { + throw new Error("Annotation must be of type string."); } - }, { - key: "writeValues", - value: function writeValues(reader) { - this._writeValues(reader); + this._annotations.push(annotation); + } + setAnnotations(annotations) { + if (annotations === undefined || annotations === null) { + throw new Error("Annotations were undefined or null."); + } else if (!this._validateAnnotations(annotations)) { + throw new Error("Annotations must be of type string[]."); + } else { + this._annotations = annotations; + } + } + writeValues(reader) { + this._writeValues(reader); + } + writeValue(reader) { + this._writeValue(reader); + } + _clearAnnotations() { + this._annotations = []; + } + _writeValues(reader) { + let type = reader.type(); + if (type === null) { + type = reader.next(); } - }, { - key: "writeValue", - value: function writeValue(reader) { + while (type !== null) { this._writeValue(reader); + type = reader.next(); } - }, { - key: "_clearAnnotations", - value: function _clearAnnotations() { - this._annotations = []; + } + _writeValue(reader) { + const type = reader.type(); + if (type === null) { + return; } - }, { - key: "_writeValues", - value: function _writeValues(reader) { - var type = reader.type(); - if (type === null) { - type = reader.next(); - } - while (type !== null) { - this._writeValue(reader); - type = reader.next(); + if (this._isInStruct()) { + const fieldName = reader.fieldName(); + if (fieldName === null) { + throw new Error("Cannot call writeValue() when the Writer is in a Struct but the Reader is not."); } + this.writeFieldName(fieldName); } - }, { - key: "_writeValue", - value: function _writeValue(reader) { - var type = reader.type(); - if (type === null) { - return; - } - if (this._isInStruct()) { - var fieldName = reader.fieldName(); - if (fieldName === null) { - throw new Error("Cannot call writeValue() when the Writer is in a Struct but the Reader is not."); - } - this.writeFieldName(fieldName); - } - this.setAnnotations(reader.annotations()); - if (reader.isNull()) { - this.writeNull(type); - return; - } - switch (type) { - case IonTypes_1.IonTypes.BOOL: - this.writeBoolean(reader.booleanValue()); - break; - case IonTypes_1.IonTypes.INT: - this.writeInt(reader.bigIntValue()); - break; - case IonTypes_1.IonTypes.FLOAT: - this.writeFloat64(reader.numberValue()); - break; - case IonTypes_1.IonTypes.DECIMAL: - this.writeDecimal(reader.decimalValue()); - break; - case IonTypes_1.IonTypes.TIMESTAMP: - this.writeTimestamp(reader.timestampValue()); - break; - case IonTypes_1.IonTypes.SYMBOL: - this.writeSymbol(reader.stringValue()); - break; - case IonTypes_1.IonTypes.STRING: - this.writeString(reader.stringValue()); - break; - case IonTypes_1.IonTypes.CLOB: - this.writeClob(reader.uInt8ArrayValue()); - break; - case IonTypes_1.IonTypes.BLOB: - this.writeBlob(reader.uInt8ArrayValue()); - break; - case IonTypes_1.IonTypes.LIST: - this.stepIn(IonTypes_1.IonTypes.LIST); - break; - case IonTypes_1.IonTypes.SEXP: - this.stepIn(IonTypes_1.IonTypes.SEXP); - break; - case IonTypes_1.IonTypes.STRUCT: - this.stepIn(IonTypes_1.IonTypes.STRUCT); - break; - default: - throw new Error("Unrecognized type " + (type !== null ? type.name : type)); - } - if (type.isContainer) { - reader.stepIn(); - this._writeValues(reader); - this.stepOut(); - reader.stepOut(); - } + this.setAnnotations(reader.annotations()); + if (reader.isNull()) { + this.writeNull(type); + return; + } + switch (type) { + case IonTypes_1.IonTypes.BOOL: + this.writeBoolean(reader.booleanValue()); + break; + case IonTypes_1.IonTypes.INT: + this.writeInt(reader.bigIntValue()); + break; + case IonTypes_1.IonTypes.FLOAT: + this.writeFloat64(reader.numberValue()); + break; + case IonTypes_1.IonTypes.DECIMAL: + this.writeDecimal(reader.decimalValue()); + break; + case IonTypes_1.IonTypes.TIMESTAMP: + this.writeTimestamp(reader.timestampValue()); + break; + case IonTypes_1.IonTypes.SYMBOL: + this.writeSymbol(reader.stringValue()); + break; + case IonTypes_1.IonTypes.STRING: + this.writeString(reader.stringValue()); + break; + case IonTypes_1.IonTypes.CLOB: + this.writeClob(reader.uInt8ArrayValue()); + break; + case IonTypes_1.IonTypes.BLOB: + this.writeBlob(reader.uInt8ArrayValue()); + break; + case IonTypes_1.IonTypes.LIST: + this.stepIn(IonTypes_1.IonTypes.LIST); + break; + case IonTypes_1.IonTypes.SEXP: + this.stepIn(IonTypes_1.IonTypes.SEXP); + break; + case IonTypes_1.IonTypes.STRUCT: + this.stepIn(IonTypes_1.IonTypes.STRUCT); + break; + default: + throw new Error("Unrecognized type " + (type !== null ? type.name : type)); + } + if (type.isContainer) { + reader.stepIn(); + this._writeValues(reader); + this.stepOut(); + reader.stepOut(); + } + } + _validateAnnotations(input) { + if (!Array.isArray(input)) { + return false; } - }, { - key: "_validateAnnotations", - value: function _validateAnnotations(input) { - if (!Array.isArray(input)) { + for (let i = 0; i < input.length; i++) { + if (!this._isString(input[i])) { return false; } - for (var i = 0; i < input.length; i++) { - if (!this._isString(input[i])) { - return false; - } - } - return true; } - }, { - key: "_isString", - value: function _isString(input) { - return typeof input === "string"; - } - }]); - return AbstractWriter; -}(); + return true; + } + _isString(input) { + return typeof input === "string"; + } +} exports.AbstractWriter = AbstractWriter; -},{"./IonTypes":29,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],2:[function(require,module,exports){ +},{"./IonTypes":29}],2:[function(require,module,exports){ "use strict"; /*! @@ -180,100 +156,80 @@ exports.AbstractWriter = AbstractWriter; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); Object.defineProperty(exports, "__esModule", { value: true }); exports.BigIntSerde = void 0; -var BigIntSerde = /*#__PURE__*/function () { - function BigIntSerde() { - (0, _classCallCheck2["default"])(this, BigIntSerde); - } - (0, _createClass2["default"])(BigIntSerde, null, [{ - key: "toSignedIntBytes", - value: function toSignedIntBytes(value, isNegative) { - var bytes = this.toUnsignedIntBytes(value); - if (bytes[0] >= 128) { - var extendedBytes = new Uint8Array(bytes.length + 1); - extendedBytes.set(bytes, 1); - bytes = extendedBytes; - } - if (isNegative) { - bytes[0] += 0x80; - } - return bytes; - } - }, { - key: "fromUnsignedBytes", - value: function fromUnsignedBytes(bytes) { - var magnitude = 0n; - for (var m = 0; m < bytes.length; m++) { - var _byte = BigInt(bytes[m]); - magnitude = magnitude << this.BITS_PER_BYTE; - magnitude = magnitude | _byte; - } - return magnitude; - } - }, { - key: "toUnsignedIntBytes", - value: function toUnsignedIntBytes(value) { - if (value < 0n) { - value = -value; - } - var sizeInBytes = this.getUnsignedIntSizeInBytes(value); - var bytes = new Uint8Array(sizeInBytes); - for (var m = sizeInBytes - 1; m >= 0; m--) { - var lastByte = Number(value & this.BYTE_MAX_VALUE); - value = value >> this.BITS_PER_BYTE; - bytes[m] = lastByte; - } - return bytes; - } - }, { - key: "getUnsignedIntSizeInBytes", - value: function getUnsignedIntSizeInBytes(value) { - for (var m = 0; m < this.SIZE_THRESHOLDS.length; m++) { - var _threshold = this.SIZE_THRESHOLDS[m]; - if (value <= _threshold) { - return m + 1; - } - } - var sizeInBytes = this.SIZE_THRESHOLDS.length; - var threshold = this.calculateSizeThreshold(sizeInBytes); - while (value > threshold) { - sizeInBytes++; - threshold = this.calculateSizeThreshold(sizeInBytes); - } - return sizeInBytes; - } - }, { - key: "calculateSizeThresholds", - value: function calculateSizeThresholds() { - var thresholds = []; - for (var m = 1; m <= this.SERIALIZED_BIGINT_SIZES_TO_PRECOMPUTE; m++) { - thresholds.push(this.calculateSizeThreshold(m)); - } - return thresholds; - } - }, { - key: "calculateSizeThreshold", - value: function calculateSizeThreshold(numberOfBytes) { - var exponent = BigInt(numberOfBytes) * this.BITS_PER_BYTE; - var threshold = Math.pow(2n, exponent); - return threshold - 1n; - } - }]); - return BigIntSerde; -}(); +class BigIntSerde { + static toSignedIntBytes(value, isNegative) { + let bytes = this.toUnsignedIntBytes(value); + if (bytes[0] >= 128) { + const extendedBytes = new Uint8Array(bytes.length + 1); + extendedBytes.set(bytes, 1); + bytes = extendedBytes; + } + if (isNegative) { + bytes[0] += 0x80; + } + return bytes; + } + static fromUnsignedBytes(bytes) { + let magnitude = 0n; + for (let m = 0; m < bytes.length; m++) { + const byte = BigInt(bytes[m]); + magnitude = magnitude << this.BITS_PER_BYTE; + magnitude = magnitude | byte; + } + return magnitude; + } + static toUnsignedIntBytes(value) { + if (value < 0n) { + value = -value; + } + const sizeInBytes = this.getUnsignedIntSizeInBytes(value); + const bytes = new Uint8Array(sizeInBytes); + for (let m = sizeInBytes - 1; m >= 0; m--) { + const lastByte = Number(value & this.BYTE_MAX_VALUE); + value = value >> this.BITS_PER_BYTE; + bytes[m] = lastByte; + } + return bytes; + } + static getUnsignedIntSizeInBytes(value) { + for (let m = 0; m < this.SIZE_THRESHOLDS.length; m++) { + const threshold = this.SIZE_THRESHOLDS[m]; + if (value <= threshold) { + return m + 1; + } + } + let sizeInBytes = this.SIZE_THRESHOLDS.length; + let threshold = this.calculateSizeThreshold(sizeInBytes); + while (value > threshold) { + sizeInBytes++; + threshold = this.calculateSizeThreshold(sizeInBytes); + } + return sizeInBytes; + } + static calculateSizeThresholds() { + const thresholds = []; + for (let m = 1; m <= this.SERIALIZED_BIGINT_SIZES_TO_PRECOMPUTE; m++) { + thresholds.push(this.calculateSizeThreshold(m)); + } + return thresholds; + } + static calculateSizeThreshold(numberOfBytes) { + const exponent = BigInt(numberOfBytes) * this.BITS_PER_BYTE; + const threshold = 2n ** exponent; + return threshold - 1n; + } +} exports.BigIntSerde = BigIntSerde; BigIntSerde.SERIALIZED_BIGINT_SIZES_TO_PRECOMPUTE = 64; BigIntSerde.BITS_PER_BYTE = 8n; BigIntSerde.BYTE_MAX_VALUE = BigInt(0xff); BigIntSerde.SIZE_THRESHOLDS = BigIntSerde.calculateSizeThresholds(); -},{"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],3:[function(require,module,exports){ +},{}],3:[function(require,module,exports){ "use strict"; /*! @@ -290,9 +246,6 @@ BigIntSerde.SIZE_THRESHOLDS = BigIntSerde.calculateSizeThresholds(); * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); Object.defineProperty(exports, "__esModule", { value: true }); @@ -303,20 +256,21 @@ var ComparisonResultType; ComparisonResultType["NOT_EQUAL"] = "NOT_EQUAL"; ComparisonResultType["ERROR"] = "ERROR"; })(ComparisonResultType = exports.ComparisonResultType || (exports.ComparisonResultType = {})); -var ComparisonResult = /*#__PURE__*/(0, _createClass2["default"])(function ComparisonResult() { - var result = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ComparisonResultType.EQUAL; - var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; - var actualIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - var expectedIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; - (0, _classCallCheck2["default"])(this, ComparisonResult); - this.result = result; - this.message = message; - this.actualIndex = actualIndex; - this.expectedIndex = expectedIndex; -}); +class ComparisonResult { + constructor() { + let result = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ComparisonResultType.EQUAL; + let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; + let actualIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; + let expectedIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; + this.result = result; + this.message = message; + this.actualIndex = actualIndex; + this.expectedIndex = expectedIndex; + } +} exports.ComparisonResult = ComparisonResult; -},{"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],4:[function(require,module,exports){ +},{}],4:[function(require,module,exports){ "use strict"; /*! @@ -342,7 +296,7 @@ var IntSize; IntSize[IntSize["Number"] = 0] = "Number"; IntSize[IntSize["BigInt"] = 1] = "BigInt"; })(IntSize = exports.IntSize || (exports.IntSize = {})); -exports["default"] = IntSize; +exports.default = IntSize; },{}],5:[function(require,module,exports){ "use strict"; @@ -361,14 +315,11 @@ exports["default"] = IntSize; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, - get: function get() { + get: function () { return m[k]; } }); @@ -400,23 +351,23 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.dom = exports.IntSize = exports.dumpPrettyText = exports.dumpText = exports.dumpBinary = exports.makeBinaryWriter = exports.makePrettyWriter = exports.makeTextWriter = exports.makeReader = void 0; -var IntSize_1 = __importDefault(require("./IntSize")); -exports.IntSize = IntSize_1["default"]; -var IonBinaryReader_1 = require("./IonBinaryReader"); -var IonBinaryWriter_1 = require("./IonBinaryWriter"); -var IonConstants_1 = require("./IonConstants"); -var IonLocalSymbolTable_1 = require("./IonLocalSymbolTable"); -var IonPrettyTextWriter_1 = require("./IonPrettyTextWriter"); -var IonSpan_1 = require("./IonSpan"); -var IonTextReader_1 = require("./IonTextReader"); -var IonTextWriter_1 = require("./IonTextWriter"); -var IonUnicode_1 = require("./IonUnicode"); -var IonWriteable_1 = require("./IonWriteable"); +const IntSize_1 = __importDefault(require("./IntSize")); +exports.IntSize = IntSize_1.default; +const IonBinaryReader_1 = require("./IonBinaryReader"); +const IonBinaryWriter_1 = require("./IonBinaryWriter"); +const IonConstants_1 = require("./IonConstants"); +const IonLocalSymbolTable_1 = require("./IonLocalSymbolTable"); +const IonPrettyTextWriter_1 = require("./IonPrettyTextWriter"); +const IonSpan_1 = require("./IonSpan"); +const IonTextReader_1 = require("./IonTextReader"); +const IonTextWriter_1 = require("./IonTextWriter"); +const IonUnicode_1 = require("./IonUnicode"); +const IonWriteable_1 = require("./IonWriteable"); function isBinary(buffer) { if (buffer.length < 4) { return false; } - for (var i = 0; i < 4; i++) { + for (let i = 0; i < 4; i++) { if (buffer[i] !== IonConstants_1.IVM.binary[i]) { return false; } @@ -427,7 +378,7 @@ function makeReader(buf, catalog) { if (typeof buf === "string") { return new IonTextReader_1.TextReader(new IonSpan_1.StringSpan(buf), catalog); } - var bufArray = new Uint8Array(buf); + const bufArray = new Uint8Array(buf); if (isBinary(bufArray)) { return new IonBinaryReader_1.BinaryReader(new IonSpan_1.BinarySpan(bufArray), catalog); } else { @@ -444,22 +395,13 @@ function makePrettyWriter(indentSize) { } exports.makePrettyWriter = makePrettyWriter; function makeBinaryWriter() { - var localSymbolTable = IonLocalSymbolTable_1.defaultLocalSymbolTable(); + const localSymbolTable = IonLocalSymbolTable_1.defaultLocalSymbolTable(); return new IonBinaryWriter_1.BinaryWriter(localSymbolTable, new IonWriteable_1.Writeable()); } exports.makeBinaryWriter = makeBinaryWriter; function _writeAllTo(writer, values) { - var _iterator = _createForOfIteratorHelper(values), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var value = _step.value; - dom.Value.from(value).writeTo(writer); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); + for (const value of values) { + dom.Value.from(value).writeTo(writer); } writer.close(); return writer.getBytes(); @@ -488,124 +430,124 @@ exports.dumpPrettyText = dumpPrettyText; var IonCatalog_1 = require("./IonCatalog"); Object.defineProperty(exports, "Catalog", { enumerable: true, - get: function get() { + get: function () { return IonCatalog_1.Catalog; } }); var IonDecimal_1 = require("./IonDecimal"); Object.defineProperty(exports, "Decimal", { enumerable: true, - get: function get() { + get: function () { return IonDecimal_1.Decimal; } }); var IonLocalSymbolTable_2 = require("./IonLocalSymbolTable"); Object.defineProperty(exports, "defaultLocalSymbolTable", { enumerable: true, - get: function get() { + get: function () { return IonLocalSymbolTable_2.defaultLocalSymbolTable; } }); var IonType_1 = require("./IonType"); Object.defineProperty(exports, "IonType", { enumerable: true, - get: function get() { + get: function () { return IonType_1.IonType; } }); var IonTypes_1 = require("./IonTypes"); Object.defineProperty(exports, "IonTypes", { enumerable: true, - get: function get() { + get: function () { return IonTypes_1.IonTypes; } }); var IonSharedSymbolTable_1 = require("./IonSharedSymbolTable"); Object.defineProperty(exports, "SharedSymbolTable", { enumerable: true, - get: function get() { + get: function () { return IonSharedSymbolTable_1.SharedSymbolTable; } }); var IonTimestamp_1 = require("./IonTimestamp"); Object.defineProperty(exports, "TimestampPrecision", { enumerable: true, - get: function get() { + get: function () { return IonTimestamp_1.TimestampPrecision; } }); Object.defineProperty(exports, "Timestamp", { enumerable: true, - get: function get() { + get: function () { return IonTimestamp_1.Timestamp; } }); var IonText_1 = require("./IonText"); Object.defineProperty(exports, "toBase64", { enumerable: true, - get: function get() { + get: function () { return IonText_1.toBase64; } }); var IonUnicode_2 = require("./IonUnicode"); Object.defineProperty(exports, "decodeUtf8", { enumerable: true, - get: function get() { + get: function () { return IonUnicode_2.decodeUtf8; } }); -var dom = __importStar(require("./dom")); +const dom = __importStar(require("./dom")); exports.dom = dom; var dom_1 = require("./dom"); Object.defineProperty(exports, "load", { enumerable: true, - get: function get() { + get: function () { return dom_1.load; } }); Object.defineProperty(exports, "loadAll", { enumerable: true, - get: function get() { + get: function () { return dom_1.loadAll; } }); var IonEvent_1 = require("./events/IonEvent"); Object.defineProperty(exports, "IonEventType", { enumerable: true, - get: function get() { + get: function () { return IonEvent_1.IonEventType; } }); Object.defineProperty(exports, "IonEventFactory", { enumerable: true, - get: function get() { + get: function () { return IonEvent_1.IonEventFactory; } }); var IonEventStream_1 = require("./events/IonEventStream"); Object.defineProperty(exports, "IonEventStream", { enumerable: true, - get: function get() { + get: function () { return IonEventStream_1.IonEventStream; } }); var EventStreamError_1 = require("./events/EventStreamError"); Object.defineProperty(exports, "EventStreamError", { enumerable: true, - get: function get() { + get: function () { return EventStreamError_1.EventStreamError; } }); var ComparisonResult_1 = require("./ComparisonResult"); Object.defineProperty(exports, "ComparisonResult", { enumerable: true, - get: function get() { + get: function () { return ComparisonResult_1.ComparisonResult; } }); Object.defineProperty(exports, "ComparisonResultType", { enumerable: true, - get: function get() { + get: function () { return ComparisonResult_1.ComparisonResultType; } }); @@ -671,9 +613,6 @@ exports.TB_ANNOTATION = 14; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var __importDefault = void 0 && (void 0).__importDefault || function (mod) { return mod && mod.__esModule ? mod : { "default": mod @@ -683,30 +622,30 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.BinaryReader = void 0; -var IntSize_1 = __importDefault(require("./IntSize")); -var IonCatalog_1 = require("./IonCatalog"); -var IonConstants_1 = require("./IonConstants"); -var IonLocalSymbolTable_1 = require("./IonLocalSymbolTable"); -var IonParserBinaryRaw_1 = require("./IonParserBinaryRaw"); -var IonSymbols_1 = require("./IonSymbols"); -var IonTypes_1 = require("./IonTypes"); -var util_1 = require("./util"); -var BOC = -2; -var EOF = -1; -var TB_NULL = 0; -var TB_BOOL = 1; -var TB_INT = 2; -var TB_NEG_INT = 3; -var TB_FLOAT = 4; -var TB_DECIMAL = 5; -var TB_TIMESTAMP = 6; -var TB_SYMBOL = 7; -var TB_STRING = 8; -var TB_CLOB = 9; -var TB_BLOB = 10; -var TB_LIST = 11; -var TB_SEXP = 12; -var TB_STRUCT = 13; +const IntSize_1 = __importDefault(require("./IntSize")); +const IonCatalog_1 = require("./IonCatalog"); +const IonConstants_1 = require("./IonConstants"); +const IonLocalSymbolTable_1 = require("./IonLocalSymbolTable"); +const IonParserBinaryRaw_1 = require("./IonParserBinaryRaw"); +const IonSymbols_1 = require("./IonSymbols"); +const IonTypes_1 = require("./IonTypes"); +const util_1 = require("./util"); +const BOC = -2; +const EOF = -1; +const TB_NULL = 0; +const TB_BOOL = 1; +const TB_INT = 2; +const TB_NEG_INT = 3; +const TB_FLOAT = 4; +const TB_DECIMAL = 5; +const TB_TIMESTAMP = 6; +const TB_SYMBOL = 7; +const TB_STRING = 8; +const TB_CLOB = 9; +const TB_BLOB = 10; +const TB_LIST = 11; +const TB_SEXP = 12; +const TB_STRUCT = 13; function get_ion_type(t) { switch (t) { case TB_NULL: @@ -741,231 +680,183 @@ function get_ion_type(t) { return null; } } -var BinaryReader = /*#__PURE__*/function () { - function BinaryReader(source, catalog) { - (0, _classCallCheck2["default"])(this, BinaryReader); +class BinaryReader { + constructor(source, catalog) { this._annotations = null; this._parser = new IonParserBinaryRaw_1.ParserBinaryRaw(source); this._cat = catalog ? catalog : new IonCatalog_1.Catalog(); this._symtab = IonLocalSymbolTable_1.defaultLocalSymbolTable(); this._raw_type = BOC; } - (0, _createClass2["default"])(BinaryReader, [{ - key: "position", - value: function position() { - return this._parser.source().position(); + position() { + return this._parser.source().position(); + } + next() { + this._annotations = null; + if (this._raw_type === EOF) { + return null; } - }, { - key: "next", - value: function next() { - this._annotations = null; - if (this._raw_type === EOF) { - return null; - } - for (this._raw_type = this._parser.next(); this.depth() === 0; this._raw_type = this._parser.next()) { - if (this._raw_type === TB_SYMBOL) { - var raw = this._parser._getSid(); - if (raw !== IonConstants_1.IVM.sid) { - break; - } - this._symtab = IonLocalSymbolTable_1.defaultLocalSymbolTable(); - } else if (this._raw_type === TB_STRUCT) { - if (!this._parser.hasAnnotations()) { - break; - } - if (this._parser.getAnnotation(0) !== IonSymbols_1.ion_symbol_table_sid) { - break; - } - this._symtab = IonSymbols_1.makeSymbolTable(this._cat, this, this._symtab); - } else { + for (this._raw_type = this._parser.next(); this.depth() === 0; this._raw_type = this._parser.next()) { + if (this._raw_type === TB_SYMBOL) { + const raw = this._parser._getSid(); + if (raw !== IonConstants_1.IVM.sid) { break; } + this._symtab = IonLocalSymbolTable_1.defaultLocalSymbolTable(); + } else if (this._raw_type === TB_STRUCT) { + if (!this._parser.hasAnnotations()) { + break; + } + if (this._parser.getAnnotation(0) !== IonSymbols_1.ion_symbol_table_sid) { + break; + } + this._symtab = IonSymbols_1.makeSymbolTable(this._cat, this, this._symtab); + } else { + break; } - return get_ion_type(this._raw_type); - } - }, { - key: "stepIn", - value: function stepIn() { - if (!get_ion_type(this._raw_type).isContainer) { - throw new Error("Can't step in to a scalar value"); - } - this._parser.stepIn(); - this._raw_type = BOC; - } - }, { - key: "stepOut", - value: function stepOut() { - this._parser.stepOut(); - this._raw_type = BOC; - } - }, { - key: "type", - value: function type() { - return get_ion_type(this._raw_type); - } - }, { - key: "depth", - value: function depth() { - return this._parser.depth(); - } - }, { - key: "fieldName", - value: function fieldName() { - return this.getSymbolString(this._parser.getFieldId()); - } - }, { - key: "hasAnnotations", - value: function hasAnnotations() { - return this._parser.hasAnnotations(); - } - }, { - key: "annotations", - value: function annotations() { - this._loadAnnotations(); - return this._annotations !== null ? this._annotations : []; - } - }, { - key: "getAnnotation", - value: function getAnnotation(index) { - this._loadAnnotations(); - return this._annotations[index]; - } - }, { - key: "isNull", - value: function isNull() { - return this._raw_type === TB_NULL || this._parser.isNull(); - } - }, { - key: "uInt8ArrayValue", - value: function uInt8ArrayValue() { - return this._parser.uInt8ArrayValue(); - } - }, { - key: "booleanValue", - value: function booleanValue() { - return this._parser.booleanValue(); - } - }, { - key: "decimalValue", - value: function decimalValue() { - return this._parser.decimalValue(); - } - }, { - key: "bigIntValue", - value: function bigIntValue() { - return this._parser.bigIntValue(); - } - }, { - key: "intSize", - value: function intSize() { - if (util_1.isSafeInteger(this.bigIntValue())) { - return IntSize_1["default"].Number; - } - return IntSize_1["default"].BigInt; - } - }, { - key: "numberValue", - value: function numberValue() { - return this._parser.numberValue(); - } - }, { - key: "stringValue", - value: function stringValue() { - var t = this; - var p = t._parser; - switch (get_ion_type(t._raw_type)) { - case IonTypes_1.IonTypes.NULL: - return null; - case IonTypes_1.IonTypes.STRING: - if (this.isNull()) { - return null; - } - return p.stringValue(); - case IonTypes_1.IonTypes.SYMBOL: - if (this.isNull()) { - return null; - } - var sid = p._getSid(); - if (sid !== null) { - return this.getSymbolString(sid); - } - } - throw new Error("Current value is not a string or symbol."); } - }, { - key: "timestampValue", - value: function timestampValue() { - return this._parser.timestampValue(); + return get_ion_type(this._raw_type); + } + stepIn() { + if (!get_ion_type(this._raw_type).isContainer) { + throw new Error("Can't step in to a scalar value"); + } + this._parser.stepIn(); + this._raw_type = BOC; + } + stepOut() { + this._parser.stepOut(); + this._raw_type = BOC; + } + type() { + return get_ion_type(this._raw_type); + } + depth() { + return this._parser.depth(); + } + fieldName() { + return this.getSymbolString(this._parser.getFieldId()); + } + hasAnnotations() { + return this._parser.hasAnnotations(); + } + annotations() { + this._loadAnnotations(); + return this._annotations !== null ? this._annotations : []; + } + getAnnotation(index) { + this._loadAnnotations(); + return this._annotations[index]; + } + isNull() { + return this._raw_type === TB_NULL || this._parser.isNull(); + } + uInt8ArrayValue() { + return this._parser.uInt8ArrayValue(); + } + booleanValue() { + return this._parser.booleanValue(); + } + decimalValue() { + return this._parser.decimalValue(); + } + bigIntValue() { + return this._parser.bigIntValue(); + } + intSize() { + if (util_1.isSafeInteger(this.bigIntValue())) { + return IntSize_1.default.Number; } - }, { - key: "value", - value: function value() { - var type = this.type(); - if (type && type.isContainer) { + return IntSize_1.default.BigInt; + } + numberValue() { + return this._parser.numberValue(); + } + stringValue() { + const t = this; + const p = t._parser; + switch (get_ion_type(t._raw_type)) { + case IonTypes_1.IonTypes.NULL: + return null; + case IonTypes_1.IonTypes.STRING: if (this.isNull()) { return null; } - throw new Error("Unable to provide a value for " + type.name + " containers."); - } - switch (type) { - case IonTypes_1.IonTypes.NULL: + return p.stringValue(); + case IonTypes_1.IonTypes.SYMBOL: + if (this.isNull()) { return null; - case IonTypes_1.IonTypes.BLOB: - case IonTypes_1.IonTypes.CLOB: - return this.uInt8ArrayValue(); - case IonTypes_1.IonTypes.BOOL: - return this.booleanValue(); - case IonTypes_1.IonTypes.DECIMAL: - return this.decimalValue(); - case IonTypes_1.IonTypes.INT: - return this.bigIntValue(); - case IonTypes_1.IonTypes.FLOAT: - return this.numberValue(); - case IonTypes_1.IonTypes.STRING: - case IonTypes_1.IonTypes.SYMBOL: - return this.stringValue(); - case IonTypes_1.IonTypes.TIMESTAMP: - return this.timestampValue(); - default: - throw new Error("There is no current value."); - } + } + const sid = p._getSid(); + if (sid !== null) { + return this.getSymbolString(sid); + } } - }, { - key: "_loadAnnotations", - value: function _loadAnnotations() { - var _this = this; - if (this._annotations === null) { - this._annotations = []; - this._parser.getAnnotations().forEach(function (id) { - _this._annotations.push(_this.getSymbolString(id)); - }); + throw new Error("Current value is not a string or symbol."); + } + timestampValue() { + return this._parser.timestampValue(); + } + value() { + const type = this.type(); + if (type && type.isContainer) { + if (this.isNull()) { + return null; } + throw new Error("Unable to provide a value for " + type.name + " containers."); } - }, { - key: "getSymbolString", - value: function getSymbolString(symbolId) { - var s = null; - if (symbolId === null) { + switch (type) { + case IonTypes_1.IonTypes.NULL: return null; + case IonTypes_1.IonTypes.BLOB: + case IonTypes_1.IonTypes.CLOB: + return this.uInt8ArrayValue(); + case IonTypes_1.IonTypes.BOOL: + return this.booleanValue(); + case IonTypes_1.IonTypes.DECIMAL: + return this.decimalValue(); + case IonTypes_1.IonTypes.INT: + return this.bigIntValue(); + case IonTypes_1.IonTypes.FLOAT: + return this.numberValue(); + case IonTypes_1.IonTypes.STRING: + case IonTypes_1.IonTypes.SYMBOL: + return this.stringValue(); + case IonTypes_1.IonTypes.TIMESTAMP: + return this.timestampValue(); + default: + throw new Error("There is no current value."); + } + } + _loadAnnotations() { + if (this._annotations === null) { + this._annotations = []; + this._parser.getAnnotations().forEach(id => { + this._annotations.push(this.getSymbolString(id)); + }); + } + } + getSymbolString(symbolId) { + let s = null; + if (symbolId === null) { + return null; + } + if (symbolId > 0) { + s = this._symtab.getSymbolText(symbolId); + if (s === undefined) { + throw new Error("symbol is unresolvable"); } - if (symbolId > 0) { - s = this._symtab.getSymbolText(symbolId); - if (s === undefined) { - throw new Error("symbol is unresolvable"); - } - } else if (symbolId === 0) { - throw new Error("Symbol ID zero is unsupported"); - } else if (symbolId < 0) { - throw new Error("Negative symbol ID: " + symbolId + " is illegal."); - } - return s; + } else if (symbolId === 0) { + throw new Error("Symbol ID zero is unsupported"); + } else if (symbolId < 0) { + throw new Error("Negative symbol ID: " + symbolId + " is illegal."); } - }]); - return BinaryReader; -}(); + return s; + } +} exports.BinaryReader = BinaryReader; -},{"./IntSize":4,"./IonCatalog":9,"./IonConstants":10,"./IonLocalSymbolTable":13,"./IonParserBinaryRaw":15,"./IonSymbols":22,"./IonTypes":29,"./util":55,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],8:[function(require,module,exports){ +},{"./IntSize":4,"./IonCatalog":9,"./IonConstants":10,"./IonLocalSymbolTable":13,"./IonParserBinaryRaw":15,"./IonSymbols":22,"./IonTypes":29,"./util":55}],8:[function(require,module,exports){ "use strict"; /*! @@ -982,37 +873,25 @@ exports.BinaryReader = BinaryReader; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.NullNode = exports.LeafNode = exports.AbstractNode = exports.BinaryWriter = void 0; -var AbstractWriter_1 = require("./AbstractWriter"); -var BigIntSerde_1 = require("./BigIntSerde"); -var IonLowLevelBinaryWriter_1 = require("./IonLowLevelBinaryWriter"); -var IonTimestamp_1 = require("./IonTimestamp"); -var IonTypes_1 = require("./IonTypes"); -var IonUnicode_1 = require("./IonUnicode"); -var IonWriteable_1 = require("./IonWriteable"); -var util_1 = require("./util"); -var MAJOR_VERSION = 1; -var MINOR_VERSION = 0; -var MAX_VALUE_LENGTH = 14; -var MAX_VALUE_LENGTH_FLAG = 14; -var NULL_VALUE_FLAG = 15; -var TYPE_DESCRIPTOR_LENGTH = 1; -var EMPTY_UINT8ARRAY = new Uint8Array(); +const AbstractWriter_1 = require("./AbstractWriter"); +const BigIntSerde_1 = require("./BigIntSerde"); +const IonLowLevelBinaryWriter_1 = require("./IonLowLevelBinaryWriter"); +const IonTimestamp_1 = require("./IonTimestamp"); +const IonTypes_1 = require("./IonTypes"); +const IonUnicode_1 = require("./IonUnicode"); +const IonWriteable_1 = require("./IonWriteable"); +const util_1 = require("./util"); +const MAJOR_VERSION = 1; +const MINOR_VERSION = 0; +const MAX_VALUE_LENGTH = 14; +const MAX_VALUE_LENGTH_FLAG = 14; +const NULL_VALUE_FLAG = 15; +const TYPE_DESCRIPTOR_LENGTH = 1; +const EMPTY_UINT8ARRAY = new Uint8Array(); var States; (function (States) { States[States["VALUE"] = 0] = "VALUE"; @@ -1038,719 +917,510 @@ var TypeCodes; TypeCodes[TypeCodes["STRUCT"] = 13] = "STRUCT"; TypeCodes[TypeCodes["ANNOTATION"] = 14] = "ANNOTATION"; })(TypeCodes || (TypeCodes = {})); -var BinaryWriter = /*#__PURE__*/function (_AbstractWriter_1$Abs) { - (0, _inherits2["default"])(BinaryWriter, _AbstractWriter_1$Abs); - var _super = _createSuper(BinaryWriter); - function BinaryWriter(symbolTable, writeable) { - var _this; - (0, _classCallCheck2["default"])(this, BinaryWriter); - _this = _super.call(this); - _this.datagram = []; - _this.containers = []; - _this.state = States.VALUE; - _this.symbolTable = symbolTable; - _this.writer = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(writeable); - return _this; - } - (0, _createClass2["default"])(BinaryWriter, [{ - key: "getBytes", - value: function getBytes() { - return this.writer.getBytes(); - } - }, { - key: "writeBlob", - value: function writeBlob(value) { - util_1._assertDefined(value); - this.checkWriteValue(); - if (value === null) { - this.writeNull(IonTypes_1.IonTypes.BLOB); - return; - } - this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.BLOB, this.encodeAnnotations(this._annotations), value)); +class BinaryWriter extends AbstractWriter_1.AbstractWriter { + constructor(symbolTable, writeable) { + super(); + this.datagram = []; + this.containers = []; + this.state = States.VALUE; + this.symbolTable = symbolTable; + this.writer = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(writeable); + } + getBytes() { + return this.writer.getBytes(); + } + writeBlob(value) { + util_1._assertDefined(value); + this.checkWriteValue(); + if (value === null) { + this.writeNull(IonTypes_1.IonTypes.BLOB); + return; + } + this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.BLOB, this.encodeAnnotations(this._annotations), value)); + } + writeBoolean(value) { + util_1._assertDefined(value); + this.checkWriteValue(); + if (value === null) { + this.writeNull(IonTypes_1.IonTypes.BOOL); + return; + } + this.addNode(new BooleanNode(this.writer, this.getCurrentContainer(), this.encodeAnnotations(this._annotations), value)); + } + writeClob(value) { + util_1._assertDefined(value); + this.checkWriteValue(); + if (value === null) { + this.writeNull(IonTypes_1.IonTypes.CLOB); + return; + } + this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.CLOB, this.encodeAnnotations(this._annotations), value)); + } + writeDecimal(value) { + util_1._assertDefined(value); + this.checkWriteValue(); + if (value === null) { + this.writeNull(IonTypes_1.IonTypes.DECIMAL); + return; + } + const exponent = value.getExponent(); + const coefficient = value.getCoefficient(); + const isPositiveZero = coefficient === 0n && !value.isNegative(); + if (isPositiveZero && exponent === 0 && util_1._sign(exponent) === 1) { + this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.DECIMAL, this.encodeAnnotations(this._annotations), new Uint8Array(0))); + return; + } + const isNegative = value.isNegative(); + const writeCoefficient = isNegative || coefficient !== 0n; + const coefficientBytes = writeCoefficient ? BigIntSerde_1.BigIntSerde.toSignedIntBytes(coefficient, isNegative) : EMPTY_UINT8ARRAY; + const bufLen = IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getVariableLengthSignedIntSize(exponent) + (writeCoefficient ? coefficientBytes.length : 0); + const writer = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(new IonWriteable_1.Writeable(bufLen)); + writer.writeVariableLengthSignedInt(exponent); + if (writeCoefficient) { + writer.writeBytes(coefficientBytes); + } + this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.DECIMAL, this.encodeAnnotations(this._annotations), writer.getBytes())); + } + writeFloat32(value) { + util_1._assertDefined(value); + this.checkWriteValue(); + if (value === null) { + this.writeNull(IonTypes_1.IonTypes.FLOAT); + return; + } + let bytes; + if (Object.is(value, 0)) { + bytes = new Uint8Array(0); + } else { + const buffer = new ArrayBuffer(4); + const dataview = new DataView(buffer); + dataview.setFloat32(0, value, false); + bytes = new Uint8Array(buffer); + } + this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.FLOAT, this.encodeAnnotations(this._annotations), bytes)); + } + writeFloat64(value) { + util_1._assertDefined(value); + this.checkWriteValue(); + if (value === null) { + this.writeNull(IonTypes_1.IonTypes.FLOAT); + return; + } + let bytes; + if (Object.is(value, 0)) { + bytes = new Uint8Array(0); + } else { + const buffer = new ArrayBuffer(8); + const dataview = new DataView(buffer); + dataview.setFloat64(0, value, false); + bytes = new Uint8Array(buffer); + } + this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.FLOAT, this.encodeAnnotations(this._annotations), bytes)); + } + writeInt(value) { + util_1._assertDefined(value); + this.checkWriteValue(); + if (value === null) { + this.writeNull(IonTypes_1.IonTypes.INT); + return; + } + this.addNode(new IntNode(this.writer, this.getCurrentContainer(), this.encodeAnnotations(this._annotations), value)); + } + writeNull(type) { + if (type === undefined || type === null) { + type = IonTypes_1.IonTypes.NULL; + } + this.checkWriteValue(); + this.addNode(new NullNode(this.writer, this.getCurrentContainer(), type, this.encodeAnnotations(this._annotations))); + } + writeString(value) { + util_1._assertDefined(value); + this.checkWriteValue(); + if (value === null) { + this.writeNull(IonTypes_1.IonTypes.STRING); + return; + } + this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.STRING, this.encodeAnnotations(this._annotations), IonUnicode_1.encodeUtf8(value))); + } + writeSymbol(value) { + util_1._assertDefined(value); + this.checkWriteValue(); + if (value === null) { + this.writeNull(IonTypes_1.IonTypes.SYMBOL); + } else { + const symbolId = this.symbolTable.addSymbol(value); + const writer = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(new IonWriteable_1.Writeable(IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getUnsignedIntSize(symbolId))); + writer.writeUnsignedInt(symbolId); + this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.SYMBOL, this.encodeAnnotations(this._annotations), writer.getBytes())); + } + } + writeTimestamp(value) { + util_1._assertDefined(value); + this.checkWriteValue(); + if (value === null) { + this.writeNull(IonTypes_1.IonTypes.TIMESTAMP); + return; + } + const writer = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(new IonWriteable_1.Writeable(12)); + writer.writeVariableLengthSignedInt(value.getLocalOffset()); + const date = value.getDate(); + writer.writeVariableLengthUnsignedInt(date.getUTCFullYear()); + if (value.getPrecision() >= IonTimestamp_1.TimestampPrecision.MONTH) { + writer.writeVariableLengthUnsignedInt(date.getUTCMonth() + 1); + } + if (value.getPrecision() >= IonTimestamp_1.TimestampPrecision.DAY) { + writer.writeVariableLengthUnsignedInt(date.getUTCDate()); + } + if (value.getPrecision() >= IonTimestamp_1.TimestampPrecision.HOUR_AND_MINUTE) { + writer.writeVariableLengthUnsignedInt(date.getUTCHours()); + writer.writeVariableLengthUnsignedInt(date.getUTCMinutes()); + } + if (value.getPrecision() >= IonTimestamp_1.TimestampPrecision.SECONDS) { + writer.writeVariableLengthUnsignedInt(value.getSecondsInt()); + const fractionalSeconds = value._getFractionalSeconds(); + if (fractionalSeconds.getExponent() !== 0) { + writer.writeVariableLengthSignedInt(fractionalSeconds.getExponent()); + if (fractionalSeconds.getCoefficient() !== 0n) { + writer.writeBytes(BigIntSerde_1.BigIntSerde.toSignedIntBytes(fractionalSeconds.getCoefficient(), fractionalSeconds.isNegative())); + } + } + } + this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.TIMESTAMP, this.encodeAnnotations(this._annotations), writer.getBytes())); + } + stepIn(type) { + this.checkWriteValue(); + switch (type) { + case IonTypes_1.IonTypes.LIST: + case IonTypes_1.IonTypes.SEXP: + this.addNode(new SequenceNode(this.writer, this.getCurrentContainer(), type, this.encodeAnnotations(this._annotations))); + break; + case IonTypes_1.IonTypes.STRUCT: + this.addNode(new StructNode(this.writer, this.getCurrentContainer(), this.encodeAnnotations(this._annotations))); + this.state = States.STRUCT_FIELD; + break; + default: + throw new Error("Unrecognized container type"); } - }, { - key: "writeBoolean", - value: function writeBoolean(value) { - util_1._assertDefined(value); - this.checkWriteValue(); - if (value === null) { - this.writeNull(IonTypes_1.IonTypes.BOOL); - return; - } - this.addNode(new BooleanNode(this.writer, this.getCurrentContainer(), this.encodeAnnotations(this._annotations), value)); + } + stepOut() { + if (this.depth() === 0) { + throw new Error("Not currently in a container"); } - }, { - key: "writeClob", - value: function writeClob(value) { - util_1._assertDefined(value); - this.checkWriteValue(); - if (value === null) { - this.writeNull(IonTypes_1.IonTypes.CLOB); - return; - } - this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.CLOB, this.encodeAnnotations(this._annotations), value)); + if (this.state === States.STRUCT_VALUE) { + throw new Error("Cannot exit a struct with a partially written field"); } - }, { - key: "writeDecimal", - value: function writeDecimal(value) { - util_1._assertDefined(value); - this.checkWriteValue(); - if (value === null) { - this.writeNull(IonTypes_1.IonTypes.DECIMAL); - return; - } - var exponent = value.getExponent(); - var coefficient = value.getCoefficient(); - var isPositiveZero = coefficient === 0n && !value.isNegative(); - if (isPositiveZero && exponent === 0 && util_1._sign(exponent) === 1) { - this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.DECIMAL, this.encodeAnnotations(this._annotations), new Uint8Array(0))); - return; - } - var isNegative = value.isNegative(); - var writeCoefficient = isNegative || coefficient !== 0n; - var coefficientBytes = writeCoefficient ? BigIntSerde_1.BigIntSerde.toSignedIntBytes(coefficient, isNegative) : EMPTY_UINT8ARRAY; - var bufLen = IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getVariableLengthSignedIntSize(exponent) + (writeCoefficient ? coefficientBytes.length : 0); - var writer = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(new IonWriteable_1.Writeable(bufLen)); - writer.writeVariableLengthSignedInt(exponent); - if (writeCoefficient) { - writer.writeBytes(coefficientBytes); - } - this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.DECIMAL, this.encodeAnnotations(this._annotations), writer.getBytes())); - } - }, { - key: "writeFloat32", - value: function writeFloat32(value) { - util_1._assertDefined(value); - this.checkWriteValue(); - if (value === null) { - this.writeNull(IonTypes_1.IonTypes.FLOAT); - return; - } - var bytes; - if (Object.is(value, 0)) { - bytes = new Uint8Array(0); - } else { - var buffer = new ArrayBuffer(4); - var dataview = new DataView(buffer); - dataview.setFloat32(0, value, false); - bytes = new Uint8Array(buffer); - } - this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.FLOAT, this.encodeAnnotations(this._annotations), bytes)); - } - }, { - key: "writeFloat64", - value: function writeFloat64(value) { - util_1._assertDefined(value); - this.checkWriteValue(); - if (value === null) { - this.writeNull(IonTypes_1.IonTypes.FLOAT); - return; - } - var bytes; - if (Object.is(value, 0)) { - bytes = new Uint8Array(0); - } else { - var buffer = new ArrayBuffer(8); - var dataview = new DataView(buffer); - dataview.setFloat64(0, value, false); - bytes = new Uint8Array(buffer); - } - this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.FLOAT, this.encodeAnnotations(this._annotations), bytes)); - } - }, { - key: "writeInt", - value: function writeInt(value) { - util_1._assertDefined(value); - this.checkWriteValue(); - if (value === null) { - this.writeNull(IonTypes_1.IonTypes.INT); - return; - } - this.addNode(new IntNode(this.writer, this.getCurrentContainer(), this.encodeAnnotations(this._annotations), value)); + this.containers.pop(); + if (this.depth() > 0) { + this.state = this.getCurrentContainer() instanceof StructNode ? States.STRUCT_FIELD : States.VALUE; + } else { + this.state = States.VALUE; } - }, { - key: "writeNull", - value: function writeNull(type) { - if (type === undefined || type === null) { - type = IonTypes_1.IonTypes.NULL; - } - this.checkWriteValue(); - this.addNode(new NullNode(this.writer, this.getCurrentContainer(), type, this.encodeAnnotations(this._annotations))); + } + _isInStruct() { + return this.getCurrentContainer() instanceof StructNode; + } + writeFieldName(fieldName) { + util_1._assertDefined(fieldName); + if (this.state !== States.STRUCT_FIELD) { + throw new Error("Cannot write a field name outside of a struct"); } - }, { - key: "writeString", - value: function writeString(value) { - util_1._assertDefined(value); - this.checkWriteValue(); - if (value === null) { - this.writeNull(IonTypes_1.IonTypes.STRING); - return; - } - this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.STRING, this.encodeAnnotations(this._annotations), IonUnicode_1.encodeUtf8(value))); + this.fieldName = this.encodeAnnotations([fieldName]); + this.state = States.STRUCT_VALUE; + } + depth() { + return this.containers.length; + } + close() { + this.checkClosed(); + if (this.depth() > 0) { + throw new Error("Writer has one or more open containers; call stepOut() for each container prior to close()"); } - }, { - key: "writeSymbol", - value: function writeSymbol(value) { - util_1._assertDefined(value); - this.checkWriteValue(); - if (value === null) { - this.writeNull(IonTypes_1.IonTypes.SYMBOL); - } else { - var symbolId = this.symbolTable.addSymbol(value); - var writer = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(new IonWriteable_1.Writeable(IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getUnsignedIntSize(symbolId))); - writer.writeUnsignedInt(symbolId); - this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.SYMBOL, this.encodeAnnotations(this._annotations), writer.getBytes())); - } - } - }, { - key: "writeTimestamp", - value: function writeTimestamp(value) { - util_1._assertDefined(value); - this.checkWriteValue(); - if (value === null) { - this.writeNull(IonTypes_1.IonTypes.TIMESTAMP); - return; - } - var writer = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(new IonWriteable_1.Writeable(12)); - writer.writeVariableLengthSignedInt(value.getLocalOffset()); - var date = value.getDate(); - writer.writeVariableLengthUnsignedInt(date.getUTCFullYear()); - if (value.getPrecision() >= IonTimestamp_1.TimestampPrecision.MONTH) { - writer.writeVariableLengthUnsignedInt(date.getUTCMonth() + 1); - } - if (value.getPrecision() >= IonTimestamp_1.TimestampPrecision.DAY) { - writer.writeVariableLengthUnsignedInt(date.getUTCDate()); - } - if (value.getPrecision() >= IonTimestamp_1.TimestampPrecision.HOUR_AND_MINUTE) { - writer.writeVariableLengthUnsignedInt(date.getUTCHours()); - writer.writeVariableLengthUnsignedInt(date.getUTCMinutes()); - } - if (value.getPrecision() >= IonTimestamp_1.TimestampPrecision.SECONDS) { - writer.writeVariableLengthUnsignedInt(value.getSecondsInt()); - var fractionalSeconds = value._getFractionalSeconds(); - if (fractionalSeconds.getExponent() !== 0) { - writer.writeVariableLengthSignedInt(fractionalSeconds.getExponent()); - if (fractionalSeconds.getCoefficient() !== 0n) { - writer.writeBytes(BigIntSerde_1.BigIntSerde.toSignedIntBytes(fractionalSeconds.getCoefficient(), fractionalSeconds.isNegative())); - } - } - } - this.addNode(new BytesNode(this.writer, this.getCurrentContainer(), IonTypes_1.IonTypes.TIMESTAMP, this.encodeAnnotations(this._annotations), writer.getBytes())); + this.writeIvm(); + const datagram = this.datagram; + this.datagram = []; + this.writeSymbolTable(); + for (const node of datagram) { + node.write(); } - }, { - key: "stepIn", - value: function stepIn(type) { - this.checkWriteValue(); - switch (type) { - case IonTypes_1.IonTypes.LIST: - case IonTypes_1.IonTypes.SEXP: - this.addNode(new SequenceNode(this.writer, this.getCurrentContainer(), type, this.encodeAnnotations(this._annotations))); - break; - case IonTypes_1.IonTypes.STRUCT: - this.addNode(new StructNode(this.writer, this.getCurrentContainer(), this.encodeAnnotations(this._annotations))); - this.state = States.STRUCT_FIELD; - break; - default: - throw new Error("Unrecognized container type"); - } + this.state = States.CLOSED; + } + writeIvm() { + this.writer.writeByte(0xe0); + this.writer.writeByte(MAJOR_VERSION); + this.writer.writeByte(MINOR_VERSION); + this.writer.writeByte(0xea); + } + encodeAnnotations(annotations) { + if (annotations.length === 0) { + return new Uint8Array(0); } - }, { - key: "stepOut", - value: function stepOut() { - if (this.depth() === 0) { - throw new Error("Not currently in a container"); - } + const writeable = new IonWriteable_1.Writeable(); + const writer = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(writeable); + for (const annotation of annotations) { + const symbolId = this.symbolTable.addSymbol(annotation); + writer.writeVariableLengthUnsignedInt(symbolId); + } + this._clearAnnotations(); + return writeable.getBytes(); + } + getCurrentContainer() { + return this.containers[this.containers.length - 1]; + } + addNode(node) { + if (this.depth() === 0) { + this.datagram.push(node); + } else { if (this.state === States.STRUCT_VALUE) { - throw new Error("Cannot exit a struct with a partially written field"); - } - this.containers.pop(); - if (this.depth() > 0) { - this.state = this.getCurrentContainer() instanceof StructNode ? States.STRUCT_FIELD : States.VALUE; - } else { - this.state = States.VALUE; - } - } - }, { - key: "_isInStruct", - value: function _isInStruct() { - return this.getCurrentContainer() instanceof StructNode; - } - }, { - key: "writeFieldName", - value: function writeFieldName(fieldName) { - util_1._assertDefined(fieldName); - if (this.state !== States.STRUCT_FIELD) { - throw new Error("Cannot write a field name outside of a struct"); - } - this.fieldName = this.encodeAnnotations([fieldName]); - this.state = States.STRUCT_VALUE; - } - }, { - key: "depth", - value: function depth() { - return this.containers.length; - } - }, { - key: "close", - value: function close() { - this.checkClosed(); - if (this.depth() > 0) { - throw new Error("Writer has one or more open containers; call stepOut() for each container prior to close()"); - } - this.writeIvm(); - var datagram = this.datagram; - this.datagram = []; - this.writeSymbolTable(); - var _iterator = _createForOfIteratorHelper(datagram), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var node = _step.value; - node.write(); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - this.state = States.CLOSED; - } - }, { - key: "writeIvm", - value: function writeIvm() { - this.writer.writeByte(0xe0); - this.writer.writeByte(MAJOR_VERSION); - this.writer.writeByte(MINOR_VERSION); - this.writer.writeByte(0xea); - } - }, { - key: "encodeAnnotations", - value: function encodeAnnotations(annotations) { - if (annotations.length === 0) { - return new Uint8Array(0); - } - var writeable = new IonWriteable_1.Writeable(); - var writer = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(writeable); - var _iterator2 = _createForOfIteratorHelper(annotations), - _step2; - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var annotation = _step2.value; - var symbolId = this.symbolTable.addSymbol(annotation); - writer.writeVariableLengthUnsignedInt(symbolId); - } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } - this._clearAnnotations(); - return writeable.getBytes(); - } - }, { - key: "getCurrentContainer", - value: function getCurrentContainer() { - return this.containers[this.containers.length - 1]; - } - }, { - key: "addNode", - value: function addNode(node) { - if (this.depth() === 0) { - this.datagram.push(node); + this.getCurrentContainer().addChild(node, this.fieldName); + this.state = States.STRUCT_FIELD; } else { - if (this.state === States.STRUCT_VALUE) { - this.getCurrentContainer().addChild(node, this.fieldName); - this.state = States.STRUCT_FIELD; - } else { - this.getCurrentContainer().addChild(node); - } - } - if (node.isContainer()) { - this.containers.push(node); - this.state = States.VALUE; + this.getCurrentContainer().addChild(node); } } - }, { - key: "checkWriteValue", - value: function checkWriteValue() { - this.checkClosed(); - if (this.state === States.STRUCT_FIELD) { - throw new Error("Expected a struct field name instead of a value, call writeFieldName(string) with the desired name before calling stepIn(IonType) or writeIonType()"); - } + if (node.isContainer()) { + this.containers.push(node); + this.state = States.VALUE; } - }, { - key: "checkClosed", - value: function checkClosed() { - if (this.state === States.CLOSED) { - throw new Error("Writer is closed, no further operations are available"); - } + } + checkWriteValue() { + this.checkClosed(); + if (this.state === States.STRUCT_FIELD) { + throw new Error("Expected a struct field name instead of a value, call writeFieldName(string) with the desired name before calling stepIn(IonType) or writeIonType()"); } - }, { - key: "writeSymbolTable", - value: function writeSymbolTable() { - var hasImports = this.symbolTable["import"].symbolTable.name != "$ion"; - var hasLocalSymbols = this.symbolTable.symbols.length > 0; - if (!(hasImports || hasLocalSymbols)) { - return; - } - this.setAnnotations(["$ion_symbol_table"]); - this.stepIn(IonTypes_1.IonTypes.STRUCT); - if (hasImports) { - this.writeFieldName("imports"); - this.stepIn(IonTypes_1.IonTypes.LIST); - this.writeImport(this.symbolTable["import"]); - this.stepOut(); - } - if (hasLocalSymbols) { - this.writeFieldName("symbols"); - this.stepIn(IonTypes_1.IonTypes.LIST); - var _iterator3 = _createForOfIteratorHelper(this.symbolTable.symbols), - _step3; - try { - for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { - var symbol_ = _step3.value; - if (symbol_ !== undefined) { - this.writeString(symbol_); - } - } - } catch (err) { - _iterator3.e(err); - } finally { - _iterator3.f(); - } - this.stepOut(); - } + } + checkClosed() { + if (this.state === States.CLOSED) { + throw new Error("Writer is closed, no further operations are available"); + } + } + writeSymbolTable() { + const hasImports = this.symbolTable.import.symbolTable.name != "$ion"; + const hasLocalSymbols = this.symbolTable.symbols.length > 0; + if (!(hasImports || hasLocalSymbols)) { + return; + } + this.setAnnotations(["$ion_symbol_table"]); + this.stepIn(IonTypes_1.IonTypes.STRUCT); + if (hasImports) { + this.writeFieldName("imports"); + this.stepIn(IonTypes_1.IonTypes.LIST); + this.writeImport(this.symbolTable.import); this.stepOut(); - this.datagram[0].write(); } - }, { - key: "writeImport", - value: function writeImport(import_) { - if (!import_) { - return; + if (hasLocalSymbols) { + this.writeFieldName("symbols"); + this.stepIn(IonTypes_1.IonTypes.LIST); + for (const symbol_ of this.symbolTable.symbols) { + if (symbol_ !== undefined) { + this.writeString(symbol_); + } } - this.writeImport(import_.parent); - this.stepIn(IonTypes_1.IonTypes.STRUCT); - this.writeFieldName("name"); - this.writeString(import_.symbolTable.name); - this.writeFieldName("version"); - this.writeInt(import_.symbolTable.version); - this.writeFieldName("max_id"); - this.writeInt(import_.length); this.stepOut(); } - }]); - return BinaryWriter; -}(AbstractWriter_1.AbstractWriter); + this.stepOut(); + this.datagram[0].write(); + } + writeImport(import_) { + if (!import_) { + return; + } + this.writeImport(import_.parent); + this.stepIn(IonTypes_1.IonTypes.STRUCT); + this.writeFieldName("name"); + this.writeString(import_.symbolTable.name); + this.writeFieldName("version"); + this.writeInt(import_.symbolTable.version); + this.writeFieldName("max_id"); + this.writeInt(import_.length); + this.stepOut(); + } +} exports.BinaryWriter = BinaryWriter; -var AbstractNode = /*#__PURE__*/function () { - function AbstractNode(_writer, parent, _type, annotations) { - (0, _classCallCheck2["default"])(this, AbstractNode); +class AbstractNode { + constructor(_writer, parent, _type, annotations) { this._writer = _writer; this.parent = parent; this._type = _type; this.annotations = annotations; } - (0, _createClass2["default"])(AbstractNode, [{ - key: "typeCode", - get: function get() { - return this._type.binaryTypeId; - } - }, { - key: "writer", - get: function get() { - return this._writer; - } - }, { - key: "writeTypeDescriptorAndLength", - value: function writeTypeDescriptorAndLength(typeCode, isNull, length) { - var typeDescriptor = typeCode << 4; - if (isNull) { - typeDescriptor |= NULL_VALUE_FLAG; - this.writer.writeByte(typeDescriptor); - } else if (length < MAX_VALUE_LENGTH) { - typeDescriptor |= length; - this.writer.writeByte(typeDescriptor); - } else { - typeDescriptor |= MAX_VALUE_LENGTH_FLAG; - this.writer.writeByte(typeDescriptor); - this.writer.writeVariableLengthUnsignedInt(length); - } - } - }, { - key: "getContainedValueLength", - value: function getContainedValueLength() { - var valueLength = this.getValueLength(); - var valueLengthLength = AbstractNode.getLengthLength(valueLength); - return TYPE_DESCRIPTOR_LENGTH + valueLengthLength + valueLength; - } - }, { - key: "getAnnotatedContainerLength", - value: function getAnnotatedContainerLength() { - var annotationsLength = this.annotations.length; - var annotationsLengthLength = IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getVariableLengthUnsignedIntSize(annotationsLength); - var containedValueLength = this.getContainedValueLength(); - return annotationsLength + annotationsLengthLength + containedValueLength; - } - }, { - key: "getAnnotationsLength", - value: function getAnnotationsLength() { - if (this.hasAnnotations()) { - var annotationsLength = this.annotations.length; - var annotationsLengthLength = IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getVariableLengthUnsignedIntSize(annotationsLength); - var containedValueLength = this.getContainedValueLength(); - var annotationsWrapperLengthLength = AbstractNode.getLengthLength(containedValueLength + annotationsLength + annotationsLengthLength); - return TYPE_DESCRIPTOR_LENGTH + annotationsWrapperLengthLength + annotationsLengthLength + annotationsLength; - } + get typeCode() { + return this._type.binaryTypeId; + } + get writer() { + return this._writer; + } + static getLengthLength(length) { + if (length < MAX_VALUE_LENGTH) { return 0; + } else { + return IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getVariableLengthUnsignedIntSize(length); } - }, { - key: "getLength", - value: function getLength() { - var annotationsLength = this.getAnnotationsLength(); - var containedValueLength = this.getContainedValueLength(); - return annotationsLength + containedValueLength; - } - }, { - key: "writeAnnotations", - value: function writeAnnotations() { - if (!this.hasAnnotations()) { - return; - } - var annotatedContainerLength = this.getAnnotatedContainerLength(); - this.writeTypeDescriptorAndLength(TypeCodes.ANNOTATION, false, annotatedContainerLength); - this.writer.writeVariableLengthUnsignedInt(this.annotations.length); - this.writer.writeBytes(new Uint8Array(this.annotations)); + } + writeTypeDescriptorAndLength(typeCode, isNull, length) { + let typeDescriptor = typeCode << 4; + if (isNull) { + typeDescriptor |= NULL_VALUE_FLAG; + this.writer.writeByte(typeDescriptor); + } else if (length < MAX_VALUE_LENGTH) { + typeDescriptor |= length; + this.writer.writeByte(typeDescriptor); + } else { + typeDescriptor |= MAX_VALUE_LENGTH_FLAG; + this.writer.writeByte(typeDescriptor); + this.writer.writeVariableLengthUnsignedInt(length); } - }, { - key: "hasAnnotations", - value: function hasAnnotations() { - return this.annotations.length > 0; + } + getContainedValueLength() { + const valueLength = this.getValueLength(); + const valueLengthLength = AbstractNode.getLengthLength(valueLength); + return TYPE_DESCRIPTOR_LENGTH + valueLengthLength + valueLength; + } + getAnnotatedContainerLength() { + const annotationsLength = this.annotations.length; + const annotationsLengthLength = IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getVariableLengthUnsignedIntSize(annotationsLength); + const containedValueLength = this.getContainedValueLength(); + return annotationsLength + annotationsLengthLength + containedValueLength; + } + getAnnotationsLength() { + if (this.hasAnnotations()) { + const annotationsLength = this.annotations.length; + const annotationsLengthLength = IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getVariableLengthUnsignedIntSize(annotationsLength); + const containedValueLength = this.getContainedValueLength(); + const annotationsWrapperLengthLength = AbstractNode.getLengthLength(containedValueLength + annotationsLength + annotationsLengthLength); + return TYPE_DESCRIPTOR_LENGTH + annotationsWrapperLengthLength + annotationsLengthLength + annotationsLength; } - }], [{ - key: "getLengthLength", - value: function getLengthLength(length) { - if (length < MAX_VALUE_LENGTH) { - return 0; - } else { - return IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getVariableLengthUnsignedIntSize(length); - } + return 0; + } + getLength() { + const annotationsLength = this.getAnnotationsLength(); + const containedValueLength = this.getContainedValueLength(); + return annotationsLength + containedValueLength; + } + writeAnnotations() { + if (!this.hasAnnotations()) { + return; } - }]); - return AbstractNode; -}(); -exports.AbstractNode = AbstractNode; -var ContainerNode = /*#__PURE__*/function (_AbstractNode) { - (0, _inherits2["default"])(ContainerNode, _AbstractNode); - var _super2 = _createSuper(ContainerNode); - function ContainerNode(writer, parent, type, annotations) { - (0, _classCallCheck2["default"])(this, ContainerNode); - return _super2.call(this, writer, parent, type, annotations); - } - (0, _createClass2["default"])(ContainerNode, [{ - key: "isContainer", - value: function isContainer() { - return true; + const annotatedContainerLength = this.getAnnotatedContainerLength(); + this.writeTypeDescriptorAndLength(TypeCodes.ANNOTATION, false, annotatedContainerLength); + this.writer.writeVariableLengthUnsignedInt(this.annotations.length); + this.writer.writeBytes(new Uint8Array(this.annotations)); + } + hasAnnotations() { + return this.annotations.length > 0; + } +} +exports.AbstractNode = AbstractNode; +class ContainerNode extends AbstractNode { + constructor(writer, parent, type, annotations) { + super(writer, parent, type, annotations); + } + isContainer() { + return true; + } +} +class SequenceNode extends ContainerNode { + constructor(writer, parent, type, annotations) { + super(writer, parent, type, annotations); + this.children = []; + } + addChild(child, name) { + this.children.push(child); + } + write() { + this.writeAnnotations(); + this.writeTypeDescriptorAndLength(this.typeCode, false, this.getValueLength()); + for (const child of this.children) { + child.write(); } - }]); - return ContainerNode; -}(AbstractNode); -var SequenceNode = /*#__PURE__*/function (_ContainerNode) { - (0, _inherits2["default"])(SequenceNode, _ContainerNode); - var _super3 = _createSuper(SequenceNode); - function SequenceNode(writer, parent, type, annotations) { - var _this2; - (0, _classCallCheck2["default"])(this, SequenceNode); - _this2 = _super3.call(this, writer, parent, type, annotations); - _this2.children = []; - return _this2; - } - (0, _createClass2["default"])(SequenceNode, [{ - key: "addChild", - value: function addChild(child, name) { - this.children.push(child); - } - }, { - key: "write", - value: function write() { - this.writeAnnotations(); - this.writeTypeDescriptorAndLength(this.typeCode, false, this.getValueLength()); - var _iterator4 = _createForOfIteratorHelper(this.children), - _step4; - try { - for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { - var child = _step4.value; - child.write(); - } - } catch (err) { - _iterator4.e(err); - } finally { - _iterator4.f(); - } - } - }, { - key: "getValueLength", - value: function getValueLength() { - var valueLength = 0; - var _iterator5 = _createForOfIteratorHelper(this.children), - _step5; - try { - for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { - var child = _step5.value; - valueLength += child.getLength(); - } - } catch (err) { - _iterator5.e(err); - } finally { - _iterator5.f(); - } - return valueLength; - } - }, { - key: "getLength", - value: function getLength() { - if (this.length === undefined) { - this.length = (0, _get2["default"])((0, _getPrototypeOf2["default"])(SequenceNode.prototype), "getLength", this).call(this); - } - return this.length; - } - }]); - return SequenceNode; -}(ContainerNode); -var StructNode = /*#__PURE__*/function (_ContainerNode2) { - (0, _inherits2["default"])(StructNode, _ContainerNode2); - var _super4 = _createSuper(StructNode); - function StructNode(writer, parent, annotations) { - var _this3; - (0, _classCallCheck2["default"])(this, StructNode); - _this3 = _super4.call(this, writer, parent, IonTypes_1.IonTypes.STRUCT, annotations); - _this3.fields = []; - return _this3; - } - (0, _createClass2["default"])(StructNode, [{ - key: "addChild", - value: function addChild(child, fieldName) { - if (fieldName === null || fieldName === undefined) { - throw new Error("Cannot add a value to a struct without a field name"); - } - this.fields.push({ - name: fieldName, - value: child - }); + } + getValueLength() { + let valueLength = 0; + for (const child of this.children) { + valueLength += child.getLength(); } - }, { - key: "getValueLength", - value: function getValueLength() { - var valueLength = 0; - var _iterator6 = _createForOfIteratorHelper(this.fields), - _step6; - try { - for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { - var field = _step6.value; - valueLength += field.name.length; - valueLength += field.value.getLength(); - } - } catch (err) { - _iterator6.e(err); - } finally { - _iterator6.f(); - } - return valueLength; - } - }, { - key: "getLength", - value: function getLength() { - if (this.length === undefined) { - this.length = (0, _get2["default"])((0, _getPrototypeOf2["default"])(StructNode.prototype), "getLength", this).call(this); - } - return this.length; - } - }, { - key: "write", - value: function write() { - this.writeAnnotations(); - this.writeTypeDescriptorAndLength(this.typeCode, false, this.getValueLength()); - var _iterator7 = _createForOfIteratorHelper(this.fields), - _step7; - try { - for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) { - var field = _step7.value; - this.writer.writeBytes(new Uint8Array(field.name)); - field.value.write(); - } - } catch (err) { - _iterator7.e(err); - } finally { - _iterator7.f(); - } - } - }]); - return StructNode; -}(ContainerNode); -var LeafNode = /*#__PURE__*/function (_AbstractNode2) { - (0, _inherits2["default"])(LeafNode, _AbstractNode2); - var _super5 = _createSuper(LeafNode); - function LeafNode() { - (0, _classCallCheck2["default"])(this, LeafNode); - return _super5.apply(this, arguments); - } - (0, _createClass2["default"])(LeafNode, [{ - key: "addChild", - value: function addChild(child, name) { - throw new Error("Cannot add a child to a leaf node"); - } - }, { - key: "isContainer", - value: function isContainer() { - return false; + return valueLength; + } + getLength() { + if (this.length === undefined) { + this.length = super.getLength(); } - }]); - return LeafNode; -}(AbstractNode); -exports.LeafNode = LeafNode; -var BooleanNode = /*#__PURE__*/function (_LeafNode) { - (0, _inherits2["default"])(BooleanNode, _LeafNode); - var _super6 = _createSuper(BooleanNode); - function BooleanNode(writer, parent, annotations, value) { - var _this4; - (0, _classCallCheck2["default"])(this, BooleanNode); - _this4 = _super6.call(this, writer, parent, IonTypes_1.IonTypes.BOOL, annotations); - _this4.value = value; - return _this4; - } - (0, _createClass2["default"])(BooleanNode, [{ - key: "write", - value: function write() { - this.writeAnnotations(); - this.writeTypeDescriptorAndLength(this.typeCode, false, this.value ? 1 : 0); - } - }, { - key: "getValueLength", - value: function getValueLength() { - return 0; + return this.length; + } +} +class StructNode extends ContainerNode { + constructor(writer, parent, annotations) { + super(writer, parent, IonTypes_1.IonTypes.STRUCT, annotations); + this.fields = []; + } + addChild(child, fieldName) { + if (fieldName === null || fieldName === undefined) { + throw new Error("Cannot add a value to a struct without a field name"); + } + this.fields.push({ + name: fieldName, + value: child + }); + } + getValueLength() { + let valueLength = 0; + for (const field of this.fields) { + valueLength += field.name.length; + valueLength += field.value.getLength(); + } + return valueLength; + } + getLength() { + if (this.length === undefined) { + this.length = super.getLength(); + } + return this.length; + } + write() { + this.writeAnnotations(); + this.writeTypeDescriptorAndLength(this.typeCode, false, this.getValueLength()); + for (const field of this.fields) { + this.writer.writeBytes(new Uint8Array(field.name)); + field.value.write(); } - }]); - return BooleanNode; -}(LeafNode); -var IntNode = /*#__PURE__*/function (_LeafNode2) { - (0, _inherits2["default"])(IntNode, _LeafNode2); - var _super7 = _createSuper(IntNode); - function IntNode(writer, parent, annotations, value) { - var _this5; - (0, _classCallCheck2["default"])(this, IntNode); - _this5 = _super7.call(this, writer, parent, IonTypes_1.IonTypes.INT, annotations); - _this5.value = value; - if (!(typeof _this5.value === "number" || typeof _this5.value === "bigint")) { - throw new Error("Expected " + _this5.value + " to be a number or bigint"); - } - if (_this5.value > 0n) { - _this5.intTypeCode = TypeCodes.POSITIVE_INT; - var _writer2 = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(new IonWriteable_1.Writeable(IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getUnsignedIntSize(_this5.value))); - _writer2.writeUnsignedInt(_this5.value); - _this5.bytes = _writer2.getBytes(); - } else if (_this5.value < 0n) { - _this5.intTypeCode = TypeCodes.NEGATIVE_INT; - var magnitude; + } +} +class LeafNode extends AbstractNode { + addChild(child, name) { + throw new Error("Cannot add a child to a leaf node"); + } + isContainer() { + return false; + } +} +exports.LeafNode = LeafNode; +class BooleanNode extends LeafNode { + constructor(writer, parent, annotations, value) { + super(writer, parent, IonTypes_1.IonTypes.BOOL, annotations); + this.value = value; + } + write() { + this.writeAnnotations(); + this.writeTypeDescriptorAndLength(this.typeCode, false, this.value ? 1 : 0); + } + getValueLength() { + return 0; + } +} +class IntNode extends LeafNode { + constructor(writer, parent, annotations, value) { + super(writer, parent, IonTypes_1.IonTypes.INT, annotations); + this.value = value; + if (!(typeof this.value === "number" || typeof this.value === "bigint")) { + throw new Error("Expected " + this.value + " to be a number or bigint"); + } + if (this.value > 0n) { + this.intTypeCode = TypeCodes.POSITIVE_INT; + const writer = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(new IonWriteable_1.Writeable(IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getUnsignedIntSize(this.value))); + writer.writeUnsignedInt(this.value); + this.bytes = writer.getBytes(); + } else if (this.value < 0n) { + this.intTypeCode = TypeCodes.NEGATIVE_INT; + let magnitude; if (typeof value === "bigint") { if (value < 0n) { magnitude = -value; @@ -1760,79 +1430,52 @@ var IntNode = /*#__PURE__*/function (_LeafNode2) { } else { magnitude = Math.abs(value); } - var _writer3 = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(new IonWriteable_1.Writeable(IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getUnsignedIntSize(magnitude))); - _writer3.writeUnsignedInt(magnitude); - _this5.bytes = _writer3.getBytes(); + const writer = new IonLowLevelBinaryWriter_1.LowLevelBinaryWriter(new IonWriteable_1.Writeable(IonLowLevelBinaryWriter_1.LowLevelBinaryWriter.getUnsignedIntSize(magnitude))); + writer.writeUnsignedInt(magnitude); + this.bytes = writer.getBytes(); } else { - _this5.intTypeCode = TypeCodes.POSITIVE_INT; - _this5.bytes = new Uint8Array(0); - } - return _this5; - } - (0, _createClass2["default"])(IntNode, [{ - key: "write", - value: function write() { - this.writeAnnotations(); - this.writeTypeDescriptorAndLength(this.intTypeCode, false, this.bytes.length); - this.writer.writeBytes(this.bytes); - } - }, { - key: "getValueLength", - value: function getValueLength() { - return this.bytes.length; - } - }]); - return IntNode; -}(LeafNode); -var BytesNode = /*#__PURE__*/function (_LeafNode3) { - (0, _inherits2["default"])(BytesNode, _LeafNode3); - var _super8 = _createSuper(BytesNode); - function BytesNode(writer, parent, type, annotations, value) { - var _this6; - (0, _classCallCheck2["default"])(this, BytesNode); - _this6 = _super8.call(this, writer, parent, type, annotations); - _this6.value = value; - return _this6; - } - (0, _createClass2["default"])(BytesNode, [{ - key: "write", - value: function write() { - this.writeAnnotations(); - this.writeTypeDescriptorAndLength(this.typeCode, false, this.value.length); - this.writer.writeBytes(this.value); - } - }, { - key: "getValueLength", - value: function getValueLength() { - return this.value.length; - } - }]); - return BytesNode; -}(LeafNode); -var NullNode = /*#__PURE__*/function (_LeafNode4) { - (0, _inherits2["default"])(NullNode, _LeafNode4); - var _super9 = _createSuper(NullNode); - function NullNode(writer, parent, type, annotations) { - (0, _classCallCheck2["default"])(this, NullNode); - return _super9.call(this, writer, parent, type, annotations); - } - (0, _createClass2["default"])(NullNode, [{ - key: "write", - value: function write() { - this.writeAnnotations(); - this.writeTypeDescriptorAndLength(this.typeCode, true, 0); - } - }, { - key: "getValueLength", - value: function getValueLength() { - return 0; + this.intTypeCode = TypeCodes.POSITIVE_INT; + this.bytes = new Uint8Array(0); } - }]); - return NullNode; -}(LeafNode); + } + write() { + this.writeAnnotations(); + this.writeTypeDescriptorAndLength(this.intTypeCode, false, this.bytes.length); + this.writer.writeBytes(this.bytes); + } + getValueLength() { + return this.bytes.length; + } +} +class BytesNode extends LeafNode { + constructor(writer, parent, type, annotations, value) { + super(writer, parent, type, annotations); + this.value = value; + } + write() { + this.writeAnnotations(); + this.writeTypeDescriptorAndLength(this.typeCode, false, this.value.length); + this.writer.writeBytes(this.value); + } + getValueLength() { + return this.value.length; + } +} +class NullNode extends LeafNode { + constructor(writer, parent, type, annotations) { + super(writer, parent, type, annotations); + } + write() { + this.writeAnnotations(); + this.writeTypeDescriptorAndLength(this.typeCode, true, 0); + } + getValueLength() { + return 0; + } +} exports.NullNode = NullNode; -},{"./AbstractWriter":1,"./BigIntSerde":2,"./IonLowLevelBinaryWriter":14,"./IonTimestamp":27,"./IonTypes":29,"./IonUnicode":30,"./IonWriteable":31,"./util":55,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/get":65,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],9:[function(require,module,exports){ +},{"./AbstractWriter":1,"./BigIntSerde":2,"./IonLowLevelBinaryWriter":14,"./IonTimestamp":27,"./IonTypes":29,"./IonUnicode":30,"./IonWriteable":31,"./util":55}],9:[function(require,module,exports){ "use strict"; /*! @@ -1849,63 +1492,51 @@ exports.NullNode = NullNode; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); Object.defineProperty(exports, "__esModule", { value: true }); exports.Catalog = void 0; -var IonSystemSymbolTable_1 = require("./IonSystemSymbolTable"); +const IonSystemSymbolTable_1 = require("./IonSystemSymbolTable"); function byVersion(x, y) { return x.version - y.version; } -var Catalog = /*#__PURE__*/function () { - function Catalog() { - (0, _classCallCheck2["default"])(this, Catalog); +class Catalog { + constructor() { this.symbolTables = {}; this.add(IonSystemSymbolTable_1.getSystemSymbolTable()); } - (0, _createClass2["default"])(Catalog, [{ - key: "add", - value: function add(symbolTable) { - if (symbolTable.name === undefined || symbolTable.name === null) { - throw new Error("SymbolTable name must be defined."); - } - var versions = this.symbolTables[symbolTable.name]; - if (versions === undefined) { - this.symbolTables[symbolTable.name] = []; - } - this.symbolTables[symbolTable.name][symbolTable.version] = symbolTable; + add(symbolTable) { + if (symbolTable.name === undefined || symbolTable.name === null) { + throw new Error("SymbolTable name must be defined."); } - }, { - key: "getVersion", - value: function getVersion(name, version) { - var tables = this.symbolTables[name]; - if (!tables) { - return null; - } - var table = tables[version]; - if (!table) { - table = tables[tables.length]; - } - return table ? table : null; + const versions = this.symbolTables[symbolTable.name]; + if (versions === undefined) { + this.symbolTables[symbolTable.name] = []; } - }, { - key: "getTable", - value: function getTable(name) { - var versions = this.symbolTables[name]; - if (versions === undefined) { - return null; - } - return versions[versions.length - 1]; + this.symbolTables[symbolTable.name][symbolTable.version] = symbolTable; + } + getVersion(name, version) { + const tables = this.symbolTables[name]; + if (!tables) { + return null; + } + let table = tables[version]; + if (!table) { + table = tables[tables.length]; + } + return table ? table : null; + } + getTable(name) { + const versions = this.symbolTables[name]; + if (versions === undefined) { + return null; } - }]); - return Catalog; -}(); + return versions[versions.length - 1]; + } +} exports.Catalog = Catalog; -},{"./IonSystemSymbolTable":23,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],10:[function(require,module,exports){ +},{"./IonSystemSymbolTable":23}],10:[function(require,module,exports){ "use strict"; /*! @@ -1950,19 +1581,14 @@ exports.IVM = { * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); Object.defineProperty(exports, "__esModule", { value: true }); exports.Decimal = void 0; -var util_1 = require("./util"); -var Decimal = /*#__PURE__*/function () { - function Decimal(coefficient, exponent) { - var isNegative = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - (0, _classCallCheck2["default"])(this, Decimal); +const util_1 = require("./util"); +class Decimal { + constructor(coefficient, exponent) { + let isNegative = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; if (typeof coefficient === "string") { return Decimal.parse(coefficient); } @@ -1980,194 +1606,154 @@ var Decimal = /*#__PURE__*/function () { } return Decimal._fromBigIntCoefficient(isNegative, coefficient, exponent); } - throw new Error("Unsupported parameter set (".concat(coefficient, ", ").concat(exponent, ", ").concat(isNegative, " passed to Decimal constructor.")); - } - (0, _createClass2["default"])(Decimal, [{ - key: "isNegative", - value: function isNegative() { - return this._isNegative; - } - }, { - key: "numberValue", - value: function numberValue() { - if (this._isNegativeZero()) { - return -0; - } - return Number(this._coefficient) * Math.pow(10, this._exponent); - } - }, { - key: "intValue", - value: function intValue() { - return Math.trunc(this.numberValue()); - } - }, { - key: "toString", - value: function toString() { - var cStr = this._coefficient.toString(); - if (cStr[0] === "-") { - cStr = cStr.substring(1, cStr.length); - } - var precision = cStr.length; - var adjustedExponent = this._exponent + (precision - 1); - var s = ""; - if (this._exponent <= 0 && adjustedExponent >= -6) { - if (this._exponent === 0) { - s += cStr; + throw new Error(`Unsupported parameter set (${coefficient}, ${exponent}, ${isNegative} passed to Decimal constructor.`); + } + static _fromNumberCoefficient(coefficient, exponent) { + if (!Number.isInteger(coefficient)) { + throw new Error("The provided coefficient was not an integer. (" + coefficient + ")"); + } + const isNegative = coefficient < 0 || Object.is(coefficient, -0); + return this._fromBigIntCoefficient(isNegative, BigInt(coefficient), exponent); + } + static _fromBigIntCoefficient(isNegative, coefficient, exponent) { + const value = Object.create(this.prototype); + value._initialize(isNegative, coefficient, exponent); + return value; + } + static parse(str) { + let exponent = 0; + if (str === "null" || str === "null.decimal") { + return null; + } + const d = str.match("[d|D]"); + let exponentDelimiterIndex = str.length; + if (d !== undefined && d !== null) { + exponent = Number(str.substring(d.index + 1, str.length)); + exponentDelimiterIndex = d.index; + } + const f = str.match("\\."); + let coefficientText; + if (f) { + const exponentShift = d ? d.index - 1 - f.index : str.length - 1 - f.index; + exponent -= exponentShift; + coefficientText = str.substring(0, f.index) + str.substring(f.index + 1, exponentDelimiterIndex); + } else { + coefficientText = str.substring(0, exponentDelimiterIndex); + } + const coefficient = BigInt(coefficientText); + const isNegative = coefficient < 0n || coefficientText.startsWith("-0"); + return Decimal._fromBigIntCoefficient(isNegative, coefficient, exponent); + } + isNegative() { + return this._isNegative; + } + numberValue() { + if (this._isNegativeZero()) { + return -0; + } + return Number(this._coefficient) * Math.pow(10, this._exponent); + } + intValue() { + return Math.trunc(this.numberValue()); + } + toString() { + let cStr = this._coefficient.toString(); + if (cStr[0] === "-") { + cStr = cStr.substring(1, cStr.length); + } + const precision = cStr.length; + const adjustedExponent = this._exponent + (precision - 1); + let s = ""; + if (this._exponent <= 0 && adjustedExponent >= -6) { + if (this._exponent === 0) { + s += cStr; + } else { + if (cStr.length <= -this._exponent) { + cStr = "0".repeat(-this._exponent - cStr.length + 1) + cStr; + s += cStr.substring(0, 1) + "." + cStr.substring(1); } else { - if (cStr.length <= -this._exponent) { - cStr = "0".repeat(-this._exponent - cStr.length + 1) + cStr; - s += cStr.substring(0, 1) + "." + cStr.substring(1); - } else { - s += cStr.substring(0, precision + this._exponent) + "." + cStr.substring(precision + this._exponent); - } + s += cStr.substring(0, precision + this._exponent) + "." + cStr.substring(precision + this._exponent); } - } else { - s += cStr[0]; - if (cStr.length > 1) { - s += "." + cStr.substring(1); - } - s += "E" + (adjustedExponent > 0 ? "+" : "") + adjustedExponent; - } - return (this.isNegative() ? "-" : "") + s; - } - }, { - key: "toJSON", - value: function toJSON() { - return this.numberValue(); - } - }, { - key: "getCoefficient", - value: function getCoefficient() { - return this._coefficient; - } - }, { - key: "getExponent", - value: function getExponent() { - return this._exponent; - } - }, { - key: "equals", - value: function equals(that) { - return this.getExponent() === that.getExponent() && util_1._sign(this.getExponent()) === util_1._sign(that.getExponent()) && this.isNegative() === that.isNegative() && this.getCoefficient() === that.getCoefficient(); - } - }, { - key: "compareTo", - value: function compareTo(that) { - if (this._coefficient === 0n && that._coefficient === 0n) { - return 0; } - var neg = this.isNegative(); - if (neg !== that.isNegative()) { - return neg ? -1 : 1; - } - var _this$_compareToParam = this._compareToParams(), - _this$_compareToParam2 = (0, _slicedToArray2["default"])(_this$_compareToParam, 3), - thisCoefficientStr = _this$_compareToParam2[0], - thisPrecision = _this$_compareToParam2[1], - thisMagnitude = _this$_compareToParam2[2]; - var _that$_compareToParam = that._compareToParams(), - _that$_compareToParam2 = (0, _slicedToArray2["default"])(_that$_compareToParam, 3), - thatCoefficientStr = _that$_compareToParam2[0], - thatPrecision = _that$_compareToParam2[1], - thatMagnitude = _that$_compareToParam2[2]; - if (thisMagnitude > thatMagnitude) { - return neg ? -1 : 1; - } else if (thisMagnitude < thatMagnitude) { - return neg ? 1 : -1; - } - if (thisCoefficientStr.length < thatCoefficientStr.length) { - thisCoefficientStr += "0".repeat(thatPrecision - thisPrecision); - } else if (thisCoefficientStr.length > thatCoefficientStr.length) { - thatCoefficientStr += "0".repeat(thisPrecision - thatPrecision); - } - var thisBigInt = BigInt(thisCoefficientStr); - var thatBigInt = BigInt(thatCoefficientStr); - if (thisBigInt > thatBigInt) { - return neg ? -1 : 1; - } else if (thisBigInt < thatBigInt) { - return neg ? 1 : -1; + } else { + s += cStr[0]; + if (cStr.length > 1) { + s += "." + cStr.substring(1); } + s += "E" + (adjustedExponent > 0 ? "+" : "") + adjustedExponent; + } + return (this.isNegative() ? "-" : "") + s; + } + toJSON() { + return this.numberValue(); + } + getCoefficient() { + return this._coefficient; + } + getExponent() { + return this._exponent; + } + equals(that) { + return this.getExponent() === that.getExponent() && util_1._sign(this.getExponent()) === util_1._sign(that.getExponent()) && this.isNegative() === that.isNegative() && this.getCoefficient() === that.getCoefficient(); + } + compareTo(that) { + if (this._coefficient === 0n && that._coefficient === 0n) { return 0; } - }, { - key: "_initialize", - value: function _initialize(isNegative, coefficient, exponent) { - this._isNegative = isNegative; - this._coefficient = coefficient; - if (Object.is(-0, exponent)) { - exponent = 0; - } - this._exponent = exponent; - } - }, { - key: "_isNegativeZero", - value: function _isNegativeZero() { - return this.isNegative() && this._coefficient == 0n; - } - }, { - key: "_compareToParams", - value: function _compareToParams() { - var coefficientStr = this.isNegative() ? this._coefficient.toString().substring(1) : this._coefficient.toString(); - var precision = coefficientStr.length; - var magnitude = precision + this._exponent; - if (magnitude <= 0) { - magnitude -= 1; - } - if (this._coefficient === 0n) { - magnitude = -Infinity; - } - return [coefficientStr, precision, magnitude]; - } - }], [{ - key: "_fromNumberCoefficient", - value: function _fromNumberCoefficient(coefficient, exponent) { - if (!Number.isInteger(coefficient)) { - throw new Error("The provided coefficient was not an integer. (" + coefficient + ")"); - } - var isNegative = coefficient < 0 || Object.is(coefficient, -0); - return this._fromBigIntCoefficient(isNegative, BigInt(coefficient), exponent); - } - }, { - key: "_fromBigIntCoefficient", - value: function _fromBigIntCoefficient(isNegative, coefficient, exponent) { - var value = Object.create(this.prototype); - value._initialize(isNegative, coefficient, exponent); - return value; + const neg = this.isNegative(); + if (neg !== that.isNegative()) { + return neg ? -1 : 1; } - }, { - key: "parse", - value: function parse(str) { - var exponent = 0; - if (str === "null" || str === "null.decimal") { - return null; - } - var d = str.match("[d|D]"); - var exponentDelimiterIndex = str.length; - if (d !== undefined && d !== null) { - exponent = Number(str.substring(d.index + 1, str.length)); - exponentDelimiterIndex = d.index; - } - var f = str.match("\\."); - var coefficientText; - if (f) { - var exponentShift = d ? d.index - 1 - f.index : str.length - 1 - f.index; - exponent -= exponentShift; - coefficientText = str.substring(0, f.index) + str.substring(f.index + 1, exponentDelimiterIndex); - } else { - coefficientText = str.substring(0, exponentDelimiterIndex); - } - var coefficient = BigInt(coefficientText); - var isNegative = coefficient < 0n || coefficientText.startsWith("-0"); - return Decimal._fromBigIntCoefficient(isNegative, coefficient, exponent); + let [thisCoefficientStr, thisPrecision, thisMagnitude] = this._compareToParams(); + let [thatCoefficientStr, thatPrecision, thatMagnitude] = that._compareToParams(); + if (thisMagnitude > thatMagnitude) { + return neg ? -1 : 1; + } else if (thisMagnitude < thatMagnitude) { + return neg ? 1 : -1; + } + if (thisCoefficientStr.length < thatCoefficientStr.length) { + thisCoefficientStr += "0".repeat(thatPrecision - thisPrecision); + } else if (thisCoefficientStr.length > thatCoefficientStr.length) { + thatCoefficientStr += "0".repeat(thisPrecision - thatPrecision); + } + const thisBigInt = BigInt(thisCoefficientStr); + const thatBigInt = BigInt(thatCoefficientStr); + if (thisBigInt > thatBigInt) { + return neg ? -1 : 1; + } else if (thisBigInt < thatBigInt) { + return neg ? 1 : -1; + } + return 0; + } + _initialize(isNegative, coefficient, exponent) { + this._isNegative = isNegative; + this._coefficient = coefficient; + if (Object.is(-0, exponent)) { + exponent = 0; + } + this._exponent = exponent; + } + _isNegativeZero() { + return this.isNegative() && this._coefficient == 0n; + } + _compareToParams() { + const coefficientStr = this.isNegative() ? this._coefficient.toString().substring(1) : this._coefficient.toString(); + const precision = coefficientStr.length; + let magnitude = precision + this._exponent; + if (magnitude <= 0) { + magnitude -= 1; } - }]); - return Decimal; -}(); + if (this._coefficient === 0n) { + magnitude = -Infinity; + } + return [coefficientStr, precision, magnitude]; + } +} exports.Decimal = Decimal; Decimal.ZERO = new Decimal(0, 0); Decimal.ONE = new Decimal(1, 0); -},{"./util":55,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/slicedToArray":77}],12:[function(require,module,exports){ +},{"./util":55}],12:[function(require,module,exports){ "use strict"; /*! @@ -2184,81 +1770,63 @@ Decimal.ONE = new Decimal(1, 0); * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); Object.defineProperty(exports, "__esModule", { value: true }); exports.Import = void 0; -var Import = /*#__PURE__*/function () { - function Import(parent, symbolTable, length) { - (0, _classCallCheck2["default"])(this, Import); +class Import { + constructor(parent, symbolTable, length) { this._parent = parent; this._symbolTable = symbolTable; this._offset = this.parent ? this.parent.offset + this.parent.length : 1; this._length = length || this.symbolTable.numberOfSymbols; } - (0, _createClass2["default"])(Import, [{ - key: "parent", - get: function get() { - return this._parent; - } - }, { - key: "offset", - get: function get() { - return this._offset; + get parent() { + return this._parent; + } + get offset() { + return this._offset; + } + get length() { + return this._length; + } + get symbolTable() { + return this._symbolTable; + } + getSymbolText(symbolId) { + if (this.parent === undefined) { + throw new Error("Illegal parent state."); } - }, { - key: "length", - get: function get() { - return this._length; + if (this.parent !== null) { + const parentSymbol = this.parent.getSymbolText(symbolId); + if (parentSymbol) { + return parentSymbol; + } } - }, { - key: "symbolTable", - get: function get() { - return this._symbolTable; + const index = symbolId - this.offset; + if (index >= 0 && index < this.length) { + return this.symbolTable.getSymbolText(index); } - }, { - key: "getSymbolText", - value: function getSymbolText(symbolId) { - if (this.parent === undefined) { - throw new Error("Illegal parent state."); - } - if (this.parent !== null) { - var parentSymbol = this.parent.getSymbolText(symbolId); - if (parentSymbol) { - return parentSymbol; - } - } - var index = symbolId - this.offset; - if (index >= 0 && index < this.length) { - return this.symbolTable.getSymbolText(index); + return undefined; + } + getSymbolId(symbolText) { + let symbolId; + if (this.parent !== null) { + symbolId = this.parent.getSymbolId(symbolText); + if (symbolId) { + return symbolId; } - return undefined; } - }, { - key: "getSymbolId", - value: function getSymbolId(symbolText) { - var symbolId; - if (this.parent !== null) { - symbolId = this.parent.getSymbolId(symbolText); - if (symbolId) { - return symbolId; - } - } - symbolId = this.symbolTable.getSymbolId(symbolText); - if (symbolId !== null && symbolId !== undefined && symbolId < this.length) { - return symbolId + this.offset; - } - return undefined; + symbolId = this.symbolTable.getSymbolId(symbolText); + if (symbolId !== null && symbolId !== undefined && symbolId < this.length) { + return symbolId + this.offset; } - }]); - return Import; -}(); + return undefined; + } +} exports.Import = Import; -},{"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],13:[function(require,module,exports){ +},{}],13:[function(require,module,exports){ "use strict"; /*! @@ -2275,21 +1843,14 @@ exports.Import = Import; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } Object.defineProperty(exports, "__esModule", { value: true }); exports.defaultLocalSymbolTable = exports.LocalSymbolTable = void 0; -var IonSystemSymbolTable_1 = require("./IonSystemSymbolTable"); -var LocalSymbolTable = /*#__PURE__*/function () { - function LocalSymbolTable(theImport) { - var symbols = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, LocalSymbolTable); +const IonSystemSymbolTable_1 = require("./IonSystemSymbolTable"); +class LocalSymbolTable { + constructor(theImport) { + let symbols = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; this.index = Object.create(null); this._symbols = []; if (theImport === null) { @@ -2298,93 +1859,66 @@ var LocalSymbolTable = /*#__PURE__*/function () { this._import = theImport; } this.offset = this._import.offset + this._import.length; - var _iterator = _createForOfIteratorHelper(symbols), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var symbol_ = _step.value; - this.assignSymbolId(symbol_); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - } - (0, _createClass2["default"])(LocalSymbolTable, [{ - key: "symbols", - get: function get() { - return this._symbols; - } - }, { - key: "maxId", - get: function get() { - return this.offset + this._symbols.length - 1; - } - }, { - key: "import", - get: function get() { - return this._import; - } - }, { - key: "getSymbolId", - value: function getSymbolId(symbol_) { - return this._import.getSymbolId(symbol_) || this.index[symbol_]; - } - }, { - key: "addSymbol", - value: function addSymbol(symbol_) { - if (symbol_ !== null) { - var existingSymbolId = this.getSymbolId(symbol_); - if (existingSymbolId !== undefined) { - return existingSymbolId; - } - } - var symbolId = this.offset + this.symbols.length; - this.symbols.push(symbol_); - if (symbol_ !== null) { - this.index[symbol_] = symbolId; - } - return symbolId; - } - }, { - key: "assignSymbolId", - value: function assignSymbolId(symbol) { - var symbolId = this.offset + this.symbols.length; - this.symbols.push(symbol); - if (symbol !== null && this.getSymbolId(symbol) === undefined) { - this.index[symbol] = symbolId; - } - return symbolId; - } - }, { - key: "getSymbolText", - value: function getSymbolText(symbolId) { - if (symbolId > this.maxId) { - throw new Error("Symbol $" + symbolId.toString() + " greater than maxID."); - } - var importedSymbol = this["import"].getSymbolText(symbolId); - if (importedSymbol !== undefined) { - return importedSymbol; - } - var index = symbolId - this.offset; - return this.symbols[index]; - } - }, { - key: "numberOfSymbols", - value: function numberOfSymbols() { - return this._symbols.length; - } - }]); - return LocalSymbolTable; -}(); + for (const symbol_ of symbols) { + this.assignSymbolId(symbol_); + } + } + get symbols() { + return this._symbols; + } + get maxId() { + return this.offset + this._symbols.length - 1; + } + get import() { + return this._import; + } + getSymbolId(symbol_) { + return this._import.getSymbolId(symbol_) || this.index[symbol_]; + } + addSymbol(symbol_) { + if (symbol_ !== null) { + const existingSymbolId = this.getSymbolId(symbol_); + if (existingSymbolId !== undefined) { + return existingSymbolId; + } + } + const symbolId = this.offset + this.symbols.length; + this.symbols.push(symbol_); + if (symbol_ !== null) { + this.index[symbol_] = symbolId; + } + return symbolId; + } + assignSymbolId(symbol) { + const symbolId = this.offset + this.symbols.length; + this.symbols.push(symbol); + if (symbol !== null && this.getSymbolId(symbol) === undefined) { + this.index[symbol] = symbolId; + } + return symbolId; + } + getSymbolText(symbolId) { + if (symbolId > this.maxId) { + throw new Error("Symbol $" + symbolId.toString() + " greater than maxID."); + } + const importedSymbol = this.import.getSymbolText(symbolId); + if (importedSymbol !== undefined) { + return importedSymbol; + } + const index = symbolId - this.offset; + return this.symbols[index]; + } + numberOfSymbols() { + return this._symbols.length; + } +} exports.LocalSymbolTable = LocalSymbolTable; function defaultLocalSymbolTable() { return new LocalSymbolTable(IonSystemSymbolTable_1.getSystemSymbolTableImport()); } exports.defaultLocalSymbolTable = defaultLocalSymbolTable; -},{"./IonSystemSymbolTable":23,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],14:[function(require,module,exports){ +},{"./IonSystemSymbolTable":23}],14:[function(require,module,exports){ "use strict"; /*! @@ -2401,154 +1935,126 @@ exports.defaultLocalSymbolTable = defaultLocalSymbolTable; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); Object.defineProperty(exports, "__esModule", { value: true }); exports.LowLevelBinaryWriter = void 0; -var BigIntSerde_1 = require("./BigIntSerde"); -var LowLevelBinaryWriter = /*#__PURE__*/function () { - function LowLevelBinaryWriter(writeable) { - (0, _classCallCheck2["default"])(this, LowLevelBinaryWriter); +const BigIntSerde_1 = require("./BigIntSerde"); +class LowLevelBinaryWriter { + constructor(writeable) { this.writeable = writeable; } - (0, _createClass2["default"])(LowLevelBinaryWriter, [{ - key: "writeSignedInt", - value: function writeSignedInt(originalValue) { - var length = LowLevelBinaryWriter.getSignedIntSize(originalValue); - var value = Math.abs(originalValue); - var tempBuf = new Uint8Array(length); - var i = tempBuf.length; - while (value >= 128) { - tempBuf[--i] = value & 0xff; - value >>>= 8; - } + static getSignedIntSize(value) { + if (value === 0) { + return 1; + } + const numberOfSignBits = 1; + const magnitude = Math.abs(value); + const numberOfMagnitudeBits = Math.ceil(Math.log2(magnitude + 1)); + const numberOfBits = numberOfMagnitudeBits + numberOfSignBits; + return Math.ceil(numberOfBits / 8); + } + static getUnsignedIntSize(value) { + if (typeof value === "bigint") { + return BigIntSerde_1.BigIntSerde.getUnsignedIntSizeInBytes(value); + } + if (value === 0) { + return 1; + } + const numberOfBits = Math.floor(Math.log2(value)) + 1; + const numberOfBytes = Math.ceil(numberOfBits / 8); + return numberOfBytes; + } + static getVariableLengthSignedIntSize(value) { + const absoluteValue = Math.abs(value); + if (absoluteValue === 0) { + return 1; + } + const valueBits = Math.floor(Math.log2(absoluteValue)) + 1; + const trailingStopBits = Math.floor(valueBits / 7); + const leadingStopBit = 1; + const signBit = 1; + return Math.ceil((valueBits + trailingStopBits + leadingStopBit + signBit) / 8); + } + static getVariableLengthUnsignedIntSize(value) { + if (value === 0) { + return 1; + } + const valueBits = Math.floor(Math.log2(value)) + 1; + const stopBits = Math.ceil(valueBits / 7); + return Math.ceil((valueBits + stopBits) / 8); + } + writeSignedInt(originalValue) { + const length = LowLevelBinaryWriter.getSignedIntSize(originalValue); + let value = Math.abs(originalValue); + const tempBuf = new Uint8Array(length); + let i = tempBuf.length; + while (value >= 128) { tempBuf[--i] = value & 0xff; - if (1 / originalValue < 0) { - tempBuf[0] |= 0x80; - } - this.writeable.writeBytes(tempBuf); + value >>>= 8; + } + tempBuf[--i] = value & 0xff; + if (1 / originalValue < 0) { + tempBuf[0] |= 0x80; + } + this.writeable.writeBytes(tempBuf); + } + writeUnsignedInt(originalValue) { + if (typeof originalValue === "bigint") { + const encodedBytes = BigIntSerde_1.BigIntSerde.toUnsignedIntBytes(originalValue); + this.writeable.writeBytes(encodedBytes); + return; + } + const length = LowLevelBinaryWriter.getUnsignedIntSize(originalValue); + const tempBuf = new Uint8Array(length); + let value = originalValue; + let i = tempBuf.length; + while (value > 0) { + tempBuf[--i] = value % 256; + value = Math.trunc(value / 256); + } + this.writeable.writeBytes(tempBuf); + } + writeVariableLengthSignedInt(originalValue) { + const tempBuf = new Uint8Array(LowLevelBinaryWriter.getVariableLengthSignedIntSize(originalValue)); + let value = Math.abs(originalValue); + let i = tempBuf.length - 1; + while (value >= 64) { + tempBuf[i--] = value & 0x7f; + value >>>= 7; } - }, { - key: "writeUnsignedInt", - value: function writeUnsignedInt(originalValue) { - if (typeof originalValue === "bigint") { - var encodedBytes = BigIntSerde_1.BigIntSerde.toUnsignedIntBytes(originalValue); - this.writeable.writeBytes(encodedBytes); - return; - } - var length = LowLevelBinaryWriter.getUnsignedIntSize(originalValue); - var tempBuf = new Uint8Array(length); - var value = originalValue; - var i = tempBuf.length; - while (value > 0) { - tempBuf[--i] = value % 256; - value = Math.trunc(value / 256); - } - this.writeable.writeBytes(tempBuf); - } - }, { - key: "writeVariableLengthSignedInt", - value: function writeVariableLengthSignedInt(originalValue) { - var tempBuf = new Uint8Array(LowLevelBinaryWriter.getVariableLengthSignedIntSize(originalValue)); - var value = Math.abs(originalValue); - var i = tempBuf.length - 1; - while (value >= 64) { - tempBuf[i--] = value & 0x7f; - value >>>= 7; - } - tempBuf[i] = value; - if (1 / originalValue < 0) { - tempBuf[i] |= 0x40; - } - tempBuf[tempBuf.length - 1] |= 0x80; - this.writeable.writeBytes(tempBuf); - } - }, { - key: "writeVariableLengthUnsignedInt", - value: function writeVariableLengthUnsignedInt(originalValue) { - var tempBuf = new Uint8Array(LowLevelBinaryWriter.getVariableLengthUnsignedIntSize(originalValue)); - var value = originalValue; - var i = tempBuf.length; - tempBuf[--i] = value & 0x7f | 0x80; + tempBuf[i] = value; + if (1 / originalValue < 0) { + tempBuf[i] |= 0x40; + } + tempBuf[tempBuf.length - 1] |= 0x80; + this.writeable.writeBytes(tempBuf); + } + writeVariableLengthUnsignedInt(originalValue) { + const tempBuf = new Uint8Array(LowLevelBinaryWriter.getVariableLengthUnsignedIntSize(originalValue)); + let value = originalValue; + let i = tempBuf.length; + tempBuf[--i] = value & 0x7f | 0x80; + value >>>= 7; + while (value > 0) { + tempBuf[--i] = value & 0x7f; value >>>= 7; - while (value > 0) { - tempBuf[--i] = value & 0x7f; - value >>>= 7; - } - this.writeable.writeBytes(tempBuf); - } - }, { - key: "writeByte", - value: function writeByte(_byte) { - this.writeable.writeByte(_byte); - } - }, { - key: "writeBytes", - value: function writeBytes(bytes) { - this.writeable.writeBytes(bytes); - } - }, { - key: "getBytes", - value: function getBytes() { - return this.writeable.getBytes(); - } - }], [{ - key: "getSignedIntSize", - value: function getSignedIntSize(value) { - if (value === 0) { - return 1; - } - var numberOfSignBits = 1; - var magnitude = Math.abs(value); - var numberOfMagnitudeBits = Math.ceil(Math.log2(magnitude + 1)); - var numberOfBits = numberOfMagnitudeBits + numberOfSignBits; - return Math.ceil(numberOfBits / 8); - } - }, { - key: "getUnsignedIntSize", - value: function getUnsignedIntSize(value) { - if (typeof value === "bigint") { - return BigIntSerde_1.BigIntSerde.getUnsignedIntSizeInBytes(value); - } - if (value === 0) { - return 1; - } - var numberOfBits = Math.floor(Math.log2(value)) + 1; - var numberOfBytes = Math.ceil(numberOfBits / 8); - return numberOfBytes; - } - }, { - key: "getVariableLengthSignedIntSize", - value: function getVariableLengthSignedIntSize(value) { - var absoluteValue = Math.abs(value); - if (absoluteValue === 0) { - return 1; - } - var valueBits = Math.floor(Math.log2(absoluteValue)) + 1; - var trailingStopBits = Math.floor(valueBits / 7); - var leadingStopBit = 1; - var signBit = 1; - return Math.ceil((valueBits + trailingStopBits + leadingStopBit + signBit) / 8); - } - }, { - key: "getVariableLengthUnsignedIntSize", - value: function getVariableLengthUnsignedIntSize(value) { - if (value === 0) { - return 1; - } - var valueBits = Math.floor(Math.log2(value)) + 1; - var stopBits = Math.ceil(valueBits / 7); - return Math.ceil((valueBits + stopBits) / 8); - } - }]); - return LowLevelBinaryWriter; -}(); + } + this.writeable.writeBytes(tempBuf); + } + writeByte(byte) { + this.writeable.writeByte(byte); + } + writeBytes(bytes) { + this.writeable.writeBytes(bytes); + } + getBytes() { + return this.writeable.getBytes(); + } +} exports.LowLevelBinaryWriter = LowLevelBinaryWriter; -},{"./BigIntSerde":2,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],15:[function(require,module,exports){ +},{"./BigIntSerde":2}],15:[function(require,module,exports){ "use strict"; /*! @@ -2565,15 +2071,11 @@ exports.LowLevelBinaryWriter = LowLevelBinaryWriter; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, - get: function get() { + get: function () { return m[k]; } }); @@ -2605,16 +2107,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.ParserBinaryRaw = void 0; -var BigIntSerde_1 = require("./BigIntSerde"); -var IonBinary = __importStar(require("./IonBinary")); -var IonConstants_1 = require("./IonConstants"); -var IonDecimal_1 = require("./IonDecimal"); -var IonTimestamp_1 = require("./IonTimestamp"); -var IonTypes_1 = require("./IonTypes"); -var IonUnicode_1 = require("./IonUnicode"); -var SignAndMagnitudeInt_1 = __importDefault(require("./SignAndMagnitudeInt")); -var EOF = -1; -var TB_DATAGRAM = 20; +const BigIntSerde_1 = require("./BigIntSerde"); +const IonBinary = __importStar(require("./IonBinary")); +const IonConstants_1 = require("./IonConstants"); +const IonDecimal_1 = require("./IonDecimal"); +const IonTimestamp_1 = require("./IonTimestamp"); +const IonTypes_1 = require("./IonTypes"); +const IonUnicode_1 = require("./IonUnicode"); +const SignAndMagnitudeInt_1 = __importDefault(require("./SignAndMagnitudeInt")); +const EOF = -1; +const TB_DATAGRAM = 20; function get_ion_type(rt) { switch (rt) { case IonBinary.TB_NULL: @@ -2649,29 +2151,29 @@ function get_ion_type(rt) { throw new Error("Unrecognized type code " + rt); } } -var VINT_SHIFT = 7; -var VINT_MASK = 0x7f; -var VINT_FLAG = 0x80; +const VINT_SHIFT = 7; +const VINT_MASK = 0x7f; +const VINT_FLAG = 0x80; function high_nibble(tb) { return tb >> IonBinary.TYPE_SHIFT & IonBinary.NIBBLE_MASK; } function low_nibble(tb) { return tb & IonBinary.NIBBLE_MASK; } -var empty_array = []; -var ivm_sid = IonConstants_1.IVM.sid; -var ivm_image_0 = IonConstants_1.IVM.binary[0]; -var ivm_image_1 = IonConstants_1.IVM.binary[1]; -var ivm_image_2 = IonConstants_1.IVM.binary[2]; -var ivm_image_3 = IonConstants_1.IVM.binary[3]; -var EncodingContainer = /*#__PURE__*/(0, _createClass2["default"])(function EncodingContainer(type, length) { - (0, _classCallCheck2["default"])(this, EncodingContainer); - this.type = type; - this.length = length; -}); -var ParserBinaryRaw = /*#__PURE__*/function () { - function ParserBinaryRaw(source) { - (0, _classCallCheck2["default"])(this, ParserBinaryRaw); +const empty_array = []; +const ivm_sid = IonConstants_1.IVM.sid; +const ivm_image_0 = IonConstants_1.IVM.binary[0]; +const ivm_image_1 = IonConstants_1.IVM.binary[1]; +const ivm_image_2 = IonConstants_1.IVM.binary[2]; +const ivm_image_3 = IonConstants_1.IVM.binary[3]; +class EncodingContainer { + constructor(type, length) { + this.type = type; + this.length = length; + } +} +class ParserBinaryRaw { + constructor(source) { this._raw_type = EOF; this._len = -1; this._curr = undefined; @@ -2684,655 +2186,564 @@ var ParserBinaryRaw = /*#__PURE__*/function () { this._in_struct = false; this._in = source; } - (0, _createClass2["default"])(ParserBinaryRaw, [{ - key: "source", - value: function source() { - return this._in; - } - }, { - key: "next", - value: function next() { - if (this._curr === undefined && this._len > 0) { - this._in.skip(this._len); - } - this.clear_value(); - if (this._in_struct) { - this._fid = this.readVarUnsignedInt(); - } - return this.load_next(); - } - }, { - key: "stepIn", - value: function stepIn() { - var len, ts; - var t = this; - switch (t._raw_type) { - case IonBinary.TB_STRUCT: - case IonBinary.TB_LIST: - case IonBinary.TB_SEXP: - break; - default: - throw new Error("you can only 'stepIn' to a container"); + static _readFloatFrom(input, numberOfBytes) { + let tempBuf; + switch (numberOfBytes) { + case 0: + return 0.0; + case 4: + tempBuf = new DataView(input.chunk(4).buffer); + return tempBuf.getFloat32(0, false); + case 8: + tempBuf = new DataView(input.chunk(8).buffer); + return tempBuf.getFloat64(0, false); + case 15: + return null; + default: + throw new Error("Illegal float length: " + numberOfBytes); + } + } + static _readVarUnsignedIntFrom(input) { + let numberOfBits = 0; + let byte; + let magnitude = 0; + while (true) { + byte = input.next(); + magnitude = magnitude << 7 | byte & 0x7f; + numberOfBits += 7; + if (byte & 0x80) { + break; } - len = t._in.getRemaining() - t._len; - ts = new EncodingContainer(t._raw_type, len); - t._ts.push(ts); - t._in_struct = t._raw_type === IonBinary.TB_STRUCT; - t._in.setRemaining(t._len); - t.clear_value(); } - }, { - key: "stepOut", - value: function stepOut() { - var parent_type, ts, l, r; - var t = this; - if (t._ts.length < 2) { - throw new Error("Cannot stepOut any further, already at top level"); - } - ts = t._ts.pop(); - l = ts.length; - parent_type = t._ts[t._ts.length - 1].type; - t._in_struct = parent_type === IonBinary.TB_STRUCT; - t.clear_value(); - r = t._in.getRemaining(); - t._in.skip(r); - t._in.setRemaining(l); - } - }, { - key: "isNull", - value: function isNull() { - return this._null; - } - }, { - key: "depth", - value: function depth() { - return this._ts.length - 1; - } - }, { - key: "getFieldId", - value: function getFieldId() { - return this._fid; - } - }, { - key: "hasAnnotations", - value: function hasAnnotations() { - return this._as >= 0; - } - }, { - key: "getAnnotations", - value: function getAnnotations() { - var t = this; - if (t._a === undefined || t._a.length === 0) { - t.load_annotation_values(); - } - return t._a; - } - }, { - key: "getAnnotation", - value: function getAnnotation(index) { - var t = this; - if (t._a === undefined || t._a.length === 0) { - t.load_annotation_values(); - } - return t._a[index]; - } - }, { - key: "ionType", - value: function ionType() { - return get_ion_type(this._raw_type); - } - }, { - key: "_getSid", - value: function _getSid() { - this.load_value(); - if (this._raw_type == IonBinary.TB_SYMBOL) { - return this._curr === undefined || this._curr === null ? null : this._curr; - } - return null; + if (numberOfBits > 31) { + throw new Error("VarUInt values larger than 31 bits must be read using SignAndMagnitudeInt."); + } + return magnitude; + } + static _readVarSignedIntFrom(input) { + let v = input.next(), + byte; + const isNegative = v & 0x40; + let stopBit = v & 0x80; + v &= 0x3f; + let bits = 6; + while (!stopBit) { + byte = input.next(); + stopBit = byte & 0x80; + byte &= 0x7f; + v <<= 7; + v |= byte; + bits += 7; + } + if (bits > 32) { + throw new Error("VarInt values larger than 32 bits must be read using SignAndMagnitudeInt"); + } + return isNegative ? -v : v; + } + static _readSignedIntFrom(input, numberOfBytes) { + if (numberOfBytes == 0) { + return new SignAndMagnitudeInt_1.default(0n); + } + const bytes = input.view(numberOfBytes); + const isNegative = (bytes[0] & 0x80) == 0x80; + const numbers = Array.prototype.slice.call(bytes); + numbers[0] = bytes[0] & 0x7f; + const magnitude = BigIntSerde_1.BigIntSerde.fromUnsignedBytes(numbers); + return new SignAndMagnitudeInt_1.default(magnitude, isNegative); + } + static _readUnsignedIntAsBigIntFrom(input, numberOfBytes) { + return BigIntSerde_1.BigIntSerde.fromUnsignedBytes(Array.prototype.slice.call(input.view(numberOfBytes))); + } + static _readUnsignedIntAsNumberFrom(input, numberOfBytes) { + let value = 0; + let bytesRead = 0; + const bytesAvailable = input.getRemaining(); + let byte; + if (numberOfBytes < 1) { + return 0; + } else if (numberOfBytes > 6) { + throw new Error(`Attempted to read a ${numberOfBytes}-byte unsigned integer,` + ` which is too large for a to be stored in a number without losing precision.`); } - }, { - key: "byteValue", - value: function byteValue() { - return this.uInt8ArrayValue(); + if (bytesAvailable < numberOfBytes) { + throw new Error(`Attempted to read a ${numberOfBytes}-byte unsigned integer,` + ` but only ${bytesAvailable} bytes were available.`); } - }, { - key: "uInt8ArrayValue", - value: function uInt8ArrayValue() { - switch (this._raw_type) { - case IonBinary.TB_NULL: - return null; - case IonBinary.TB_CLOB: - case IonBinary.TB_BLOB: - if (this.isNull()) { - return null; - } - this.load_value(); - return this._curr; - default: - throw new Error("Current value is not a blob or clob."); - } + while (bytesRead < numberOfBytes) { + byte = input.next(); + bytesRead++; + if (numberOfBytes < 4) { + value <<= 8; + } else { + value *= 256; + } + value = value + byte; + } + return value; + } + static readDecimalValueFrom(input, numberOfBytes) { + const initialPosition = input.position(); + const exponent = ParserBinaryRaw._readVarSignedIntFrom(input); + const numberOfExponentBytes = input.position() - initialPosition; + const numberOfCoefficientBytes = numberOfBytes - numberOfExponentBytes; + const signedInt = ParserBinaryRaw._readSignedIntFrom(input, numberOfCoefficientBytes); + const isNegative = signedInt.isNegative; + const coefficient = isNegative ? -signedInt.magnitude : signedInt.magnitude; + return IonDecimal_1.Decimal._fromBigIntCoefficient(isNegative, coefficient, exponent); + } + source() { + return this._in; + } + next() { + if (this._curr === undefined && this._len > 0) { + this._in.skip(this._len); + } + this.clear_value(); + if (this._in_struct) { + this._fid = this.readVarUnsignedInt(); + } + return this.load_next(); + } + stepIn() { + let len, ts; + const t = this; + switch (t._raw_type) { + case IonBinary.TB_STRUCT: + case IonBinary.TB_LIST: + case IonBinary.TB_SEXP: + break; + default: + throw new Error("you can only 'stepIn' to a container"); } - }, { - key: "booleanValue", - value: function booleanValue() { - switch (this._raw_type) { - case IonBinary.TB_NULL: + len = t._in.getRemaining() - t._len; + ts = new EncodingContainer(t._raw_type, len); + t._ts.push(ts); + t._in_struct = t._raw_type === IonBinary.TB_STRUCT; + t._in.setRemaining(t._len); + t.clear_value(); + } + stepOut() { + let parent_type, ts, l, r; + const t = this; + if (t._ts.length < 2) { + throw new Error("Cannot stepOut any further, already at top level"); + } + ts = t._ts.pop(); + l = ts.length; + parent_type = t._ts[t._ts.length - 1].type; + t._in_struct = parent_type === IonBinary.TB_STRUCT; + t.clear_value(); + r = t._in.getRemaining(); + t._in.skip(r); + t._in.setRemaining(l); + } + isNull() { + return this._null; + } + depth() { + return this._ts.length - 1; + } + getFieldId() { + return this._fid; + } + hasAnnotations() { + return this._as >= 0; + } + getAnnotations() { + const t = this; + if (t._a === undefined || t._a.length === 0) { + t.load_annotation_values(); + } + return t._a; + } + getAnnotation(index) { + const t = this; + if (t._a === undefined || t._a.length === 0) { + t.load_annotation_values(); + } + return t._a[index]; + } + ionType() { + return get_ion_type(this._raw_type); + } + _getSid() { + this.load_value(); + if (this._raw_type == IonBinary.TB_SYMBOL) { + return this._curr === undefined || this._curr === null ? null : this._curr; + } + return null; + } + byteValue() { + return this.uInt8ArrayValue(); + } + uInt8ArrayValue() { + switch (this._raw_type) { + case IonBinary.TB_NULL: + return null; + case IonBinary.TB_CLOB: + case IonBinary.TB_BLOB: + if (this.isNull()) { return null; - case IonBinary.TB_BOOL: - if (this.isNull()) { - return null; - } - return this._curr; - } - throw new Error("Current value is not a Boolean."); + } + this.load_value(); + return this._curr; + default: + throw new Error("Current value is not a blob or clob."); } - }, { - key: "decimalValue", - value: function decimalValue() { - switch (this._raw_type) { - case IonBinary.TB_NULL: + } + booleanValue() { + switch (this._raw_type) { + case IonBinary.TB_NULL: + return null; + case IonBinary.TB_BOOL: + if (this.isNull()) { return null; - case IonBinary.TB_DECIMAL: - if (this.isNull()) { - return null; - } - this.load_value(); - return this._curr; - } - throw new Error("Current value is not a decimal."); + } + return this._curr; } - }, { - key: "bigIntValue", - value: function bigIntValue() { - switch (this._raw_type) { - case IonBinary.TB_NULL: + throw new Error("Current value is not a Boolean."); + } + decimalValue() { + switch (this._raw_type) { + case IonBinary.TB_NULL: + return null; + case IonBinary.TB_DECIMAL: + if (this.isNull()) { return null; - case IonBinary.TB_INT: - case IonBinary.TB_NEG_INT: - if (this.isNull()) { - return null; - } - this.load_value(); - if (!(typeof this._curr === "bigint")) { - var num = this._curr; - return BigInt(num); - } - return this._curr; - default: - throw new Error("bigIntValue() was called when the current value was not an int."); - } + } + this.load_value(); + return this._curr; } - }, { - key: "numberValue", - value: function numberValue() { - switch (this._raw_type) { - case IonBinary.TB_NULL: + throw new Error("Current value is not a decimal."); + } + bigIntValue() { + switch (this._raw_type) { + case IonBinary.TB_NULL: + return null; + case IonBinary.TB_INT: + case IonBinary.TB_NEG_INT: + if (this.isNull()) { return null; - case IonBinary.TB_INT: - case IonBinary.TB_NEG_INT: - if (this.isNull()) { - return null; - } - this.load_value(); - if (typeof this._curr === "bigint") { - var bigInt = this._curr; - return Number(bigInt); - } - return this._curr; - case IonBinary.TB_FLOAT: - if (this.isNull()) { - return null; - } - this.load_value(); - return this._curr; - default: - throw new Error("Current value is not a float or int."); - } + } + this.load_value(); + if (!(typeof this._curr === "bigint")) { + const num = this._curr; + return BigInt(num); + } + return this._curr; + default: + throw new Error("bigIntValue() was called when the current value was not an int."); } - }, { - key: "stringValue", - value: function stringValue() { - switch (this._raw_type) { - case IonBinary.TB_NULL: + } + numberValue() { + switch (this._raw_type) { + case IonBinary.TB_NULL: + return null; + case IonBinary.TB_INT: + case IonBinary.TB_NEG_INT: + if (this.isNull()) { return null; - case IonBinary.TB_STRING: - case IonBinary.TB_SYMBOL: - if (this.isNull()) { - return null; - } - this.load_value(); - return this._curr; - } - throw new Error("Current value is not a string or symbol."); + } + this.load_value(); + if (typeof this._curr === "bigint") { + const bigInt = this._curr; + return Number(bigInt); + } + return this._curr; + case IonBinary.TB_FLOAT: + if (this.isNull()) { + return null; + } + this.load_value(); + return this._curr; + default: + throw new Error("Current value is not a float or int."); } - }, { - key: "timestampValue", - value: function timestampValue() { - switch (this._raw_type) { - case IonBinary.TB_NULL: + } + stringValue() { + switch (this._raw_type) { + case IonBinary.TB_NULL: + return null; + case IonBinary.TB_STRING: + case IonBinary.TB_SYMBOL: + if (this.isNull()) { return null; - case IonBinary.TB_TIMESTAMP: - if (this.isNull()) { - return null; - } - this.load_value(); - return this._curr; - } - throw new Error("Current value is not a timestamp."); - } - }, { - key: "read_binary_float", - value: function read_binary_float() { - return ParserBinaryRaw._readFloatFrom(this._in, this._len); - } - }, { - key: "readVarUnsignedInt", - value: function readVarUnsignedInt() { - return ParserBinaryRaw._readVarUnsignedIntFrom(this._in); - } - }, { - key: "readVarSignedInt", - value: function readVarSignedInt() { - return ParserBinaryRaw._readVarSignedIntFrom(this._in); - } - }, { - key: "readUnsignedIntAsBigInt", - value: function readUnsignedIntAsBigInt() { - return ParserBinaryRaw._readUnsignedIntAsBigIntFrom(this._in, this._len); - } - }, { - key: "readUnsignedIntAsNumber", - value: function readUnsignedIntAsNumber() { - return ParserBinaryRaw._readUnsignedIntAsNumberFrom(this._in, this._len); - } - }, { - key: "read_decimal_value", - value: function read_decimal_value() { - return ParserBinaryRaw.readDecimalValueFrom(this._in, this._len); - } - }, { - key: "read_timestamp_value", - value: function read_timestamp_value() { - if (!(this._len > 0)) { + } + this.load_value(); + return this._curr; + } + throw new Error("Current value is not a string or symbol."); + } + timestampValue() { + switch (this._raw_type) { + case IonBinary.TB_NULL: return null; - } - var offset; - var year; - var month = null; - var day = null; - var hour = null; - var minute = null; - var secondInt = null; - var fractionalSeconds = IonDecimal_1.Decimal.ZERO; - var precision = IonTimestamp_1.TimestampPrecision.YEAR; - var end = this._in.position() + this._len; - offset = this.readVarSignedInt(); - if (this._in.position() < end) { - year = this.readVarUnsignedInt(); - } else { - throw new Error("Timestamps must include a year."); - } - if (this._in.position() < end) { - month = this.readVarUnsignedInt(); - precision = IonTimestamp_1.TimestampPrecision.MONTH; - } - if (this._in.position() < end) { - day = this.readVarUnsignedInt(); - precision = IonTimestamp_1.TimestampPrecision.DAY; - } - if (this._in.position() < end) { - hour = this.readVarUnsignedInt(); - if (this._in.position() >= end) { - throw new Error("Timestamps with an hour must include a minute."); - } else { - minute = this.readVarUnsignedInt(); + case IonBinary.TB_TIMESTAMP: + if (this.isNull()) { + return null; } - precision = IonTimestamp_1.TimestampPrecision.HOUR_AND_MINUTE; - } - if (this._in.position() < end) { - secondInt = this.readVarUnsignedInt(); - precision = IonTimestamp_1.TimestampPrecision.SECONDS; + this.load_value(); + return this._curr; + } + throw new Error("Current value is not a timestamp."); + } + read_binary_float() { + return ParserBinaryRaw._readFloatFrom(this._in, this._len); + } + readVarUnsignedInt() { + return ParserBinaryRaw._readVarUnsignedIntFrom(this._in); + } + readVarSignedInt() { + return ParserBinaryRaw._readVarSignedIntFrom(this._in); + } + readUnsignedIntAsBigInt() { + return ParserBinaryRaw._readUnsignedIntAsBigIntFrom(this._in, this._len); + } + readUnsignedIntAsNumber() { + return ParserBinaryRaw._readUnsignedIntAsNumberFrom(this._in, this._len); + } + read_decimal_value() { + return ParserBinaryRaw.readDecimalValueFrom(this._in, this._len); + } + read_timestamp_value() { + if (!(this._len > 0)) { + return null; + } + let offset; + let year; + let month = null; + let day = null; + let hour = null; + let minute = null; + let secondInt = null; + let fractionalSeconds = IonDecimal_1.Decimal.ZERO; + let precision = IonTimestamp_1.TimestampPrecision.YEAR; + const end = this._in.position() + this._len; + offset = this.readVarSignedInt(); + if (this._in.position() < end) { + year = this.readVarUnsignedInt(); + } else { + throw new Error("Timestamps must include a year."); + } + if (this._in.position() < end) { + month = this.readVarUnsignedInt(); + precision = IonTimestamp_1.TimestampPrecision.MONTH; + } + if (this._in.position() < end) { + day = this.readVarUnsignedInt(); + precision = IonTimestamp_1.TimestampPrecision.DAY; + } + if (this._in.position() < end) { + hour = this.readVarUnsignedInt(); + if (this._in.position() >= end) { + throw new Error("Timestamps with an hour must include a minute."); + } else { + minute = this.readVarUnsignedInt(); } + precision = IonTimestamp_1.TimestampPrecision.HOUR_AND_MINUTE; + } + if (this._in.position() < end) { + secondInt = this.readVarUnsignedInt(); + precision = IonTimestamp_1.TimestampPrecision.SECONDS; + } + if (this._in.position() < end) { + const exponent = this.readVarSignedInt(); + let coefficient = 0n; + let isNegative = false; if (this._in.position() < end) { - var exponent = this.readVarSignedInt(); - var coefficient = 0n; - var isNegative = false; - if (this._in.position() < end) { - var deserializedSignedInt = ParserBinaryRaw._readSignedIntFrom(this._in, end - this._in.position()); - isNegative = deserializedSignedInt._isNegative; - coefficient = deserializedSignedInt._magnitude; - } - var dec = IonDecimal_1.Decimal._fromBigIntCoefficient(isNegative, coefficient, exponent); - var _IonTimestamp_1$Times = IonTimestamp_1.Timestamp._splitSecondsDecimal(dec), - _IonTimestamp_1$Times2 = (0, _slicedToArray2["default"])(_IonTimestamp_1$Times, 2), - _ = _IonTimestamp_1$Times2[0], - fractionStr = _IonTimestamp_1$Times2[1]; - fractionalSeconds = IonDecimal_1.Decimal.parse(secondInt + "." + fractionStr); - } - var msSinceEpoch = Date.UTC(year, month ? month - 1 : 0, day ? day : 1, hour ? hour : 0, minute ? minute : 0, secondInt ? secondInt : 0, 0); - msSinceEpoch = IonTimestamp_1.Timestamp._adjustMsSinceEpochIfNeeded(year, msSinceEpoch); - var date = new Date(msSinceEpoch); - return IonTimestamp_1.Timestamp._valueOf(date, offset, fractionalSeconds, precision); - } - }, { - key: "read_string_value", - value: function read_string_value() { - return IonUnicode_1.decodeUtf8(this._in.chunk(this._len)); - } - }, { - key: "clear_value", - value: function clear_value() { - this._raw_type = EOF; - this._curr = undefined; - this._a = empty_array; - this._as = -1; - this._null = false; - this._fid = null; - this._len = -1; - } - }, { - key: "load_length", - value: function load_length(tb) { - var t = this; - t._len = low_nibble(tb); - switch (t._len) { - case 1: - if (high_nibble(tb) === IonBinary.TB_STRUCT) { - t._len = this.readVarUnsignedInt(); - } - t._null = false; - break; - case IonBinary.LEN_VAR: - t._null = false; - t._len = this.readVarUnsignedInt(); - break; - case IonBinary.LEN_NULL: - t._null = true; - t._len = 0; - break; - default: - t._null = false; - break; + const deserializedSignedInt = ParserBinaryRaw._readSignedIntFrom(this._in, end - this._in.position()); + isNegative = deserializedSignedInt._isNegative; + coefficient = deserializedSignedInt._magnitude; } + const dec = IonDecimal_1.Decimal._fromBigIntCoefficient(isNegative, coefficient, exponent); + const [_, fractionStr] = IonTimestamp_1.Timestamp._splitSecondsDecimal(dec); + fractionalSeconds = IonDecimal_1.Decimal.parse(secondInt + "." + fractionStr); } - }, { - key: "load_next", - value: function load_next() { - var t = this; - var rt, tb; - t._as = -1; - if (t._in.is_empty()) { - t.clear_value(); - return undefined; - } - tb = t._in.next(); - rt = high_nibble(tb); - t.load_length(tb); - if (rt === IonBinary.TB_ANNOTATION) { - if (t._len < 1 && t.depth() === 0) { - rt = t.load_ivm(); - } else { - rt = t.load_annotations(); + let msSinceEpoch = Date.UTC(year, month ? month - 1 : 0, day ? day : 1, hour ? hour : 0, minute ? minute : 0, secondInt ? secondInt : 0, 0); + msSinceEpoch = IonTimestamp_1.Timestamp._adjustMsSinceEpochIfNeeded(year, msSinceEpoch); + const date = new Date(msSinceEpoch); + return IonTimestamp_1.Timestamp._valueOf(date, offset, fractionalSeconds, precision); + } + read_string_value() { + return IonUnicode_1.decodeUtf8(this._in.chunk(this._len)); + } + clear_value() { + this._raw_type = EOF; + this._curr = undefined; + this._a = empty_array; + this._as = -1; + this._null = false; + this._fid = null; + this._len = -1; + } + load_length(tb) { + const t = this; + t._len = low_nibble(tb); + switch (t._len) { + case 1: + if (high_nibble(tb) === IonBinary.TB_STRUCT) { + t._len = this.readVarUnsignedInt(); } - } - switch (rt) { - case IonBinary.TB_NULL: - t._null = true; - break; - case IonBinary.TB_BOOL: - if (t._len === 0 || t._len === 1) { - t._curr = t._len === 1; - t._len = 0; - } - break; - } - t._raw_type = rt; - return rt; + t._null = false; + break; + case IonBinary.LEN_VAR: + t._null = false; + t._len = this.readVarUnsignedInt(); + break; + case IonBinary.LEN_NULL: + t._null = true; + t._len = 0; + break; + default: + t._null = false; + break; + } + } + load_next() { + const t = this; + let rt, tb; + t._as = -1; + if (t._in.is_empty()) { + t.clear_value(); + return undefined; } - }, { - key: "load_annotations", - value: function load_annotations() { - var t = this; - var tb, type_, annotation_len; + tb = t._in.next(); + rt = high_nibble(tb); + t.load_length(tb); + if (rt === IonBinary.TB_ANNOTATION) { if (t._len < 1 && t.depth() === 0) { - type_ = t.load_ivm(); + rt = t.load_ivm(); } else { - annotation_len = this.readVarUnsignedInt(); - t._as = t._in.position(); - t._in.skip(annotation_len); - t._ae = t._in.position(); - tb = t._in.next(); - t.load_length(tb); - type_ = high_nibble(tb); - } - return type_; - } - }, { - key: "load_ivm", - value: function load_ivm() { - var t = this; - var span = t._in; - if (span.next() !== ivm_image_1) { - throw new Error("invalid binary Ion at " + span.position()); - } - if (span.next() !== ivm_image_2) { - throw new Error("invalid binary Ion at " + span.position()); - } - if (span.next() !== ivm_image_3) { - throw new Error("invalid binary Ion at " + span.position()); - } - t._curr = ivm_sid; - t._len = 0; - return IonBinary.TB_SYMBOL; - } - }, { - key: "load_annotation_values", - value: function load_annotation_values() { - var t = this; - var a, b, pos, limit, arr; - if ((pos = t._as) < 0) { - return; + rt = t.load_annotations(); } - arr = []; - limit = t._ae; - a = 0; - while (pos < limit) { - b = t._in.valueAt(pos); - pos++; - a = a << VINT_SHIFT | b & VINT_MASK; - if ((b & VINT_FLAG) !== 0) { - if (a === 0) { - throw new Error("Symbol ID zero is unsupported."); - } - arr.push(a); - a = 0; + } + switch (rt) { + case IonBinary.TB_NULL: + t._null = true; + break; + case IonBinary.TB_BOOL: + if (t._len === 0 || t._len === 1) { + t._curr = t._len === 1; + t._len = 0; } - } - t._a = arr; + break; } - }, { - key: "_readIntegerMagnitude", - value: function _readIntegerMagnitude() { - if (this._len === 0) { - return 0n; - } - if (this._len < 6) { - return this.readUnsignedIntAsNumber(); - } - return this.readUnsignedIntAsBigInt(); + t._raw_type = rt; + return rt; + } + load_annotations() { + const t = this; + let tb, type_, annotation_len; + if (t._len < 1 && t.depth() === 0) { + type_ = t.load_ivm(); + } else { + annotation_len = this.readVarUnsignedInt(); + t._as = t._in.position(); + t._in.skip(annotation_len); + t._ae = t._in.position(); + tb = t._in.next(); + t.load_length(tb); + type_ = high_nibble(tb); } - }, { - key: "load_value", - value: function load_value() { - if (this._curr != undefined) { - return; - } - if (this.isNull()) { - return; - } - switch (this._raw_type) { - case IonBinary.TB_BOOL: - break; - case IonBinary.TB_INT: - this._curr = this._readIntegerMagnitude(); - break; - case IonBinary.TB_NEG_INT: - var value = this._readIntegerMagnitude(); - this._curr = typeof value === "bigint" ? -value : -value; - break; - case IonBinary.TB_FLOAT: - this._curr = this.read_binary_float(); - break; - case IonBinary.TB_DECIMAL: - if (this._len === 0) { - this._curr = IonDecimal_1.Decimal.ZERO; - } else { - this._curr = this.read_decimal_value(); - } - break; - case IonBinary.TB_TIMESTAMP: - this._curr = this.read_timestamp_value(); - break; - case IonBinary.TB_SYMBOL: - this._curr = this.readUnsignedIntAsNumber(); - break; - case IonBinary.TB_STRING: - this._curr = this.read_string_value(); - break; - case IonBinary.TB_CLOB: - case IonBinary.TB_BLOB: - if (this.isNull()) { - break; - } - this._curr = this._in.chunk(this._len); - break; - default: - throw new Error("Unexpected type: " + this._raw_type); - } - } - }], [{ - key: "_readFloatFrom", - value: function _readFloatFrom(input, numberOfBytes) { - var tempBuf; - switch (numberOfBytes) { - case 0: - return 0.0; - case 4: - tempBuf = new DataView(input.chunk(4).buffer); - return tempBuf.getFloat32(0, false); - case 8: - tempBuf = new DataView(input.chunk(8).buffer); - return tempBuf.getFloat64(0, false); - case 15: - return null; - default: - throw new Error("Illegal float length: " + numberOfBytes); - } + return type_; + } + load_ivm() { + const t = this; + const span = t._in; + if (span.next() !== ivm_image_1) { + throw new Error("invalid binary Ion at " + span.position()); } - }, { - key: "_readVarUnsignedIntFrom", - value: function _readVarUnsignedIntFrom(input) { - var numberOfBits = 0; - var _byte; - var magnitude = 0; - while (true) { - _byte = input.next(); - magnitude = magnitude << 7 | _byte & 0x7f; - numberOfBits += 7; - if (_byte & 0x80) { - break; + if (span.next() !== ivm_image_2) { + throw new Error("invalid binary Ion at " + span.position()); + } + if (span.next() !== ivm_image_3) { + throw new Error("invalid binary Ion at " + span.position()); + } + t._curr = ivm_sid; + t._len = 0; + return IonBinary.TB_SYMBOL; + } + load_annotation_values() { + const t = this; + let a, b, pos, limit, arr; + if ((pos = t._as) < 0) { + return; + } + arr = []; + limit = t._ae; + a = 0; + while (pos < limit) { + b = t._in.valueAt(pos); + pos++; + a = a << VINT_SHIFT | b & VINT_MASK; + if ((b & VINT_FLAG) !== 0) { + if (a === 0) { + throw new Error("Symbol ID zero is unsupported."); } + arr.push(a); + a = 0; } - if (numberOfBits > 31) { - throw new Error("VarUInt values larger than 31 bits must be read using SignAndMagnitudeInt."); - } - return magnitude; - } - }, { - key: "_readVarSignedIntFrom", - value: function _readVarSignedIntFrom(input) { - var v = input.next(), - _byte2; - var isNegative = v & 0x40; - var stopBit = v & 0x80; - v &= 0x3f; - var bits = 6; - while (!stopBit) { - _byte2 = input.next(); - stopBit = _byte2 & 0x80; - _byte2 &= 0x7f; - v <<= 7; - v |= _byte2; - bits += 7; - } - if (bits > 32) { - throw new Error("VarInt values larger than 32 bits must be read using SignAndMagnitudeInt"); - } - return isNegative ? -v : v; - } - }, { - key: "_readSignedIntFrom", - value: function _readSignedIntFrom(input, numberOfBytes) { - if (numberOfBytes == 0) { - return new SignAndMagnitudeInt_1["default"](0n); - } - var bytes = input.view(numberOfBytes); - var isNegative = (bytes[0] & 0x80) == 0x80; - var numbers = Array.prototype.slice.call(bytes); - numbers[0] = bytes[0] & 0x7f; - var magnitude = BigIntSerde_1.BigIntSerde.fromUnsignedBytes(numbers); - return new SignAndMagnitudeInt_1["default"](magnitude, isNegative); - } - }, { - key: "_readUnsignedIntAsBigIntFrom", - value: function _readUnsignedIntAsBigIntFrom(input, numberOfBytes) { - return BigIntSerde_1.BigIntSerde.fromUnsignedBytes(Array.prototype.slice.call(input.view(numberOfBytes))); - } - }, { - key: "_readUnsignedIntAsNumberFrom", - value: function _readUnsignedIntAsNumberFrom(input, numberOfBytes) { - var value = 0; - var bytesRead = 0; - var bytesAvailable = input.getRemaining(); - var _byte3; - if (numberOfBytes < 1) { - return 0; - } else if (numberOfBytes > 6) { - throw new Error("Attempted to read a ".concat(numberOfBytes, "-byte unsigned integer,") + " which is too large for a to be stored in a number without losing precision."); - } - if (bytesAvailable < numberOfBytes) { - throw new Error("Attempted to read a ".concat(numberOfBytes, "-byte unsigned integer,") + " but only ".concat(bytesAvailable, " bytes were available.")); - } - while (bytesRead < numberOfBytes) { - _byte3 = input.next(); - bytesRead++; - if (numberOfBytes < 4) { - value <<= 8; + } + t._a = arr; + } + _readIntegerMagnitude() { + if (this._len === 0) { + return 0n; + } + if (this._len < 6) { + return this.readUnsignedIntAsNumber(); + } + return this.readUnsignedIntAsBigInt(); + } + load_value() { + if (this._curr != undefined) { + return; + } + if (this.isNull()) { + return; + } + switch (this._raw_type) { + case IonBinary.TB_BOOL: + break; + case IonBinary.TB_INT: + this._curr = this._readIntegerMagnitude(); + break; + case IonBinary.TB_NEG_INT: + let value = this._readIntegerMagnitude(); + this._curr = typeof value === "bigint" ? -value : -value; + break; + case IonBinary.TB_FLOAT: + this._curr = this.read_binary_float(); + break; + case IonBinary.TB_DECIMAL: + if (this._len === 0) { + this._curr = IonDecimal_1.Decimal.ZERO; } else { - value *= 256; + this._curr = this.read_decimal_value(); } - value = value + _byte3; - } - return value; + break; + case IonBinary.TB_TIMESTAMP: + this._curr = this.read_timestamp_value(); + break; + case IonBinary.TB_SYMBOL: + this._curr = this.readUnsignedIntAsNumber(); + break; + case IonBinary.TB_STRING: + this._curr = this.read_string_value(); + break; + case IonBinary.TB_CLOB: + case IonBinary.TB_BLOB: + if (this.isNull()) { + break; + } + this._curr = this._in.chunk(this._len); + break; + default: + throw new Error("Unexpected type: " + this._raw_type); } - }, { - key: "readDecimalValueFrom", - value: function readDecimalValueFrom(input, numberOfBytes) { - var initialPosition = input.position(); - var exponent = ParserBinaryRaw._readVarSignedIntFrom(input); - var numberOfExponentBytes = input.position() - initialPosition; - var numberOfCoefficientBytes = numberOfBytes - numberOfExponentBytes; - var signedInt = ParserBinaryRaw._readSignedIntFrom(input, numberOfCoefficientBytes); - var isNegative = signedInt.isNegative; - var coefficient = isNegative ? -signedInt.magnitude : signedInt.magnitude; - return IonDecimal_1.Decimal._fromBigIntCoefficient(isNegative, coefficient, exponent); - } - }]); - return ParserBinaryRaw; -}(); + } +} exports.ParserBinaryRaw = ParserBinaryRaw; -},{"./BigIntSerde":2,"./IonBinary":6,"./IonConstants":10,"./IonDecimal":11,"./IonTimestamp":27,"./IonTypes":29,"./IonUnicode":30,"./SignAndMagnitudeInt":32,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/slicedToArray":77}],16:[function(require,module,exports){ +},{"./BigIntSerde":2,"./IonBinary":6,"./IonConstants":10,"./IonDecimal":11,"./IonTimestamp":27,"./IonTypes":29,"./IonUnicode":30,"./SignAndMagnitudeInt":32}],16:[function(require,module,exports){ "use strict"; /*! @@ -3349,89 +2760,86 @@ exports.ParserBinaryRaw = ParserBinaryRaw; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); Object.defineProperty(exports, "__esModule", { value: true }); exports.ParserTextRaw = exports.get_ion_type = void 0; -var IonText_1 = require("./IonText"); -var IonSymbolToken_1 = require("./IonSymbolToken"); -var IonTypes_1 = require("./IonTypes"); -var EOF = -1; -var ERROR = -2; -var T_NULL = 1; -var T_BOOL = 2; -var T_INT = 3; -var T_HEXINT = 4; -var T_FLOAT = 5; -var T_FLOAT_SPECIAL = 6; -var T_DECIMAL = 7; -var T_TIMESTAMP = 8; -var T_IDENTIFIER = 9; -var T_OPERATOR = 10; -var T_STRING1 = 11; -var T_STRING2 = 12; -var T_STRING3 = 13; -var T_CLOB2 = 14; -var T_CLOB3 = 15; -var T_BLOB = 16; -var T_SEXP = 17; -var T_LIST = 18; -var T_STRUCT = 19; -var CH_CR = 13; -var CH_NL = 10; -var CH_BS = 92; -var CH_FORWARD_SLASH = "/".charCodeAt(0); -var CH_AS = 42; -var CH_SQ = 39; -var CH_DOUBLE_QUOTE = '"'.charCodeAt(0); -var CH_CM = 44; -var CH_OP = 40; -var CH_CP = 41; -var CH_LEFT_CURLY = "{".charCodeAt(0); -var CH_CC = 125; -var CH_OS = 91; -var CH_CS = 93; -var CH_CL = 58; -var CH_DT = 46; -var CH_EQ = 61; -var CH_PS = 43; -var CH_MS = 45; -var CH_0 = 48; -var CH_D = 68; -var CH_E = 69; -var CH_F = 70; -var CH_T = 84; -var CH_X = 88; -var CH_Z = 90; -var CH_d = 100; -var CH_e = 101; -var CH_f = 102; -var CH_i = 105; -var CH_n = 110; -var CH_x = 120; -var ESC_0 = 48; -var ESC_a = 97; -var ESC_b = 98; -var ESC_t = 116; -var ESC_nl = 110; -var ESC_ff = 102; -var ESC_cr = 114; -var ESC_v = 118; -var ESC_dq = CH_DOUBLE_QUOTE; -var ESC_sq = CH_SQ; -var ESC_qm = 63; -var ESC_bs = 92; -var ESC_fs = 47; -var ESC_nl2 = 10; -var ESC_nl3 = 13; -var ESC_x = CH_x; -var ESC_u = 117; -var ESC_U = 85; -var INF = [CH_i, CH_n, CH_f]; -var _UTF16_MASK = 0x03ff; +const IonText_1 = require("./IonText"); +const IonSymbolToken_1 = require("./IonSymbolToken"); +const IonTypes_1 = require("./IonTypes"); +const EOF = -1; +const ERROR = -2; +const T_NULL = 1; +const T_BOOL = 2; +const T_INT = 3; +const T_HEXINT = 4; +const T_FLOAT = 5; +const T_FLOAT_SPECIAL = 6; +const T_DECIMAL = 7; +const T_TIMESTAMP = 8; +const T_IDENTIFIER = 9; +const T_OPERATOR = 10; +const T_STRING1 = 11; +const T_STRING2 = 12; +const T_STRING3 = 13; +const T_CLOB2 = 14; +const T_CLOB3 = 15; +const T_BLOB = 16; +const T_SEXP = 17; +const T_LIST = 18; +const T_STRUCT = 19; +const CH_CR = 13; +const CH_NL = 10; +const CH_BS = 92; +const CH_FORWARD_SLASH = "/".charCodeAt(0); +const CH_AS = 42; +const CH_SQ = 39; +const CH_DOUBLE_QUOTE = '"'.charCodeAt(0); +const CH_CM = 44; +const CH_OP = 40; +const CH_CP = 41; +const CH_LEFT_CURLY = "{".charCodeAt(0); +const CH_CC = 125; +const CH_OS = 91; +const CH_CS = 93; +const CH_CL = 58; +const CH_DT = 46; +const CH_EQ = 61; +const CH_PS = 43; +const CH_MS = 45; +const CH_0 = 48; +const CH_D = 68; +const CH_E = 69; +const CH_F = 70; +const CH_T = 84; +const CH_X = 88; +const CH_Z = 90; +const CH_d = 100; +const CH_e = 101; +const CH_f = 102; +const CH_i = 105; +const CH_n = 110; +const CH_x = 120; +const ESC_0 = 48; +const ESC_a = 97; +const ESC_b = 98; +const ESC_t = 116; +const ESC_nl = 110; +const ESC_ff = 102; +const ESC_cr = 114; +const ESC_v = 118; +const ESC_dq = CH_DOUBLE_QUOTE; +const ESC_sq = CH_SQ; +const ESC_qm = 63; +const ESC_bs = 92; +const ESC_fs = 47; +const ESC_nl2 = 10; +const ESC_nl3 = 13; +const ESC_x = CH_x; +const ESC_u = 117; +const ESC_U = 85; +const INF = [CH_i, CH_n, CH_f]; +const _UTF16_MASK = 0x03ff; function get_ion_type(t) { switch (t) { case EOF: @@ -3617,13 +3025,12 @@ function is_valid_string_char(ch, allow_new_line) { } return true; } -var ParserTextRaw = /*#__PURE__*/function () { - function ParserTextRaw(source) { - (0, _classCallCheck2["default"])(this, ParserTextRaw); +class ParserTextRaw { + constructor(source) { this._value_null = false; this._curr_null = false; this._read_value_helper_minus = function (ch1, accept_operator_symbols, calling_op) { - var op, + let op, ch2 = this._peek(); if (ch2 == CH_i) { ch2 = this._peek("inf"); @@ -3645,7 +3052,7 @@ var ParserTextRaw = /*#__PURE__*/function () { } }; this._read_string_helper = function (terminator, allow_new_line) { - var ch; + let ch; this._start = this._in.position(); for (;;) { ch = this._read(); @@ -3670,7 +3077,7 @@ var ParserTextRaw = /*#__PURE__*/function () { this._msg = ""; this._fieldname = null; this._fieldnameType = null; - var helpers = { + const helpers = { 40: this._read_value_helper_paren, 91: this._read_value_helper_square, 123: this._read_value_helper_curly, @@ -3679,8 +3086,8 @@ var ParserTextRaw = /*#__PURE__*/function () { 39: this._read_value_helper_single, 34: this._read_value_helper_double }; - var set_helper = function set_helper(str, fn) { - var i = str.length, + const set_helper = function (str, fn) { + let i = str.length, ch; while (i > 0) { i--; @@ -3695,266 +3102,284 @@ var ParserTextRaw = /*#__PURE__*/function () { helpers[CH_MS] = this._read_value_helper_minus; this._read_value_helper_helpers = helpers; } - (0, _createClass2["default"])(ParserTextRaw, [{ - key: "fieldName", - value: function fieldName() { - return this._fieldname; - } - }, { - key: "fieldNameType", - value: function fieldNameType() { - return this._fieldnameType; - } - }, { - key: "source", - value: function source() { - return this._in; - } - }, { - key: "annotations", - value: function annotations() { - return this._ann; - } - }, { - key: "clearFieldName", - value: function clearFieldName() { - this._fieldname = null; - this._fieldnameType = null; - } - }, { - key: "isNull", - value: function isNull() { - return this._curr_null; - } - }, { - key: "bigIntValue", - value: function bigIntValue() { - if (this.isNull()) { - return null; - } - var intText = this.get_value_as_string(this._curr).toLowerCase(); - switch (this._curr) { - case T_INT: - case T_HEXINT: - if (intText.startsWith("-")) { - var i = BigInt(intText.slice(1)); - return -i; - } - return BigInt(intText); - default: - throw new Error("intValue() was called when the current value was not an integer."); - } + fieldName() { + return this._fieldname; + } + fieldNameType() { + return this._fieldnameType; + } + source() { + return this._in; + } + annotations() { + return this._ann; + } + clearFieldName() { + this._fieldname = null; + this._fieldnameType = null; + } + isNull() { + return this._curr_null; + } + bigIntValue() { + if (this.isNull()) { + return null; } - }, { - key: "numberValue", - value: function numberValue() { - if (this.isNull()) { - return null; - } - var s = this.get_value_as_string(this._curr); - switch (this._curr) { - case T_INT: - case T_HEXINT: - return Number(BigInt(s)); - case T_FLOAT: - return Number(s); - case T_FLOAT_SPECIAL: - if (s == "+inf") { - return Number.POSITIVE_INFINITY; - } else if (s == "-inf") { - return Number.NEGATIVE_INFINITY; - } else if (s == "nan") { - return Number.NaN; - } - default: - throw new Error("can't convert to number"); - } + const intText = this.get_value_as_string(this._curr).toLowerCase(); + switch (this._curr) { + case T_INT: + case T_HEXINT: + if (intText.startsWith("-")) { + const i = BigInt(intText.slice(1)); + return -i; + } + return BigInt(intText); + default: + throw new Error("intValue() was called when the current value was not an integer."); } - }, { - key: "booleanValue", - value: function booleanValue() { - if (this.isNull()) { - return null; - } - var s = this.get_value_as_string(T_BOOL); - if (s === "true") { - return true; - } else if (s === "false") { - return false; - } - throw new Error("Unrecognized Boolean value '" + s + "'"); - } - }, { - key: "get_value_as_string", - value: function get_value_as_string(t) { - var index; - var ch; - var s = ""; - switch (t) { - case T_NULL: - case T_BOOL: - case T_INT: - case T_HEXINT: - case T_FLOAT: - case T_FLOAT_SPECIAL: - case T_DECIMAL: - case T_TIMESTAMP: - case T_IDENTIFIER: - case T_OPERATOR: - for (index = this._start; index < this._end; index++) { - s += String.fromCharCode(this._in.valueAt(index)); + } + numberValue() { + if (this.isNull()) { + return null; + } + const s = this.get_value_as_string(this._curr); + switch (this._curr) { + case T_INT: + case T_HEXINT: + return Number(BigInt(s)); + case T_FLOAT: + return Number(s); + case T_FLOAT_SPECIAL: + if (s == "+inf") { + return Number.POSITIVE_INFINITY; + } else if (s == "-inf") { + return Number.NEGATIVE_INFINITY; + } else if (s == "nan") { + return Number.NaN; + } + default: + throw new Error("can't convert to number"); + } + } + booleanValue() { + if (this.isNull()) { + return null; + } + const s = this.get_value_as_string(T_BOOL); + if (s === "true") { + return true; + } else if (s === "false") { + return false; + } + throw new Error("Unrecognized Boolean value '" + s + "'"); + } + get_value_as_string(t) { + let index; + let ch; + let s = ""; + switch (t) { + case T_NULL: + case T_BOOL: + case T_INT: + case T_HEXINT: + case T_FLOAT: + case T_FLOAT_SPECIAL: + case T_DECIMAL: + case T_TIMESTAMP: + case T_IDENTIFIER: + case T_OPERATOR: + for (index = this._start; index < this._end; index++) { + s += String.fromCharCode(this._in.valueAt(index)); + } + break; + case T_BLOB: + for (index = this._start; index < this._end; index++) { + ch = this._in.valueAt(index); + if (IonText_1.is_base64_char(ch)) { + s += String.fromCharCode(ch); } - break; - case T_BLOB: - for (index = this._start; index < this._end; index++) { - ch = this._in.valueAt(index); - if (IonText_1.is_base64_char(ch)) { - s += String.fromCharCode(ch); - } + } + break; + case T_STRING1: + case T_STRING2: + case T_STRING3: + for (index = this._start; index < this._end; index++) { + let isEscaped = false; + ch = this._in.valueAt(index); + if (ch == CH_BS) { + ch = this._read_escape_sequence(index, this._end); + index += this._esc_len; + isEscaped = true; } - break; - case T_STRING1: - case T_STRING2: - case T_STRING3: - for (index = this._start; index < this._end; index++) { - var isEscaped = false; - ch = this._in.valueAt(index); - if (ch == CH_BS) { - ch = this._read_escape_sequence(index, this._end); + if (this.isHighSurrogate(ch)) { + index++; + let tempChar = this._in.valueAt(index); + if (tempChar == CH_BS) { + tempChar = this._read_escape_sequence(index, this._end); index += this._esc_len; - isEscaped = true; } - if (this.isHighSurrogate(ch)) { - index++; - var tempChar = this._in.valueAt(index); - if (tempChar == CH_BS) { - tempChar = this._read_escape_sequence(index, this._end); - index += this._esc_len; - } - if (this.isLowSurrogate(tempChar)) { - var hiSurrogate = ch; - var loSurrogate = tempChar; - var codepoint = 0x10000 + ((hiSurrogate & _UTF16_MASK) << 10) + (loSurrogate & _UTF16_MASK); - s += String.fromCodePoint(codepoint); - } else { - throw new Error("expected a low surrogate, but found: " + ch); - } - } else if (this.isLowSurrogate(ch)) { - throw new Error("unexpected low surrogate: " + ch); - } else if (t === T_STRING3 && ch === CH_SQ && !isEscaped && this.verifyTriple(index)) { - index = this._skip_triple_quote_gap(index, this._end, true); - } else if (ch >= 0) { - if (isEscaped) { - s += String.fromCodePoint(ch); - } else { - if (t === T_STRING3 && ch === ESC_nl3 && this._in.valueAt(index + 1) === ESC_nl2) { - ch = ESC_nl2; - index++; - } - s += String.fromCharCode(ch); - } + if (this.isLowSurrogate(tempChar)) { + const hiSurrogate = ch; + const loSurrogate = tempChar; + const codepoint = 0x10000 + ((hiSurrogate & _UTF16_MASK) << 10) + (loSurrogate & _UTF16_MASK); + s += String.fromCodePoint(codepoint); + } else { + throw new Error("expected a low surrogate, but found: " + ch); } - } - break; - default: - throw new Error("can't get this value as a string"); - } - return s; - } - }, { - key: "get_value_as_uint8array", - value: function get_value_as_uint8array(t) { - var bytes = []; - switch (t) { - case T_CLOB2: - for (var index = this._start; index < this._end; index++) { - var ch = this._in.valueAt(index); - if (ch === CH_BS) { - bytes.push(this.readClobEscapes(index, this._end)); - index += this._esc_len; - } else if (ch < 128) { - bytes.push(ch); + } else if (this.isLowSurrogate(ch)) { + throw new Error("unexpected low surrogate: " + ch); + } else if (t === T_STRING3 && ch === CH_SQ && !isEscaped && this.verifyTriple(index)) { + index = this._skip_triple_quote_gap(index, this._end, true); + } else if (ch >= 0) { + if (isEscaped) { + s += String.fromCodePoint(ch); } else { - throw new Error("Non-Ascii values illegal within clob."); + if (t === T_STRING3 && ch === ESC_nl3 && this._in.valueAt(index + 1) === ESC_nl2) { + ch = ESC_nl2; + index++; + } + s += String.fromCharCode(ch); } } - break; - case T_CLOB3: - for (var _index = this._start; _index < this._end; _index++) { - var _ch = this._in.valueAt(_index); - if (_ch === CH_BS) { - var escaped = this.readClobEscapes(_index, this._end); - if (escaped >= 0) { - bytes.push(escaped); - } - _index += this._esc_len; - } else if (_ch === CH_SQ) { - if (this.verifyTriple(_index)) { - _index = this._skip_triple_quote_gap(_index, this._end, false); - } else { - bytes.push(_ch); - } - } else if (_ch < 128) { - bytes.push(_ch); + } + break; + default: + throw new Error("can't get this value as a string"); + } + return s; + } + get_value_as_uint8array(t) { + const bytes = []; + switch (t) { + case T_CLOB2: + for (let index = this._start; index < this._end; index++) { + const ch = this._in.valueAt(index); + if (ch === CH_BS) { + bytes.push(this.readClobEscapes(index, this._end)); + index += this._esc_len; + } else if (ch < 128) { + bytes.push(ch); + } else { + throw new Error("Non-Ascii values illegal within clob."); + } + } + break; + case T_CLOB3: + for (let index = this._start; index < this._end; index++) { + const ch = this._in.valueAt(index); + if (ch === CH_BS) { + const escaped = this.readClobEscapes(index, this._end); + if (escaped >= 0) { + bytes.push(escaped); + } + index += this._esc_len; + } else if (ch === CH_SQ) { + if (this.verifyTriple(index)) { + index = this._skip_triple_quote_gap(index, this._end, false); } else { - throw new Error("Non-Ascii values illegal within clob."); + bytes.push(ch); } + } else if (ch < 128) { + bytes.push(ch); + } else { + throw new Error("Non-Ascii values illegal within clob."); } - break; - default: - throw new Error("can't get this value as a Uint8Array"); - } - return Uint8Array.from(bytes); - } - }, { - key: "next", - value: function next() { - this.clearFieldName(); - this._ann = []; - if (this._value_type === ERROR) { - this._run(); - } - this._curr = this._value_pop(); - var t; - if (this._curr === ERROR) { - this._value.push(ERROR); - return undefined; - } else { - t = this._curr; - } - this._curr_null = this._value_null; - this._value_null = false; - return t; + } + break; + default: + throw new Error("can't get this value as a Uint8Array"); } - }, { - key: "_read_datagram_values", - value: function _read_datagram_values() { - var ch = this._peek(); - if (ch == EOF) { - this._value_push(EOF); - } else { - this._ops.unshift(this._read_datagram_values); - this._ops.unshift(this._read_value); - } + return Uint8Array.from(bytes); + } + next() { + this.clearFieldName(); + this._ann = []; + if (this._value_type === ERROR) { + this._run(); + } + this._curr = this._value_pop(); + let t; + if (this._curr === ERROR) { + this._value.push(ERROR); + return undefined; + } else { + t = this._curr; + } + this._curr_null = this._value_null; + this._value_null = false; + return t; + } + _read_datagram_values() { + const ch = this._peek(); + if (ch == EOF) { + this._value_push(EOF); + } else { + this._ops.unshift(this._read_datagram_values); + this._ops.unshift(this._read_value); } - }, { - key: "_read_sexp_values", - value: function _read_sexp_values() { - var ch = this._read_after_whitespace(true); - if (ch == CH_CP) { + } + _read_sexp_values() { + const ch = this._read_after_whitespace(true); + if (ch == CH_CP) { + this._value_push(EOF); + } else if (ch === EOF) { + throw new Error("Expected closing )."); + } else { + this._unread(ch); + this._ops.unshift(this._read_sexp_values); + this._ops.unshift(this._read_sexp_value); + } + } + _read_list_values() { + const ch = this._read_after_whitespace(true); + if (ch == CH_CS) { + this._value_push(EOF); + } else { + this._unread(ch); + this._ops.unshift(this._read_list_comma); + this._ops.unshift(this._read_value); + } + } + _read_struct_values() { + let op = this._done_with_error, + ch = this._read_after_whitespace(true); + switch (ch) { + case CH_SQ: + op = this._read_string1; + if (this._peek("''") != ERROR) { + op = this._read_string3; + } + break; + case CH_DOUBLE_QUOTE: + op = this._read_string2; + break; + case CH_CC: this._value_push(EOF); - } else if (ch === EOF) { - throw new Error("Expected closing )."); - } else { - this._unread(ch); - this._ops.unshift(this._read_sexp_values); - this._ops.unshift(this._read_sexp_value); + return; + default: + if (IonText_1.is_letter(ch)) { + op = this._read_symbol; + } + break; + } + if (op === this._done_with_error) { + this._error("expected field name (or close struct '}') not found"); + } else { + op.call(this); + this._load_field_name(); + ch = this._read_after_whitespace(true); + if (ch != CH_CL) { + this._error("expected ':'"); + return; } + this._ops.unshift(this._read_struct_comma); + this._ops.unshift(this._read_value); } - }, { - key: "_read_list_values", - value: function _read_list_values() { - var ch = this._read_after_whitespace(true); + } + _read_list_comma() { + let ch = this._read_after_whitespace(true); + if (ch == CH_CM) { + ch = this._read_after_whitespace(true); if (ch == CH_CS) { this._value_push(EOF); } else { @@ -3962,1123 +3387,941 @@ var ParserTextRaw = /*#__PURE__*/function () { this._ops.unshift(this._read_list_comma); this._ops.unshift(this._read_value); } + } else if (ch == CH_CS) { + this._value_push(EOF); + } else { + this._error("expected ',' or ']'"); } - }, { - key: "_read_struct_values", - value: function _read_struct_values() { - var op = this._done_with_error, - ch = this._read_after_whitespace(true); - switch (ch) { - case CH_SQ: - op = this._read_string1; - if (this._peek("''") != ERROR) { - op = this._read_string3; - } - break; - case CH_DOUBLE_QUOTE: - op = this._read_string2; - break; - case CH_CC: - this._value_push(EOF); - return; - default: - if (IonText_1.is_letter(ch)) { - op = this._read_symbol; - } - break; - } - if (op === this._done_with_error) { - this._error("expected field name (or close struct '}') not found"); + } + _read_struct_comma() { + let ch = this._read_after_whitespace(true); + if (ch == CH_CM) { + ch = this._read_after_whitespace(true); + if (ch == CH_CC) { + this._value_push(EOF); } else { - op.call(this); - this._load_field_name(); - ch = this._read_after_whitespace(true); - if (ch != CH_CL) { - this._error("expected ':'"); - return; - } - this._ops.unshift(this._read_struct_comma); - this._ops.unshift(this._read_value); + this._unread(ch); + this._ops.unshift(this._read_struct_values); } + } else if (ch == CH_CC) { + this._value_push(EOF); + } else { + this._error("expected ',' or '}'"); } - }, { - key: "_read_list_comma", - value: function _read_list_comma() { - var ch = this._read_after_whitespace(true); - if (ch == CH_CM) { - ch = this._read_after_whitespace(true); - if (ch == CH_CS) { - this._value_push(EOF); - } else { - this._unread(ch); - this._ops.unshift(this._read_list_comma); - this._ops.unshift(this._read_value); + } + _load_field_name() { + this._fieldnameType = this._value_pop(); + const s = this.get_value_as_string(this._fieldnameType); + switch (this._fieldnameType) { + case T_IDENTIFIER: + if (IonText_1.is_keyword(s)) { + throw new Error("can't use '" + s + "' as a fieldname without quotes"); } - } else if (ch == CH_CS) { - this._value_push(EOF); + case T_STRING1: + case T_STRING2: + case T_STRING3: + this._fieldname = s; + break; + default: + throw new Error("invalid fieldname" + s); + } + } + _read_value() { + this._read_value_helper(false, this._read_value); + } + _read_sexp_value() { + this._read_value_helper(true, this._read_sexp_value); + } + _read_value_helper(accept_operator_symbols, calling_op) { + const ch = this._read_after_whitespace(true); + if (ch == EOF) { + this._read_value_helper_EOF(ch, accept_operator_symbols, calling_op); + } else { + const fn = this._read_value_helper_helpers[ch]; + if (fn != undefined) { + fn.call(this, ch, accept_operator_symbols, calling_op); } else { - this._error("expected ',' or ']'"); + this._error("unexpected character '" + IonText_1.asAscii(ch) + "'"); } } - }, { - key: "_read_struct_comma", - value: function _read_struct_comma() { - var ch = this._read_after_whitespace(true); - if (ch == CH_CM) { - ch = this._read_after_whitespace(true); - if (ch == CH_CC) { - this._value_push(EOF); - } else { - this._unread(ch); - this._ops.unshift(this._read_struct_values); - } - } else if (ch == CH_CC) { - this._value_push(EOF); + } + _read_value_helper_EOF(ch1, accept_operator_symbols, calling_op) { + this._ops.unshift(this._done); + } + _read_value_helper_paren(ch1, accept_operator_symbols, calling_op) { + this._value_push(T_SEXP); + this._ops.unshift(this._read_sexp_values); + } + _read_value_helper_square(ch1, accept_operator_symbols, calling_op) { + this._value_push(T_LIST); + this._ops.unshift(this._read_list_values); + } + _read_value_helper_curly(ch1, accept_operator_symbols, calling_op) { + let ch3; + const ch2 = this._read(); + if (ch2 == CH_LEFT_CURLY) { + ch3 = this._read_after_whitespace(false); + if (ch3 == CH_SQ) { + this._ops.unshift(this._read_clob_string3); + } else if (ch3 == CH_DOUBLE_QUOTE) { + this._ops.unshift(this._read_clob_string2); } else { - this._error("expected ',' or '}'"); - } - } - }, { - key: "_load_field_name", - value: function _load_field_name() { - this._fieldnameType = this._value_pop(); - var s = this.get_value_as_string(this._fieldnameType); - switch (this._fieldnameType) { - case T_IDENTIFIER: - if (IonText_1.is_keyword(s)) { - throw new Error("can't use '" + s + "' as a fieldname without quotes"); - } - case T_STRING1: - case T_STRING2: - case T_STRING3: - this._fieldname = s; - break; - default: - throw new Error("invalid fieldname" + s); + this._unread(ch3); + this._ops.unshift(this._read_blob); } + } else { + this._unread(ch2); + this._value_push(T_STRUCT); + this._ops.unshift(this._read_struct_values); + } + } + _read_value_helper_plus(ch1, accept_operator_symbols, calling_op) { + const ch2 = this._peek("inf"); + this._unread(ch1); + if (IonText_1.isNumericTerminator(ch2)) { + this._ops.unshift(this._read_plus_inf); + } else if (accept_operator_symbols) { + this._ops.unshift(this._read_operator_symbol); + } else { + this._error("unexpected '+'"); } - }, { - key: "_read_value", - value: function _read_value() { - this._read_value_helper(false, this._read_value); - } - }, { - key: "_read_sexp_value", - value: function _read_sexp_value() { - this._read_value_helper(true, this._read_sexp_value); + } + _read_value_helper_digit(ch1, accept_operator_symbols, calling_op) { + const ch2 = this._peek_4_digits(ch1); + this._unread(ch1); + if (ch2 == CH_T || ch2 == CH_MS) { + this._ops.unshift(this._readTimestamp); + } else { + this._ops.unshift(this._read_number); } - }, { - key: "_read_value_helper", - value: function _read_value_helper(accept_operator_symbols, calling_op) { - var ch = this._read_after_whitespace(true); - if (ch == EOF) { - this._read_value_helper_EOF(ch, accept_operator_symbols, calling_op); - } else { - var fn = this._read_value_helper_helpers[ch]; - if (fn != undefined) { - fn.call(this, ch, accept_operator_symbols, calling_op); - } else { - this._error("unexpected character '" + IonText_1.asAscii(ch) + "'"); - } + } + _read_value_helper_single(ch1, accept_operator_symbols, calling_op) { + let op; + if (this._peek("''") != ERROR) { + op = this._read_string3; + op.call(this); + } else { + op = this._read_string1; + op.call(this); + if (this._test_string_as_annotation(op)) { + this._ops.unshift(calling_op); } } - }, { - key: "_read_value_helper_EOF", - value: function _read_value_helper_EOF(ch1, accept_operator_symbols, calling_op) { - this._ops.unshift(this._done); - } - }, { - key: "_read_value_helper_paren", - value: function _read_value_helper_paren(ch1, accept_operator_symbols, calling_op) { - this._value_push(T_SEXP); - this._ops.unshift(this._read_sexp_values); + } + _read_value_helper_double(ch1, accept_operator_symbols, calling_op) { + this._ops.unshift(this._read_string2); + } + _read_value_helper_letter(ch1, accept_operator_symbols, calling_op) { + this._read_symbol(); + const type = this._value_pop(); + if (type != T_IDENTIFIER) { + throw new Error("Expecting symbol here."); } - }, { - key: "_read_value_helper_square", - value: function _read_value_helper_square(ch1, accept_operator_symbols, calling_op) { - this._value_push(T_LIST); - this._ops.unshift(this._read_list_values); - } - }, { - key: "_read_value_helper_curly", - value: function _read_value_helper_curly(ch1, accept_operator_symbols, calling_op) { - var ch3; - var ch2 = this._read(); - if (ch2 == CH_LEFT_CURLY) { - ch3 = this._read_after_whitespace(false); - if (ch3 == CH_SQ) { - this._ops.unshift(this._read_clob_string3); - } else if (ch3 == CH_DOUBLE_QUOTE) { - this._ops.unshift(this._read_clob_string2); + let symbol = this.get_value_as_string(type); + if (IonText_1.is_keyword(symbol)) { + let kwt = get_keyword_type(symbol); + if (kwt === T_NULL) { + this._value_null = true; + if (this._peek() === CH_DT) { + this._read(); + const ch = this._read(); + if (IonText_1.is_letter(ch) !== true) { + throw new Error("Expected type name after 'null.'"); + } + this._read_symbol(); + if (this._value_pop() !== T_IDENTIFIER) { + throw new Error("Expected type name after 'null.'"); + } + symbol = this.get_value_as_string(T_IDENTIFIER); + kwt = get_type_from_name(symbol); + } + this._start = -1; + this._end = -1; + } + this._value_push(kwt); + } else { + const ch = this._read_after_whitespace(true); + if (ch == CH_CL && this._peek() == CH_CL) { + this._read(); + const sid = this._parseSymbolId(symbol); + if (sid === 0) { + throw new Error("Symbol ID zero is not supported."); + } else if (isNaN(sid)) { + this._ann.push(new IonSymbolToken_1.SymbolToken(symbol)); } else { - this._unread(ch3); - this._ops.unshift(this._read_blob); + this._ann.push(new IonSymbolToken_1.SymbolToken(null, sid)); } + this._ops.unshift(calling_op); } else { - this._unread(ch2); - this._value_push(T_STRUCT); - this._ops.unshift(this._read_struct_values); + const kwt = T_IDENTIFIER; + this._unread(ch); + this._value_push(kwt); } } - }, { - key: "_read_value_helper_plus", - value: function _read_value_helper_plus(ch1, accept_operator_symbols, calling_op) { - var ch2 = this._peek("inf"); + } + _read_value_helper_operator(ch1, accept_operator_symbols, calling_op) { + if (accept_operator_symbols) { this._unread(ch1); - if (IonText_1.isNumericTerminator(ch2)) { - this._ops.unshift(this._read_plus_inf); - } else if (accept_operator_symbols) { - this._ops.unshift(this._read_operator_symbol); - } else { - this._error("unexpected '+'"); - } + this._ops.unshift(this._read_operator_symbol); + } else { + this._error("unexpected operator character"); } - }, { - key: "_read_value_helper_digit", - value: function _read_value_helper_digit(ch1, accept_operator_symbols, calling_op) { - var ch2 = this._peek_4_digits(ch1); - this._unread(ch1); - if (ch2 == CH_T || ch2 == CH_MS) { - this._ops.unshift(this._readTimestamp); - } else { - this._ops.unshift(this._read_number); - } + } + _done() { + this._value_push(EOF); + } + _done_with_error() { + this._value_push(ERROR); + throw new Error(this._error_msg); + } + _read_number() { + let ch, t; + this._start = this._in.position(); + ch = this._read(); + if (ch == CH_MS) { + ch = this._read(); } - }, { - key: "_read_value_helper_single", - value: function _read_value_helper_single(ch1, accept_operator_symbols, calling_op) { - var op; - if (this._peek("''") != ERROR) { - op = this._read_string3; - op.call(this); - } else { - op = this._read_string1; - op.call(this); - if (this._test_string_as_annotation(op)) { - this._ops.unshift(calling_op); - } - } - } - }, { - key: "_read_value_helper_double", - value: function _read_value_helper_double(ch1, accept_operator_symbols, calling_op) { - this._ops.unshift(this._read_string2); - } - }, { - key: "_read_value_helper_letter", - value: function _read_value_helper_letter(ch1, accept_operator_symbols, calling_op) { - this._read_symbol(); - var type = this._value_pop(); - if (type != T_IDENTIFIER) { - throw new Error("Expecting symbol here."); - } - var symbol = this.get_value_as_string(type); - if (IonText_1.is_keyword(symbol)) { - var kwt = get_keyword_type(symbol); - if (kwt === T_NULL) { - this._value_null = true; - if (this._peek() === CH_DT) { - this._read(); - var ch = this._read(); - if (IonText_1.is_letter(ch) !== true) { - throw new Error("Expected type name after 'null.'"); - } - this._read_symbol(); - if (this._value_pop() !== T_IDENTIFIER) { - throw new Error("Expected type name after 'null.'"); - } - symbol = this.get_value_as_string(T_IDENTIFIER); - kwt = get_type_from_name(symbol); - } - this._start = -1; - this._end = -1; - } - this._value_push(kwt); - } else { - var _ch2 = this._read_after_whitespace(true); - if (_ch2 == CH_CL && this._peek() == CH_CL) { - this._read(); - var sid = this._parseSymbolId(symbol); - if (sid === 0) { - throw new Error("Symbol ID zero is not supported."); - } else if (isNaN(sid)) { - this._ann.push(new IonSymbolToken_1.SymbolToken(symbol)); - } else { - this._ann.push(new IonSymbolToken_1.SymbolToken(null, sid)); - } - this._ops.unshift(calling_op); - } else { - var _kwt = T_IDENTIFIER; - this._unread(_ch2); - this._value_push(_kwt); - } + if (ch == CH_0) { + ch = this._peek(); + if (ch == CH_x || ch == CH_X) { + this._read_hex_int(); + return; } + if (IonText_1.is_digit(ch)) { + this._error("leading zeros are not allowed"); + } + ch = CH_0; } - }, { - key: "_read_value_helper_operator", - value: function _read_value_helper_operator(ch1, accept_operator_symbols, calling_op) { - if (accept_operator_symbols) { - this._unread(ch1); - this._ops.unshift(this._read_operator_symbol); - } else { - this._error("unexpected operator character"); + t = T_INT; + ch = this._read_required_digits(ch); + if (ch == CH_DT) { + t = T_DECIMAL; + ch = this._read_optional_digits(this._read()); + } + if (!IonText_1.isNumericTerminator(ch)) { + if (ch == CH_d || ch == CH_D) { + t = T_DECIMAL; + ch = this._read_exponent(); + } else if (ch == CH_e || ch == CH_E || ch == CH_f || ch == CH_F) { + t = T_FLOAT; + ch = this._read_exponent(); } } - }, { - key: "_done", - value: function _done() { - this._value_push(EOF); + if (!IonText_1.isNumericTerminator(ch)) { + this._error("invalid character after number"); + } else { + this._unread(ch); + this._end = this._in.position(); + this._value_push(t); } - }, { - key: "_done_with_error", - value: function _done_with_error() { - this._value_push(ERROR); - throw new Error(this._error_msg); + } + _read_hex_int() { + let ch = this._read(); + if (ch == CH_x || ch == CH_X) { + ch = this._read(); + ch = this._read_required_hex_digits(ch); } - }, { - key: "_read_number", - value: function _read_number() { - var ch, t; - this._start = this._in.position(); + if (IonText_1.isNumericTerminator(ch)) { + this._unread(ch); + this._end = this._in.position(); + this._value_push(T_HEXINT); + } else { + this._error("invalid character after number"); + } + } + _read_exponent() { + let ch = this._read(); + if (ch == CH_MS || ch == CH_PS) { ch = this._read(); - if (ch == CH_MS) { - ch = this._read(); - } - if (ch == CH_0) { - ch = this._peek(); - if (ch == CH_x || ch == CH_X) { - this._read_hex_int(); - return; - } - if (IonText_1.is_digit(ch)) { - this._error("leading zeros are not allowed"); - } - ch = CH_0; - } - t = T_INT; - ch = this._read_required_digits(ch); - if (ch == CH_DT) { - t = T_DECIMAL; - ch = this._read_optional_digits(this._read()); + } + ch = this._read_required_digits(ch); + return ch; + } + _read_plus_inf() { + this._start = this._in.position(); + if (this._read() == CH_PS) { + this._read_inf_helper(); + } else { + this._error("expected +inf"); + } + } + _read_minus_inf() { + this._start = this._in.position(); + if (this._read() == CH_MS) { + this._read_inf_helper(); + } else { + this._error("expected -inf"); + } + } + _read_inf_helper() { + let ii, ch; + for (ii = 0; ii < 3; ii++) { + ch = this._read(); + if (ch != INF[ii]) { + this._error("expected 'inf'"); + return; } - if (!IonText_1.isNumericTerminator(ch)) { - if (ch == CH_d || ch == CH_D) { - t = T_DECIMAL; - ch = this._read_exponent(); - } else if (ch == CH_e || ch == CH_E || ch == CH_f || ch == CH_F) { - t = T_FLOAT; - ch = this._read_exponent(); + } + if (IonText_1.isNumericTerminator(this._peek())) { + this._end = this._in.position(); + this._value_push(T_FLOAT_SPECIAL); + } else { + this._error("invalid numeric terminator after 'inf'"); + } + } + _readTimestamp() { + this._start = this._in.position(); + let ch = this._readPastNDigits(4); + if (ch === CH_T) { + this._end = this._in.position(); + this._value_push(T_TIMESTAMP); + return; + } else if (ch !== CH_MS) { + throw new Error("Timestamp year must be followed by '-' or 'T'."); + } + ch = this._readPastNDigits(2); + if (ch === CH_T) { + this._end = this._in.position(); + this._value_push(T_TIMESTAMP); + return; + } else if (ch !== CH_MS) { + throw new Error("Timestamp month must be followed by '-' or 'T'."); + } + ch = this._readPastNDigits(2); + if (IonText_1.isNumericTerminator(ch)) { + this._unread(ch); + this._end = this._in.position(); + this._value_push(T_TIMESTAMP); + return; + } else if (ch !== CH_T) { + throw new Error("Timestamp day must be followed by a numeric stop character ."); + } + const peekChar = this._in.peek(); + if (IonText_1.isNumericTerminator(peekChar)) { + this._end = this._in.position(); + this._value_push(T_TIMESTAMP); + return; + } else if (!IonText_1.is_digit(peekChar)) { + throw new Error("Timestamp DATE must be followed by numeric terminator or additional TIME digits."); + } + ch = this._readPastNDigits(2); + if (ch !== CH_CL) { + throw new Error("Timestamp time(hr:min) requires format of 00:00"); + } + ch = this._readPastNDigits(2); + if (ch === CH_CL) { + ch = this._readPastNDigits(2); + if (ch === CH_DT) { + if (!IonText_1.is_digit(this._read())) { + throw new Error("W3C timestamp spec requires atleast one digit after decimal point."); } - } - if (!IonText_1.isNumericTerminator(ch)) { - this._error("invalid character after number"); - } else { - this._unread(ch); - this._end = this._in.position(); - this._value_push(t); + while (IonText_1.is_digit(ch = this._read())) {} } } - }, { - key: "_read_hex_int", - value: function _read_hex_int() { - var ch = this._read(); - if (ch == CH_x || ch == CH_X) { - ch = this._read(); - ch = this._read_required_hex_digits(ch); + if (ch === CH_Z) { + if (!IonText_1.isNumericTerminator(this._peek())) { + throw new Error("Illegal terminator after Zulu offset."); } - if (IonText_1.isNumericTerminator(ch)) { - this._unread(ch); - this._end = this._in.position(); - this._value_push(T_HEXINT); - } else { - this._error("invalid character after number"); + this._end = this._in.position(); + this._value_push(T_TIMESTAMP); + return; + } else if (ch !== CH_PS && ch !== CH_MS) { + throw new Error("Timestamps require an offset."); + } + ch = this._readPastNDigits(2); + if (ch !== CH_CL) { + throw new Error("Timestamp offset(hr:min) requires format of +/-00:00."); + } + this._readNDigits(2); + ch = this._peek(); + if (!IonText_1.isNumericTerminator(ch)) { + throw new Error("Improperly formatted timestamp."); + } + this._end = this._in.position(); + this._value_push(T_TIMESTAMP); + } + _read_symbol() { + let ch; + this._start = this._in.position() - 1; + for (;;) { + ch = this._read(); + if (!IonText_1.is_letter_or_digit(ch)) { + break; } } - }, { - key: "_read_exponent", - value: function _read_exponent() { - var ch = this._read(); - if (ch == CH_MS || ch == CH_PS) { - ch = this._read(); + this._unread(ch); + this._end = this._in.position(); + this._value_push(T_IDENTIFIER); + } + _read_operator_symbol() { + let ch; + this._start = this._in.position(); + for (;;) { + ch = this._read(); + if (!IonText_1.is_operator_char(ch)) { + break; } - ch = this._read_required_digits(ch); - return ch; } - }, { - key: "_read_plus_inf", - value: function _read_plus_inf() { - this._start = this._in.position(); - if (this._read() == CH_PS) { - this._read_inf_helper(); - } else { - this._error("expected +inf"); - } + this._end = this._in.position() - 1; + this._unread(ch); + this._value_push(T_OPERATOR); + } + _read_string1() { + this._read_string_helper(CH_SQ, false); + this._end = this._in.position() - 1; + this._value_push(T_STRING1); + } + _read_string2() { + this._read_string_helper(CH_DOUBLE_QUOTE, false); + this._end = this._in.position() - 1; + this._value_push(T_STRING2); + } + _read_string3(recognizeComments) { + if (recognizeComments === undefined) { + recognizeComments = true; } - }, { - key: "_read_minus_inf", - value: function _read_minus_inf() { - this._start = this._in.position(); - if (this._read() == CH_MS) { - this._read_inf_helper(); - } else { - this._error("expected -inf"); + let ch; + this._unread(this._peek("")); + for (this._start = this._in.position() + 3; this._peek("'''") !== ERROR; this._in.unread(this._read_after_whitespace(recognizeComments))) { + for (let i = 0; i < 3; i++) { + this._read(); } - } - }, { - key: "_read_inf_helper", - value: function _read_inf_helper() { - var ii, ch; - for (ii = 0; ii < 3; ii++) { + while (this._peek("'''") === ERROR) { ch = this._read(); - if (ch != INF[ii]) { - this._error("expected 'inf'"); - return; + if (ch == CH_BS) { + this._read_string_escape_sequence(); + } + if (ch === EOF) { + throw new Error("Closing triple quotes not found."); + } + if (!is_valid_string_char(ch, true)) { + throw new Error("invalid character " + ch + " in string"); } } - if (IonText_1.isNumericTerminator(this._peek())) { - this._end = this._in.position(); - this._value_push(T_FLOAT_SPECIAL); - } else { - this._error("invalid numeric terminator after 'inf'"); + this._end = this._in.position(); + for (let i = 0; i < 3; i++) { + this._read(); } } - }, { - key: "_readTimestamp", - value: function _readTimestamp() { - this._start = this._in.position(); - var ch = this._readPastNDigits(4); - if (ch === CH_T) { - this._end = this._in.position(); - this._value_push(T_TIMESTAMP); - return; - } else if (ch !== CH_MS) { - throw new Error("Timestamp year must be followed by '-' or 'T'."); - } - ch = this._readPastNDigits(2); - if (ch === CH_T) { - this._end = this._in.position(); - this._value_push(T_TIMESTAMP); - return; - } else if (ch !== CH_MS) { - throw new Error("Timestamp month must be followed by '-' or 'T'."); - } - ch = this._readPastNDigits(2); - if (IonText_1.isNumericTerminator(ch)) { + this._value_push(T_STRING3); + } + verifyTriple(entryIndex) { + return this._in.valueAt(entryIndex) === CH_SQ && this._in.valueAt(entryIndex + 1) === CH_SQ && this._in.valueAt(entryIndex + 2) === CH_SQ; + } + _read_string_escape_sequence() { + let ch = this._read(); + switch (ch) { + case ESC_0: + case ESC_a: + case ESC_b: + case ESC_t: + case ESC_nl: + case ESC_ff: + case ESC_cr: + case ESC_v: + case ESC_dq: + case ESC_sq: + case ESC_qm: + case ESC_bs: + case ESC_fs: + case ESC_nl2: + break; + case ESC_nl3: + ch = this._read(); + if (ch != ESC_nl2) { + this._unread(ch); + } + break; + case ESC_x: + ch = this._read_N_hexdigits(2); this._unread(ch); + break; + case ESC_u: + ch = this._read_N_hexdigits(4); + this._unread(ch); + break; + case ESC_U: + ch = this._read_N_hexdigits(8); + this._unread(ch); + break; + default: + this._error("unexpected character: " + ch + " after escape slash"); + } + } + _test_string_as_annotation(op) { + let s, ch, is_ann; + const t = this._value_pop(); + if (t != T_STRING1 && t != T_STRING3) { + this._error("expecting quoted symbol here"); + } + s = this.get_value_as_string(t); + ch = this._read_after_whitespace(true); + if (ch == CH_CL && this._peek() == CH_CL) { + this._read(); + this._ann.push(new IonSymbolToken_1.SymbolToken(s)); + is_ann = true; + } else { + this._unread(ch); + this._value_push(t); + is_ann = false; + } + return is_ann; + } + _read_clob_string2() { + let t; + this._read_string2(); + t = this._value_pop(); + if (t != T_STRING2) { + this._error("string expected"); + } + this._value_push(T_CLOB2); + this._ops.unshift(this._read_close_double_brace); + } + _read_clob_string3() { + let t; + this._read_string3(false); + t = this._value_pop(); + if (t != T_STRING3) { + this._error("string expected"); + } + this._value_push(T_CLOB3); + this._ops.unshift(this._read_close_double_brace); + } + _read_blob() { + let ch, + base64_chars = 0, + trailers = 0; + this._start = this._in.position(); + while (true) { + ch = this._read(); + if (IonText_1.is_base64_char(ch)) { + base64_chars++; this._end = this._in.position(); - this._value_push(T_TIMESTAMP); - return; - } else if (ch !== CH_T) { - throw new Error("Timestamp day must be followed by a numeric stop character ."); - } - var peekChar = this._in.peek(); - if (IonText_1.isNumericTerminator(peekChar)) { - this._end = this._in.position(); - this._value_push(T_TIMESTAMP); - return; - } else if (!IonText_1.is_digit(peekChar)) { - throw new Error("Timestamp DATE must be followed by numeric terminator or additional TIME digits."); - } - ch = this._readPastNDigits(2); - if (ch !== CH_CL) { - throw new Error("Timestamp time(hr:min) requires format of 00:00"); + } else if (!IonText_1.is_whitespace(ch)) { + break; } - ch = this._readPastNDigits(2); - if (ch === CH_CL) { - ch = this._readPastNDigits(2); - if (ch === CH_DT) { - if (!IonText_1.is_digit(this._read())) { - throw new Error("W3C timestamp spec requires atleast one digit after decimal point."); + } + while (ch == CH_EQ) { + trailers++; + ch = this._read_after_whitespace(false); + } + if (ch != CH_CC || this._read() != CH_CC) { + throw new Error("Invalid blob"); + } + if (!is_valid_base64_length(base64_chars, trailers)) { + throw new Error("Invalid base64 value"); + } + this._value_push(T_BLOB); + } + _read_close_double_brace() { + const ch = this._read_after_whitespace(false); + if (ch != CH_CC || this._read() != CH_CC) { + this._error("expected '}}'"); + } + } + isHighSurrogate(ch) { + return ch >= 0xd800 && ch <= 0xdbff; + } + isLowSurrogate(ch) { + return ch >= 0xdc00 && ch <= 0xdfff; + } + indexWhiteSpace(index, acceptComments) { + let ch = this._in.valueAt(index); + if (!acceptComments) { + for (; IonText_1.is_whitespace(ch); ch = this._in.valueAt(index++)) {} + } else { + for (; IonText_1.is_whitespace(ch) || ch === CH_FORWARD_SLASH; ch = this._in.valueAt(index++)) { + if (ch === CH_FORWARD_SLASH) { + ch = this._in.valueAt(index++); + switch (ch) { + case CH_FORWARD_SLASH: + index = this.indexToNewLine(index); + break; + case CH_AS: + index = this.indexToCloseComment(index); + break; + default: + index--; + break; } - while (IonText_1.is_digit(ch = this._read())) {} - } - } - if (ch === CH_Z) { - if (!IonText_1.isNumericTerminator(this._peek())) { - throw new Error("Illegal terminator after Zulu offset."); } - this._end = this._in.position(); - this._value_push(T_TIMESTAMP); - return; - } else if (ch !== CH_PS && ch !== CH_MS) { - throw new Error("Timestamps require an offset."); - } - ch = this._readPastNDigits(2); - if (ch !== CH_CL) { - throw new Error("Timestamp offset(hr:min) requires format of +/-00:00."); - } - this._readNDigits(2); - ch = this._peek(); - if (!IonText_1.isNumericTerminator(ch)) { - throw new Error("Improperly formatted timestamp."); } - this._end = this._in.position(); - this._value_push(T_TIMESTAMP); } - }, { - key: "_read_symbol", - value: function _read_symbol() { - var ch; - this._start = this._in.position() - 1; - for (;;) { - ch = this._read(); - if (!IonText_1.is_letter_or_digit(ch)) { - break; + return index; + } + indexToNewLine(index) { + let ch = this._in.valueAt(index); + while (ch !== EOF && ch !== CH_NL) { + if (ch === CH_CR) { + if (this._in.valueAt(index + 1) !== CH_NL) { + return index; } } - this._unread(ch); - this._end = this._in.position(); - this._value_push(T_IDENTIFIER); + ch = this._in.valueAt(index++); } - }, { - key: "_read_operator_symbol", - value: function _read_operator_symbol() { - var ch; - this._start = this._in.position(); - for (;;) { - ch = this._read(); - if (!IonText_1.is_operator_char(ch)) { - break; + return index; + } + indexToCloseComment(index) { + while (this._in.valueAt(index) !== CH_AS && this._in.valueAt(index + 1) !== CH_FORWARD_SLASH) { + index++; + } + return index; + } + _skip_triple_quote_gap(entryIndex, end, acceptComments) { + let tempIndex = entryIndex + 3; + tempIndex = this.indexWhiteSpace(tempIndex, acceptComments); + if (tempIndex + 2 <= end && this.verifyTriple(tempIndex)) { + return tempIndex + 4; + } else { + return tempIndex + 1; + } + } + readClobEscapes(ii, end) { + let ch; + if (ii + 1 >= end) { + throw new Error("invalid escape sequence"); + } + ch = this._in.valueAt(ii + 1); + this._esc_len = 1; + switch (ch) { + case ESC_0: + return 0; + case ESC_a: + return 7; + case ESC_b: + return 8; + case ESC_t: + return 9; + case ESC_nl: + return 10; + case ESC_ff: + return 12; + case ESC_cr: + return 13; + case ESC_v: + return 11; + case ESC_dq: + return 34; + case ESC_sq: + return 39; + case ESC_qm: + return 63; + case ESC_bs: + return 92; + case ESC_fs: + return 47; + case ESC_nl2: + return -1; + case ESC_nl3: + if (ii + 2 < end && this._in.valueAt(ii + 2) == CH_NL) { + this._esc_len = 2; + } + return IonText_1.ESCAPED_NEWLINE; + case ESC_x: + if (ii + 3 >= end) { + throw new Error("invalid escape sequence"); + } + ch = this._get_N_hexdigits(ii + 2, ii + 4); + this._esc_len = 3; + break; + default: + throw new Error("Invalid escape: /" + ch); + } + return ch; + } + _read_escape_sequence(ii, end) { + let ch; + if (ii + 1 >= end) { + throw new Error("Invalid escape sequence."); + } + ch = this._in.valueAt(ii + 1); + this._esc_len = 1; + switch (ch) { + case ESC_0: + return 0; + case ESC_a: + return 7; + case ESC_b: + return 8; + case ESC_t: + return 9; + case ESC_nl: + return 10; + case ESC_ff: + return 12; + case ESC_cr: + return 13; + case ESC_v: + return 11; + case ESC_dq: + return 34; + case ESC_sq: + return 39; + case ESC_qm: + return 63; + case ESC_bs: + return 92; + case ESC_fs: + return 47; + case ESC_nl2: + return -1; + case ESC_nl3: + if (ii + 2 < end && this._in.valueAt(ii + 2) == CH_NL) { + this._esc_len = 2; + } + return IonText_1.ESCAPED_NEWLINE; + case ESC_x: + if (ii + 3 >= end) { + throw new Error("invalid escape sequence"); + } + ch = this._get_N_hexdigits(ii + 2, ii + 4); + this._esc_len = 3; + break; + case ESC_u: + if (ii + 5 >= end) { + throw new Error("invalid escape sequence"); } - } - this._end = this._in.position() - 1; - this._unread(ch); - this._value_push(T_OPERATOR); - } - }, { - key: "_read_string1", - value: function _read_string1() { - this._read_string_helper(CH_SQ, false); - this._end = this._in.position() - 1; - this._value_push(T_STRING1); - } - }, { - key: "_read_string2", - value: function _read_string2() { - this._read_string_helper(CH_DOUBLE_QUOTE, false); - this._end = this._in.position() - 1; - this._value_push(T_STRING2); - } - }, { - key: "_read_string3", - value: function _read_string3(recognizeComments) { - if (recognizeComments === undefined) { - recognizeComments = true; - } - var ch; - this._unread(this._peek("")); - for (this._start = this._in.position() + 3; this._peek("'''") !== ERROR; this._in.unread(this._read_after_whitespace(recognizeComments))) { - for (var i = 0; i < 3; i++) { - this._read(); - } - while (this._peek("'''") === ERROR) { - ch = this._read(); - if (ch == CH_BS) { - this._read_string_escape_sequence(); - } - if (ch === EOF) { - throw new Error("Closing triple quotes not found."); - } - if (!is_valid_string_char(ch, true)) { - throw new Error("invalid character " + ch + " in string"); - } - } - this._end = this._in.position(); - for (var _i = 0; _i < 3; _i++) { - this._read(); - } - } - this._value_push(T_STRING3); - } - }, { - key: "verifyTriple", - value: function verifyTriple(entryIndex) { - return this._in.valueAt(entryIndex) === CH_SQ && this._in.valueAt(entryIndex + 1) === CH_SQ && this._in.valueAt(entryIndex + 2) === CH_SQ; - } - }, { - key: "_read_string_escape_sequence", - value: function _read_string_escape_sequence() { - var ch = this._read(); - switch (ch) { - case ESC_0: - case ESC_a: - case ESC_b: - case ESC_t: - case ESC_nl: - case ESC_ff: - case ESC_cr: - case ESC_v: - case ESC_dq: - case ESC_sq: - case ESC_qm: - case ESC_bs: - case ESC_fs: - case ESC_nl2: - break; - case ESC_nl3: - ch = this._read(); - if (ch != ESC_nl2) { - this._unread(ch); - } - break; - case ESC_x: - ch = this._read_N_hexdigits(2); - this._unread(ch); - break; - case ESC_u: - ch = this._read_N_hexdigits(4); - this._unread(ch); - break; - case ESC_U: - ch = this._read_N_hexdigits(8); - this._unread(ch); - break; - default: - this._error("unexpected character: " + ch + " after escape slash"); - } - } - }, { - key: "_test_string_as_annotation", - value: function _test_string_as_annotation(op) { - var s, ch, is_ann; - var t = this._value_pop(); - if (t != T_STRING1 && t != T_STRING3) { - this._error("expecting quoted symbol here"); - } - s = this.get_value_as_string(t); - ch = this._read_after_whitespace(true); - if (ch == CH_CL && this._peek() == CH_CL) { - this._read(); - this._ann.push(new IonSymbolToken_1.SymbolToken(s)); - is_ann = true; - } else { - this._unread(ch); - this._value_push(t); - is_ann = false; - } - return is_ann; - } - }, { - key: "_read_clob_string2", - value: function _read_clob_string2() { - var t; - this._read_string2(); - t = this._value_pop(); - if (t != T_STRING2) { - this._error("string expected"); - } - this._value_push(T_CLOB2); - this._ops.unshift(this._read_close_double_brace); - } - }, { - key: "_read_clob_string3", - value: function _read_clob_string3() { - var t; - this._read_string3(false); - t = this._value_pop(); - if (t != T_STRING3) { - this._error("string expected"); - } - this._value_push(T_CLOB3); - this._ops.unshift(this._read_close_double_brace); - } - }, { - key: "_read_blob", - value: function _read_blob() { - var ch, - base64_chars = 0, - trailers = 0; - this._start = this._in.position(); - while (true) { - ch = this._read(); - if (IonText_1.is_base64_char(ch)) { - base64_chars++; - this._end = this._in.position(); - } else if (!IonText_1.is_whitespace(ch)) { - break; + ch = this._get_N_hexdigits(ii + 2, ii + 6); + this._esc_len = 5; + break; + case ESC_U: + if (ii + 9 >= end) { + throw new Error("invalid escape sequence"); } - } - while (ch == CH_EQ) { - trailers++; - ch = this._read_after_whitespace(false); - } - if (ch != CH_CC || this._read() != CH_CC) { - throw new Error("Invalid blob"); - } - if (!is_valid_base64_length(base64_chars, trailers)) { - throw new Error("Invalid base64 value"); - } - this._value_push(T_BLOB); + ch = this._get_N_hexdigits(ii + 2, ii + 10); + this._esc_len = 9; + break; + default: + throw new Error("unexpected character after escape slash"); } - }, { - key: "_read_close_double_brace", - value: function _read_close_double_brace() { - var ch = this._read_after_whitespace(false); - if (ch != CH_CC || this._read() != CH_CC) { - this._error("expected '}}'"); - } + return ch; + } + _get_N_hexdigits(ii, end) { + let ch, + v = 0; + while (ii < end) { + ch = this._in.valueAt(ii); + v = v * 16 + get_hex_value(ch); + ii++; } - }, { - key: "isHighSurrogate", - value: function isHighSurrogate(ch) { - return ch >= 0xd800 && ch <= 0xdbff; + return v; + } + _value_push(t) { + if (this._value_type !== ERROR) { + this._error("unexpected double push of value type!"); } - }, { - key: "isLowSurrogate", - value: function isLowSurrogate(ch) { - return ch >= 0xdc00 && ch <= 0xdfff; + this._value_type = t; + } + _value_pop() { + const t = this._value_type; + this._value_type = ERROR; + return t; + } + _run() { + let op; + while (this._ops.length > 0 && this._value_type === ERROR) { + op = this._ops.shift(); + op.call(this); } - }, { - key: "indexWhiteSpace", - value: function indexWhiteSpace(index, acceptComments) { - var ch = this._in.valueAt(index); - if (!acceptComments) { - for (; IonText_1.is_whitespace(ch); ch = this._in.valueAt(index++)) {} + } + _read() { + const ch = this._in.next(); + return ch; + } + _read_skipping_comments() { + let ch = this._read(); + if (ch == CH_FORWARD_SLASH) { + ch = this._read(); + if (ch == CH_FORWARD_SLASH) { + this._read_to_newline(); + ch = IonText_1.WHITESPACE_COMMENT1; + } else if (ch == CH_AS) { + this._read_to_close_comment(); + ch = IonText_1.WHITESPACE_COMMENT2; } else { - for (; IonText_1.is_whitespace(ch) || ch === CH_FORWARD_SLASH; ch = this._in.valueAt(index++)) { - if (ch === CH_FORWARD_SLASH) { - ch = this._in.valueAt(index++); - switch (ch) { - case CH_FORWARD_SLASH: - index = this.indexToNewLine(index); - break; - case CH_AS: - index = this.indexToCloseComment(index); - break; - default: - index--; - break; - } - } - } + this._unread(ch); + ch = CH_FORWARD_SLASH; } - return index; } - }, { - key: "indexToNewLine", - value: function indexToNewLine(index) { - var ch = this._in.valueAt(index); - while (ch !== EOF && ch !== CH_NL) { - if (ch === CH_CR) { - if (this._in.valueAt(index + 1) !== CH_NL) { - return index; - } - } - ch = this._in.valueAt(index++); + return ch; + } + _read_to_newline() { + let ch; + for (;;) { + ch = this._read(); + if (ch == EOF) { + break; } - return index; - } - }, { - key: "indexToCloseComment", - value: function indexToCloseComment(index) { - while (this._in.valueAt(index) !== CH_AS && this._in.valueAt(index + 1) !== CH_FORWARD_SLASH) { - index++; + if (ch == CH_NL) { + break; } - return index; - } - }, { - key: "_skip_triple_quote_gap", - value: function _skip_triple_quote_gap(entryIndex, end, acceptComments) { - var tempIndex = entryIndex + 3; - tempIndex = this.indexWhiteSpace(tempIndex, acceptComments); - if (tempIndex + 2 <= end && this.verifyTriple(tempIndex)) { - return tempIndex + 4; - } else { - return tempIndex + 1; - } - } - }, { - key: "readClobEscapes", - value: function readClobEscapes(ii, end) { - var ch; - if (ii + 1 >= end) { - throw new Error("invalid escape sequence"); - } - ch = this._in.valueAt(ii + 1); - this._esc_len = 1; - switch (ch) { - case ESC_0: - return 0; - case ESC_a: - return 7; - case ESC_b: - return 8; - case ESC_t: - return 9; - case ESC_nl: - return 10; - case ESC_ff: - return 12; - case ESC_cr: - return 13; - case ESC_v: - return 11; - case ESC_dq: - return 34; - case ESC_sq: - return 39; - case ESC_qm: - return 63; - case ESC_bs: - return 92; - case ESC_fs: - return 47; - case ESC_nl2: - return -1; - case ESC_nl3: - if (ii + 2 < end && this._in.valueAt(ii + 2) == CH_NL) { - this._esc_len = 2; - } - return IonText_1.ESCAPED_NEWLINE; - case ESC_x: - if (ii + 3 >= end) { - throw new Error("invalid escape sequence"); - } - ch = this._get_N_hexdigits(ii + 2, ii + 4); - this._esc_len = 3; - break; - default: - throw new Error("Invalid escape: /" + ch); - } - return ch; - } - }, { - key: "_read_escape_sequence", - value: function _read_escape_sequence(ii, end) { - var ch; - if (ii + 1 >= end) { - throw new Error("Invalid escape sequence."); - } - ch = this._in.valueAt(ii + 1); - this._esc_len = 1; - switch (ch) { - case ESC_0: - return 0; - case ESC_a: - return 7; - case ESC_b: - return 8; - case ESC_t: - return 9; - case ESC_nl: - return 10; - case ESC_ff: - return 12; - case ESC_cr: - return 13; - case ESC_v: - return 11; - case ESC_dq: - return 34; - case ESC_sq: - return 39; - case ESC_qm: - return 63; - case ESC_bs: - return 92; - case ESC_fs: - return 47; - case ESC_nl2: - return -1; - case ESC_nl3: - if (ii + 2 < end && this._in.valueAt(ii + 2) == CH_NL) { - this._esc_len = 2; - } - return IonText_1.ESCAPED_NEWLINE; - case ESC_x: - if (ii + 3 >= end) { - throw new Error("invalid escape sequence"); - } - ch = this._get_N_hexdigits(ii + 2, ii + 4); - this._esc_len = 3; - break; - case ESC_u: - if (ii + 5 >= end) { - throw new Error("invalid escape sequence"); - } - ch = this._get_N_hexdigits(ii + 2, ii + 6); - this._esc_len = 5; - break; - case ESC_U: - if (ii + 9 >= end) { - throw new Error("invalid escape sequence"); - } - ch = this._get_N_hexdigits(ii + 2, ii + 10); - this._esc_len = 9; - break; - default: - throw new Error("unexpected character after escape slash"); - } - return ch; - } - }, { - key: "_get_N_hexdigits", - value: function _get_N_hexdigits(ii, end) { - var ch, - v = 0; - while (ii < end) { - ch = this._in.valueAt(ii); - v = v * 16 + get_hex_value(ch); - ii++; - } - return v; - } - }, { - key: "_value_push", - value: function _value_push(t) { - if (this._value_type !== ERROR) { - this._error("unexpected double push of value type!"); - } - this._value_type = t; - } - }, { - key: "_value_pop", - value: function _value_pop() { - var t = this._value_type; - this._value_type = ERROR; - return t; - } - }, { - key: "_run", - value: function _run() { - var op; - while (this._ops.length > 0 && this._value_type === ERROR) { - op = this._ops.shift(); - op.call(this); - } - } - }, { - key: "_read", - value: function _read() { - var ch = this._in.next(); - return ch; - } - }, { - key: "_read_skipping_comments", - value: function _read_skipping_comments() { - var ch = this._read(); - if (ch == CH_FORWARD_SLASH) { + if (ch == CH_CR) { ch = this._read(); - if (ch == CH_FORWARD_SLASH) { - this._read_to_newline(); - ch = IonText_1.WHITESPACE_COMMENT1; - } else if (ch == CH_AS) { - this._read_to_close_comment(); - ch = IonText_1.WHITESPACE_COMMENT2; - } else { + if (ch != CH_NL) { this._unread(ch); - ch = CH_FORWARD_SLASH; } + break; } - return ch; } - }, { - key: "_read_to_newline", - value: function _read_to_newline() { - var ch; - for (;;) { - ch = this._read(); - if (ch == EOF) { - break; - } - if (ch == CH_NL) { - break; - } - if (ch == CH_CR) { - ch = this._read(); - if (ch != CH_NL) { - this._unread(ch); - } - break; - } + } + _read_to_close_comment() { + let ch; + for (;;) { + ch = this._read(); + if (ch == EOF) { + break; } - } - }, { - key: "_read_to_close_comment", - value: function _read_to_close_comment() { - var ch; - for (;;) { + if (ch == CH_AS) { ch = this._read(); - if (ch == EOF) { + if (ch == CH_FORWARD_SLASH) { break; } - if (ch == CH_AS) { - ch = this._read(); - if (ch == CH_FORWARD_SLASH) { - break; - } - } } } - }, { - key: "_unread", - value: function _unread(ch) { - this._in.unread(ch); - } - }, { - key: "_read_after_whitespace", - value: function _read_after_whitespace(recognize_comments) { - var ch; - if (recognize_comments) { + } + _unread(ch) { + this._in.unread(ch); + } + _read_after_whitespace(recognize_comments) { + let ch; + if (recognize_comments) { + ch = this._read_skipping_comments(); + while (IonText_1.is_whitespace(ch)) { ch = this._read_skipping_comments(); - while (IonText_1.is_whitespace(ch)) { - ch = this._read_skipping_comments(); - } - } else { - ch = this._read(); - while (IonText_1.is_whitespace(ch)) { - ch = this._read(); - } - } - return ch; - } - }, { - key: "_peek", - value: function _peek(expected) { - var ch, - ii = 0; - if (expected === undefined || expected.length < 1) { - return this._in.valueAt(this._in.position()); } - while (ii < expected.length) { - ch = this._read(); - if (ch != expected.charCodeAt(ii)) { - break; - } - ii++; - } - if (ii === expected.length) { - ch = this._peek(); - } else { - this._unread(ch); - ch = ERROR; - } - while (ii > 0) { - ii--; - this._unread(expected.charCodeAt(ii)); - } - return ch; - } - }, { - key: "_peek_4_digits", - value: function _peek_4_digits(ch1) { - var ii, - ch, - is_digits = true; - var chars = []; - if (!IonText_1.is_digit(ch1)) { - return ERROR; - } - for (ii = 0; ii < 3; ii++) { + } else { + ch = this._read(); + while (IonText_1.is_whitespace(ch)) { ch = this._read(); - chars.push(ch); - if (!IonText_1.is_digit(ch)) { - is_digits = false; - break; - } } - ch = is_digits && ii == 3 ? this._peek() : ERROR; - while (chars.length > 0) { - this._unread(chars.pop()); + } + return ch; + } + _peek(expected) { + let ch, + ii = 0; + if (expected === undefined || expected.length < 1) { + return this._in.valueAt(this._in.position()); + } + while (ii < expected.length) { + ch = this._read(); + if (ch != expected.charCodeAt(ii)) { + break; } - return ch; + ii++; + } + if (ii === expected.length) { + ch = this._peek(); + } else { + this._unread(ch); + ch = ERROR; + } + while (ii > 0) { + ii--; + this._unread(expected.charCodeAt(ii)); + } + return ch; + } + _peek_4_digits(ch1) { + let ii, + ch, + is_digits = true; + const chars = []; + if (!IonText_1.is_digit(ch1)) { + return ERROR; } - }, { - key: "_read_required_digits", - value: function _read_required_digits(ch) { + for (ii = 0; ii < 3; ii++) { + ch = this._read(); + chars.push(ch); if (!IonText_1.is_digit(ch)) { - return ERROR; - } - for (;;) { - ch = this._read(); - if (!IonText_1.is_digit(ch)) { - break; - } + is_digits = false; + break; } - return ch; } - }, { - key: "_read_optional_digits", - value: function _read_optional_digits(ch) { - while (IonText_1.is_digit(ch)) { - ch = this._read(); - } - return ch; + ch = is_digits && ii == 3 ? this._peek() : ERROR; + while (chars.length > 0) { + this._unread(chars.pop()); + } + return ch; + } + _read_required_digits(ch) { + if (!IonText_1.is_digit(ch)) { + return ERROR; } - }, { - key: "_readNDigits", - value: function _readNDigits(n) { - var ch; - if (n <= 0) { - throw new Error("Cannot read a lack of or negative number of digits."); + for (;;) { + ch = this._read(); + if (!IonText_1.is_digit(ch)) { + break; } - while (n--) { - if (!IonText_1.is_digit(ch = this._read())) { - throw new Error("Expected digit, got: " + String.fromCharCode(ch)); - } + } + return ch; + } + _read_optional_digits(ch) { + while (IonText_1.is_digit(ch)) { + ch = this._read(); + } + return ch; + } + _readNDigits(n) { + let ch; + if (n <= 0) { + throw new Error("Cannot read a lack of or negative number of digits."); + } + while (n--) { + if (!IonText_1.is_digit(ch = this._read())) { + throw new Error("Expected digit, got: " + String.fromCharCode(ch)); } - return ch; } - }, { - key: "_readPastNDigits", - value: function _readPastNDigits(n) { - this._readNDigits(n); - return this._read(); + return ch; + } + _readPastNDigits(n) { + this._readNDigits(n); + return this._read(); + } + _read_required_hex_digits(ch) { + if (!IonText_1.is_hex_digit(ch)) { + return ERROR; + } + for (;;) { + ch = this._read(); + if (!IonText_1.is_hex_digit(ch)) { + break; + } } - }, { - key: "_read_required_hex_digits", - value: function _read_required_hex_digits(ch) { + return ch; + } + _read_N_hexdigits(n) { + let ch, + ii = 0; + while (ii < n) { + ch = this._read(); if (!IonText_1.is_hex_digit(ch)) { + this._error("" + n + " digits required " + ii + " found"); return ERROR; } - for (;;) { - ch = this._read(); - if (!IonText_1.is_hex_digit(ch)) { - break; - } - } - return ch; + ii++; } - }, { - key: "_read_N_hexdigits", - value: function _read_N_hexdigits(n) { - var ch, - ii = 0; - while (ii < n) { - ch = this._read(); - if (!IonText_1.is_hex_digit(ch)) { - this._error("" + n + " digits required " + ii + " found"); - return ERROR; - } - ii++; - } - return ch; + return ch; + } + _parseSymbolId(s) { + if (s[0] !== "$") { + return NaN; } - }, { - key: "_parseSymbolId", - value: function _parseSymbolId(s) { - if (s[0] !== "$") { + for (let i = 1; i < s.length; i++) { + if (s[i] < "0" || s[i] > "9") { return NaN; } - for (var i = 1; i < s.length; i++) { - if (s[i] < "0" || s[i] > "9") { - return NaN; - } - } - return parseInt(s.substr(1, s.length)); } - }, { - key: "_error", - value: function _error(msg) { - this._ops.unshift(this._done_with_error); - this._error_msg = msg; - } - }]); - return ParserTextRaw; -}(); + return parseInt(s.substr(1, s.length)); + } + _error(msg) { + this._ops.unshift(this._done_with_error); + this._error_msg = msg; + } +} exports.ParserTextRaw = ParserTextRaw; -},{"./IonSymbolToken":21,"./IonText":24,"./IonTypes":29,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],17:[function(require,module,exports){ +},{"./IonSymbolToken":21,"./IonText":24,"./IonTypes":29}],17:[function(require,module,exports){ "use strict"; /*! @@ -5095,182 +4338,149 @@ exports.ParserTextRaw = ParserTextRaw; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.PrettyTextWriter = void 0; -var IonText_1 = require("./IonText"); -var IonTextWriter_1 = require("./IonTextWriter"); -var IonTypes_1 = require("./IonTypes"); -var PrettyTextWriter = /*#__PURE__*/function (_IonTextWriter_1$Text) { - (0, _inherits2["default"])(PrettyTextWriter, _IonTextWriter_1$Text); - var _super = _createSuper(PrettyTextWriter); - function PrettyTextWriter(writeable) { - var _this; - var indentSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; - (0, _classCallCheck2["default"])(this, PrettyTextWriter); - _this = _super.call(this, writeable); - _this.indentSize = indentSize; - _this.indentCount = 0; - return _this; - } - (0, _createClass2["default"])(PrettyTextWriter, [{ - key: "writeFieldName", - value: function writeFieldName(fieldName) { - if (this.currentContainer.containerType !== IonTypes_1.IonTypes.STRUCT) { - throw new Error("Cannot write field name outside of a struct"); - } - if (this.currentContainer.state !== IonTextWriter_1.State.STRUCT_FIELD) { - throw new Error("Expecting a struct value"); - } - if (!this.currentContainer.clean) { - this.writeable.writeByte(IonText_1.CharCodes.COMMA); - this.writePrettyNewLine(0); - } - this.writePrettyIndent(0); - this.writeSymbolToken(fieldName); - this.writeable.writeByte(IonText_1.CharCodes.COLON); - this.writeable.writeByte(IonText_1.CharCodes.SPACE); - this.currentContainer.state = IonTextWriter_1.State.VALUE; - } - }, { - key: "writeNull", - value: function writeNull(type) { - if (type === undefined || type === null) { - type = IonTypes_1.IonTypes.NULL; - } - this.handleSeparator(); - this.writePrettyValue(); - this.writeAnnotations(); - this._writeNull(type); - if (this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT) { - this.currentContainer.state = IonTextWriter_1.State.STRUCT_FIELD; - } - } - }, { - key: "stepOut", - value: function stepOut() { - var currentContainer = this.containerContext.pop(); - if (!currentContainer || !currentContainer.containerType) { - throw new Error("Can't step out when not in a container"); - } else if (currentContainer.containerType === IonTypes_1.IonTypes.STRUCT && currentContainer.state === IonTextWriter_1.State.VALUE) { - throw new Error("Expecting a struct value"); - } - if (!currentContainer.clean) { - this.writePrettyNewLine(0); - } - this.writePrettyIndent(-1); - switch (currentContainer.containerType) { - case IonTypes_1.IonTypes.LIST: - this.writeable.writeByte(IonText_1.CharCodes.RIGHT_BRACKET); - break; - case IonTypes_1.IonTypes.SEXP: - this.writeable.writeByte(IonText_1.CharCodes.RIGHT_PARENTHESIS); - break; - case IonTypes_1.IonTypes.STRUCT: - this.writeable.writeByte(IonText_1.CharCodes.RIGHT_BRACE); - break; - default: - throw new Error("Unexpected container type"); - } +const IonText_1 = require("./IonText"); +const IonTextWriter_1 = require("./IonTextWriter"); +const IonTypes_1 = require("./IonTypes"); +class PrettyTextWriter extends IonTextWriter_1.TextWriter { + constructor(writeable) { + let indentSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; + super(writeable); + this.indentSize = indentSize; + this.indentCount = 0; + } + writeFieldName(fieldName) { + if (this.currentContainer.containerType !== IonTypes_1.IonTypes.STRUCT) { + throw new Error("Cannot write field name outside of a struct"); + } + if (this.currentContainer.state !== IonTextWriter_1.State.STRUCT_FIELD) { + throw new Error("Expecting a struct value"); + } + if (!this.currentContainer.clean) { + this.writeable.writeByte(IonText_1.CharCodes.COMMA); + this.writePrettyNewLine(0); + } + this.writePrettyIndent(0); + this.writeSymbolToken(fieldName); + this.writeable.writeByte(IonText_1.CharCodes.COLON); + this.writeable.writeByte(IonText_1.CharCodes.SPACE); + this.currentContainer.state = IonTextWriter_1.State.VALUE; + } + writeNull(type) { + if (type === undefined || type === null) { + type = IonTypes_1.IonTypes.NULL; + } + this.handleSeparator(); + this.writePrettyValue(); + this.writeAnnotations(); + this._writeNull(type); + if (this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT) { + this.currentContainer.state = IonTextWriter_1.State.STRUCT_FIELD; + } + } + stepOut() { + const currentContainer = this.containerContext.pop(); + if (!currentContainer || !currentContainer.containerType) { + throw new Error("Can't step out when not in a container"); + } else if (currentContainer.containerType === IonTypes_1.IonTypes.STRUCT && currentContainer.state === IonTextWriter_1.State.VALUE) { + throw new Error("Expecting a struct value"); + } + if (!currentContainer.clean) { + this.writePrettyNewLine(0); + } + this.writePrettyIndent(-1); + switch (currentContainer.containerType) { + case IonTypes_1.IonTypes.LIST: + this.writeable.writeByte(IonText_1.CharCodes.RIGHT_BRACKET); + break; + case IonTypes_1.IonTypes.SEXP: + this.writeable.writeByte(IonText_1.CharCodes.RIGHT_PARENTHESIS); + break; + case IonTypes_1.IonTypes.STRUCT: + this.writeable.writeByte(IonText_1.CharCodes.RIGHT_BRACE); + break; + default: + throw new Error("Unexpected container type"); } - }, { - key: "_serializeValue", - value: function _serializeValue(type, value, serialize) { - if (this.currentContainer.state === IonTextWriter_1.State.STRUCT_FIELD) { - throw new Error("Expecting a struct field"); - } - if (value === null) { - this.writeNull(type); - return; + } + _serializeValue(type, value, serialize) { + if (this.currentContainer.state === IonTextWriter_1.State.STRUCT_FIELD) { + throw new Error("Expecting a struct field"); + } + if (value === null) { + this.writeNull(type); + return; + } + this.handleSeparator(); + this.writePrettyValue(); + this.writeAnnotations(); + serialize(value); + if (this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT) { + this.currentContainer.state = IonTextWriter_1.State.STRUCT_FIELD; + } + } + writeContainer(type, openingCharacter) { + if (this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT && this.currentContainer.state === IonTextWriter_1.State.VALUE) { + this.currentContainer.state = IonTextWriter_1.State.STRUCT_FIELD; + } + this.handleSeparator(); + this.writePrettyValue(); + this.writeAnnotations(); + this.writeable.writeByte(openingCharacter); + this.writePrettyNewLine(1); + this._stepIn(type); + } + handleSeparator() { + if (this.depth() === 0) { + if (this.currentContainer.clean) { + this.currentContainer.clean = false; + } else { + this.writeable.writeByte(IonText_1.CharCodes.LINE_FEED); } - this.handleSeparator(); - this.writePrettyValue(); - this.writeAnnotations(); - serialize(value); - if (this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT) { - this.currentContainer.state = IonTextWriter_1.State.STRUCT_FIELD; - } - } - }, { - key: "writeContainer", - value: function writeContainer(type, openingCharacter) { - if (this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT && this.currentContainer.state === IonTextWriter_1.State.VALUE) { - this.currentContainer.state = IonTextWriter_1.State.STRUCT_FIELD; - } - this.handleSeparator(); - this.writePrettyValue(); - this.writeAnnotations(); - this.writeable.writeByte(openingCharacter); - this.writePrettyNewLine(1); - this._stepIn(type); - } - }, { - key: "handleSeparator", - value: function handleSeparator() { - if (this.depth() === 0) { - if (this.currentContainer.clean) { - this.currentContainer.clean = false; - } else { - this.writeable.writeByte(IonText_1.CharCodes.LINE_FEED); - } + } else { + if (this.currentContainer.clean) { + this.currentContainer.clean = false; } else { - if (this.currentContainer.clean) { - this.currentContainer.clean = false; - } else { - switch (this.currentContainer.containerType) { - case IonTypes_1.IonTypes.LIST: - this.writeable.writeByte(IonText_1.CharCodes.COMMA); - this.writePrettyNewLine(0); - break; - case IonTypes_1.IonTypes.SEXP: - this.writeable.writeByte(IonText_1.CharCodes.SPACE); - this.writePrettyNewLine(0); - break; - default: - } + switch (this.currentContainer.containerType) { + case IonTypes_1.IonTypes.LIST: + this.writeable.writeByte(IonText_1.CharCodes.COMMA); + this.writePrettyNewLine(0); + break; + case IonTypes_1.IonTypes.SEXP: + this.writeable.writeByte(IonText_1.CharCodes.SPACE); + this.writePrettyNewLine(0); + break; + default: } } } - }, { - key: "writePrettyValue", - value: function writePrettyValue() { - if (this.depth() > 0 && this.currentContainer.containerType && this.currentContainer.containerType !== IonTypes_1.IonTypes.STRUCT) { - this.writePrettyIndent(0); - } + } + writePrettyValue() { + if (this.depth() > 0 && this.currentContainer.containerType && this.currentContainer.containerType !== IonTypes_1.IonTypes.STRUCT) { + this.writePrettyIndent(0); } - }, { - key: "writePrettyNewLine", - value: function writePrettyNewLine(incrementValue) { - this.indentCount = this.indentCount + incrementValue; - if (this.indentSize && this.indentSize > 0) { - this.writeable.writeByte(IonText_1.CharCodes.LINE_FEED); - } + } + writePrettyNewLine(incrementValue) { + this.indentCount = this.indentCount + incrementValue; + if (this.indentSize && this.indentSize > 0) { + this.writeable.writeByte(IonText_1.CharCodes.LINE_FEED); } - }, { - key: "writePrettyIndent", - value: function writePrettyIndent(incrementValue) { - this.indentCount = this.indentCount + incrementValue; - if (this.indentSize && this.indentSize > 0) { - for (var i = 0; i < this.indentCount * this.indentSize; i++) { - this.writeable.writeByte(IonText_1.CharCodes.SPACE); - } + } + writePrettyIndent(incrementValue) { + this.indentCount = this.indentCount + incrementValue; + if (this.indentSize && this.indentSize > 0) { + for (let i = 0; i < this.indentCount * this.indentSize; i++) { + this.writeable.writeByte(IonText_1.CharCodes.SPACE); } } - }]); - return PrettyTextWriter; -}(IonTextWriter_1.TextWriter); + } +} exports.PrettyTextWriter = PrettyTextWriter; -},{"./IonText":24,"./IonTextWriter":26,"./IonTypes":29,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],18:[function(require,module,exports){ +},{"./IonText":24,"./IonTextWriter":26,"./IonTypes":29}],18:[function(require,module,exports){ "use strict"; /*! @@ -5287,62 +4497,46 @@ exports.PrettyTextWriter = PrettyTextWriter; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); Object.defineProperty(exports, "__esModule", { value: true }); exports.SharedSymbolTable = void 0; -var SharedSymbolTable = /*#__PURE__*/function () { - function SharedSymbolTable(_name, _version, _symbols) { - (0, _classCallCheck2["default"])(this, SharedSymbolTable); +class SharedSymbolTable { + constructor(_name, _version, _symbols) { this._name = _name; this._version = _version; this._symbols = _symbols; this._idsByText = new Map(); this._numberOfSymbols = this._symbols.length; - for (var m = _symbols.length - 1; m >= 0; m--) { + for (let m = _symbols.length - 1; m >= 0; m--) { this._idsByText.set(_symbols[m], m); } } - (0, _createClass2["default"])(SharedSymbolTable, [{ - key: "numberOfSymbols", - get: function get() { - return this._numberOfSymbols; - } - }, { - key: "name", - get: function get() { - return this._name; - } - }, { - key: "version", - get: function get() { - return this._version; - } - }, { - key: "getSymbolText", - value: function getSymbolText(symbolId) { - if (symbolId < 0) { - throw new Error("Index ".concat(symbolId, " is out of bounds for the SharedSymbolTable name=").concat(this.name, ", version=").concat(this.version)); - } - if (symbolId >= this.numberOfSymbols) { - return undefined; - } - return this._symbols[symbolId]; + get numberOfSymbols() { + return this._numberOfSymbols; + } + get name() { + return this._name; + } + get version() { + return this._version; + } + getSymbolText(symbolId) { + if (symbolId < 0) { + throw new Error(`Index ${symbolId} is out of bounds for the SharedSymbolTable name=${this.name}, version=${this.version}`); } - }, { - key: "getSymbolId", - value: function getSymbolId(text) { - return this._idsByText.get(text); + if (symbolId >= this.numberOfSymbols) { + return undefined; } - }]); - return SharedSymbolTable; -}(); + return this._symbols[symbolId]; + } + getSymbolId(text) { + return this._idsByText.get(text); + } +} exports.SharedSymbolTable = SharedSymbolTable; -},{"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],19:[function(require,module,exports){ +},{}],19:[function(require,module,exports){ "use strict"; /*! @@ -5359,295 +4553,210 @@ exports.SharedSymbolTable = SharedSymbolTable; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.BinarySpan = exports.StringSpan = exports.Span = void 0; -var IonConstants_1 = require("./IonConstants"); -var SPAN_TYPE_STRING = 0; -var SPAN_TYPE_BINARY = 1; -var SPAN_TYPE_SUB_FLAG = 2; -var SPAN_TYPE_SUB_STRING = SPAN_TYPE_SUB_FLAG | SPAN_TYPE_STRING; -var SPAN_TYPE_SUB_BINARY = SPAN_TYPE_SUB_FLAG | SPAN_TYPE_BINARY; -var MAX_POS = 1024 * 1024 * 1024; -var LINE_FEED = 10; -var CARRAIGE_RETURN = 13; -var DEBUG_FLAG = true; -var Span = /*#__PURE__*/function () { - function Span(_type) { - (0, _classCallCheck2["default"])(this, Span); +const IonConstants_1 = require("./IonConstants"); +const SPAN_TYPE_STRING = 0; +const SPAN_TYPE_BINARY = 1; +const SPAN_TYPE_SUB_FLAG = 2; +const SPAN_TYPE_SUB_STRING = SPAN_TYPE_SUB_FLAG | SPAN_TYPE_STRING; +const SPAN_TYPE_SUB_BINARY = SPAN_TYPE_SUB_FLAG | SPAN_TYPE_BINARY; +const MAX_POS = 1024 * 1024 * 1024; +const LINE_FEED = 10; +const CARRAIGE_RETURN = 13; +const DEBUG_FLAG = true; +class Span { + constructor(_type) { this._type = _type; } - (0, _createClass2["default"])(Span, [{ - key: "write", - value: function write(b) { - throw new Error("not implemented"); - } - }], [{ - key: "error", - value: function error() { - throw new Error("span error"); - } - }]); - return Span; -}(); + static error() { + throw new Error("span error"); + } + write(b) { + throw new Error("not implemented"); + } +} exports.Span = Span; -var StringSpan = /*#__PURE__*/function (_Span) { - (0, _inherits2["default"])(StringSpan, _Span); - var _super = _createSuper(StringSpan); - function StringSpan(src) { - var _this; - (0, _classCallCheck2["default"])(this, StringSpan); - _this = _super.call(this, SPAN_TYPE_STRING); - _this._line = 1; - _this._src = src; - _this._limit = src.length; - _this._start = 0; - _this._pos = 0; - _this._line_start = 0; - _this._old_line_start = 0; - return _this; - } - (0, _createClass2["default"])(StringSpan, [{ - key: "viewSource", - value: function viewSource() { - return this._src; - } - }, { - key: "position", - value: function position() { - return this._pos - this._start; - } - }, { - key: "getRemaining", - value: function getRemaining() { - return this._limit - this._pos; - } - }, { - key: "setRemaining", - value: function setRemaining(r) { - this._limit = r + this._pos; - } - }, { - key: "is_empty", - value: function is_empty() { - return this._pos >= this._limit; - } - }, { - key: "next", - value: function next() { - var ch; - if (this.is_empty()) { - if (this._pos > MAX_POS) { - throw new Error("span position is out of bounds"); - } - this._pos++; - return IonConstants_1.EOF; - } - ch = this._src.charCodeAt(this._pos); - if (ch === CARRAIGE_RETURN) { - if (this.peek() != LINE_FEED) { - this._inc_line(); - } - } else if (ch == LINE_FEED) { - this._inc_line(); +class StringSpan extends Span { + constructor(src) { + super(SPAN_TYPE_STRING); + this._line = 1; + this._src = src; + this._limit = src.length; + this._start = 0; + this._pos = 0; + this._line_start = 0; + this._old_line_start = 0; + } + viewSource() { + return this._src; + } + position() { + return this._pos - this._start; + } + getRemaining() { + return this._limit - this._pos; + } + setRemaining(r) { + this._limit = r + this._pos; + } + is_empty() { + return this._pos >= this._limit; + } + next() { + let ch; + if (this.is_empty()) { + if (this._pos > MAX_POS) { + throw new Error("span position is out of bounds"); } this._pos++; - return ch; - } - }, { - key: "_inc_line", - value: function _inc_line() { - this._old_line_start = this._line_start; - this._line++; - this._line_start = this._pos; - } - }, { - key: "unread", - value: function unread(ch) { - if (this._pos <= this._start) { - Span.error(); - } - this._pos--; - if (ch < 0) { - if (this.is_empty() != true) { - Span.error(); - } - return; - } - if (this._pos == this._line_start) { - this._line_start = this._old_line_start; - this._line--; - } - if (ch != this.peek()) { + return IonConstants_1.EOF; + } + ch = this._src.charCodeAt(this._pos); + if (ch === CARRAIGE_RETURN) { + if (this.peek() != LINE_FEED) { + this._inc_line(); + } + } else if (ch == LINE_FEED) { + this._inc_line(); + } + this._pos++; + return ch; + } + _inc_line() { + this._old_line_start = this._line_start; + this._line++; + this._line_start = this._pos; + } + unread(ch) { + if (this._pos <= this._start) { + Span.error(); + } + this._pos--; + if (ch < 0) { + if (this.is_empty() != true) { Span.error(); } + return; + } + if (this._pos == this._line_start) { + this._line_start = this._old_line_start; + this._line--; + } + if (ch != this.peek()) { + Span.error(); } - }, { - key: "peek", - value: function peek() { - return this.valueAt(this._pos); - } - }, { - key: "skip", - value: function skip(dist) { - this._pos += dist; - if (this._pos > this._limit) { - this._pos = this._limit; - } - } - }, { - key: "valueAt", - value: function valueAt(ii) { - if (ii < this._start || ii >= this._limit) { - return IonConstants_1.EOF; - } - return this._src.charCodeAt(ii); - } - }, { - key: "chunk", - value: function chunk(length) { - var tempStr = this._src.substr(this._pos, length); - this._pos += length; - return tempStr; - } - }, { - key: "getCodePoint", - value: function getCodePoint(index) { - return this._src.codePointAt(index); - } - }, { - key: "line_number", - value: function line_number() { - return this._line; - } - }, { - key: "offset", - value: function offset() { - return this._pos - this._line_start; - } - }, { - key: "clone", - value: function clone(start) { - return new StringSpan(this._src.substr(this._pos)); - } - }]); - return StringSpan; -}(Span); + } + peek() { + return this.valueAt(this._pos); + } + skip(dist) { + this._pos += dist; + if (this._pos > this._limit) { + this._pos = this._limit; + } + } + valueAt(ii) { + if (ii < this._start || ii >= this._limit) { + return IonConstants_1.EOF; + } + return this._src.charCodeAt(ii); + } + chunk(length) { + const tempStr = this._src.substr(this._pos, length); + this._pos += length; + return tempStr; + } + getCodePoint(index) { + return this._src.codePointAt(index); + } + line_number() { + return this._line; + } + offset() { + return this._pos - this._line_start; + } + clone(start) { + return new StringSpan(this._src.substr(this._pos)); + } +} exports.StringSpan = StringSpan; -var BinarySpan = /*#__PURE__*/function (_Span2) { - (0, _inherits2["default"])(BinarySpan, _Span2); - var _super2 = _createSuper(BinarySpan); - function BinarySpan(src) { - var _this2; - (0, _classCallCheck2["default"])(this, BinarySpan); - _this2 = _super2.call(this, SPAN_TYPE_BINARY); - _this2._src = src; - _this2._limit = src.length; - _this2._start = 0; - _this2._pos = 0; - return _this2; - } - (0, _createClass2["default"])(BinarySpan, [{ - key: "position", - value: function position() { - return this._pos - this._start; - } - }, { - key: "getRemaining", - value: function getRemaining() { - return this._limit - this._pos; - } - }, { - key: "setRemaining", - value: function setRemaining(r) { - this._limit = r + this._pos; - } - }, { - key: "is_empty", - value: function is_empty() { - return this._pos >= this._limit; - } - }, { - key: "next", - value: function next() { - if (this.is_empty()) { - return IonConstants_1.EOF; - } - return this._src[this._pos++]; - } - }, { - key: "view", - value: function view(length) { - if (this._pos + length > this._limit) { - throw new Error("Unable to read " + length + " bytes (position: " + this.position() + ", limit: " + this._limit + ")"); - } - return this._src.subarray(this._pos, this._pos += length); - } - }, { - key: "chunk", - value: function chunk(length) { - return new Uint8Array(this.view(length)); - } - }, { - key: "unread", - value: function unread(b) { - if (this._pos <= this._start) { - Span.error(); - } - this._pos--; - if (b == IonConstants_1.EOF) { - if (this.is_empty() == false) { - Span.error(); - } - } - if (b != this.peek()) { +class BinarySpan extends Span { + constructor(src) { + super(SPAN_TYPE_BINARY); + this._src = src; + this._limit = src.length; + this._start = 0; + this._pos = 0; + } + position() { + return this._pos - this._start; + } + getRemaining() { + return this._limit - this._pos; + } + setRemaining(r) { + this._limit = r + this._pos; + } + is_empty() { + return this._pos >= this._limit; + } + next() { + if (this.is_empty()) { + return IonConstants_1.EOF; + } + return this._src[this._pos++]; + } + view(length) { + if (this._pos + length > this._limit) { + throw new Error("Unable to read " + length + " bytes (position: " + this.position() + ", limit: " + this._limit + ")"); + } + return this._src.subarray(this._pos, this._pos += length); + } + chunk(length) { + return new Uint8Array(this.view(length)); + } + unread(b) { + if (this._pos <= this._start) { + Span.error(); + } + this._pos--; + if (b == IonConstants_1.EOF) { + if (this.is_empty() == false) { Span.error(); } } - }, { - key: "peek", - value: function peek() { - if (this.is_empty()) { - return IonConstants_1.EOF; - } - return this._src[this._pos]; + if (b != this.peek()) { + Span.error(); } - }, { - key: "skip", - value: function skip(dist) { - this._pos += dist; - if (this._pos > this._limit) { - throw new Error("Skipped over end of source."); - } + } + peek() { + if (this.is_empty()) { + return IonConstants_1.EOF; } - }, { - key: "valueAt", - value: function valueAt(ii) { - if (ii < this._start || ii >= this._limit) { - return IonConstants_1.EOF; - } - return this._src[ii]; + return this._src[this._pos]; + } + skip(dist) { + this._pos += dist; + if (this._pos > this._limit) { + throw new Error("Skipped over end of source."); } - }, { - key: "clone", - value: function clone(start, len) { - return new BinarySpan(this._src.subarray(this._pos)); + } + valueAt(ii) { + if (ii < this._start || ii >= this._limit) { + return IonConstants_1.EOF; } - }]); - return BinarySpan; -}(Span); + return this._src[ii]; + } + clone(start, len) { + return new BinarySpan(this._src.subarray(this._pos)); + } +} exports.BinarySpan = BinarySpan; -},{"./IonConstants":10,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],20:[function(require,module,exports){ +},{"./IonConstants":10}],20:[function(require,module,exports){ "use strict"; /*! @@ -5664,51 +4773,32 @@ exports.BinarySpan = BinarySpan; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.SubstituteSymbolTable = void 0; -var IonSharedSymbolTable_1 = require("./IonSharedSymbolTable"); -var SubstituteSymbolTable = /*#__PURE__*/function (_IonSharedSymbolTable) { - (0, _inherits2["default"])(SubstituteSymbolTable, _IonSharedSymbolTable); - var _super = _createSuper(SubstituteSymbolTable); - function SubstituteSymbolTable(length) { - var _this; - (0, _classCallCheck2["default"])(this, SubstituteSymbolTable); +const IonSharedSymbolTable_1 = require("./IonSharedSymbolTable"); +class SubstituteSymbolTable extends IonSharedSymbolTable_1.SharedSymbolTable { + constructor(length) { if (length < 0) { throw new Error("Cannot instantiate a SubstituteSymbolTable with a negative length. (" + length + ")"); } - _this = _super.call(this, "_substitute", -1, []); - _this._numberOfSymbols = length; - return _this; + super("_substitute", -1, []); + this._numberOfSymbols = length; } - (0, _createClass2["default"])(SubstituteSymbolTable, [{ - key: "getSymbolText", - value: function getSymbolText(symbolId) { - if (symbolId < 0) { - throw new Error("Index ".concat(symbolId, " is out of bounds for the SharedSymbolTable name=").concat(this.name, ", version=").concat(this.version)); - } - return undefined; + getSymbolText(symbolId) { + if (symbolId < 0) { + throw new Error(`Index ${symbolId} is out of bounds for the SharedSymbolTable name=${this.name}, version=${this.version}`); } - }, { - key: "getSymbolId", - value: function getSymbolId(text) { - return undefined; - } - }]); - return SubstituteSymbolTable; -}(IonSharedSymbolTable_1.SharedSymbolTable); + return undefined; + } + getSymbolId(text) { + return undefined; + } +} exports.SubstituteSymbolTable = SubstituteSymbolTable; -},{"./IonSharedSymbolTable":18,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],21:[function(require,module,exports){ +},{"./IonSharedSymbolTable":18}],21:[function(require,module,exports){ "use strict"; /*! @@ -5725,37 +4815,27 @@ exports.SubstituteSymbolTable = SubstituteSymbolTable; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); Object.defineProperty(exports, "__esModule", { value: true }); exports.SymbolToken = void 0; -var SymbolToken = /*#__PURE__*/function () { - function SymbolToken(text) { - var sid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SymbolToken._UNKNOWN_SYMBOL_ID; - (0, _classCallCheck2["default"])(this, SymbolToken); +class SymbolToken { + constructor(text) { + let sid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SymbolToken._UNKNOWN_SYMBOL_ID; this.text = text; this.sid = sid; } - (0, _createClass2["default"])(SymbolToken, [{ - key: "getText", - value: function getText() { - return this.text; - } - }, { - key: "getSid", - value: function getSid() { - return this.sid; - } - }]); - return SymbolToken; -}(); + getText() { + return this.text; + } + getSid() { + return this.sid; + } +} exports.SymbolToken = SymbolToken; SymbolToken._UNKNOWN_SYMBOL_ID = -1; -},{"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],22:[function(require,module,exports){ +},{}],22:[function(require,module,exports){ "use strict"; /*! @@ -5772,28 +4852,26 @@ SymbolToken._UNKNOWN_SYMBOL_ID = -1; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); Object.defineProperty(exports, "__esModule", { value: true }); exports.makeSymbolTable = exports.ion_symbol_table_sid = exports.ion_symbol_table = void 0; -var IonImport_1 = require("./IonImport"); -var IonLocalSymbolTable_1 = require("./IonLocalSymbolTable"); -var IonSubstituteSymbolTable_1 = require("./IonSubstituteSymbolTable"); -var IonSystemSymbolTable_1 = require("./IonSystemSymbolTable"); -var Ion_1 = require("./Ion"); +const IonImport_1 = require("./IonImport"); +const IonLocalSymbolTable_1 = require("./IonLocalSymbolTable"); +const IonSubstituteSymbolTable_1 = require("./IonSubstituteSymbolTable"); +const IonSystemSymbolTable_1 = require("./IonSystemSymbolTable"); +const Ion_1 = require("./Ion"); exports.ion_symbol_table = "$ion_symbol_table"; exports.ion_symbol_table_sid = 3; -var empty_struct = {}; +const empty_struct = {}; function load_imports(reader, catalog) { - var import_ = IonSystemSymbolTable_1.getSystemSymbolTableImport(); + let import_ = IonSystemSymbolTable_1.getSystemSymbolTableImport(); reader.stepIn(); while (reader.next()) { reader.stepIn(); - var name = null; - var version = 1; - var maxId = null; + let name = null; + let version = 1; + let maxId = null; while (reader.next()) { switch (reader.fieldName()) { case "name": @@ -5810,10 +4888,10 @@ function load_imports(reader, catalog) { version = 1; } if (name && name !== "$ion") { - var symbolTable = catalog.getVersion(name, version); + let symbolTable = catalog.getVersion(name, version); if (!symbolTable) { if (maxId === undefined) { - throw new Error("No exact match found when trying to import symbol table ".concat(name, " version ").concat(version)); + throw new Error(`No exact match found when trying to import symbol table ${name} version ${version}`); } else { symbolTable = catalog.getTable(name); } @@ -5829,7 +4907,7 @@ function load_imports(reader, catalog) { return import_; } function load_symbols(reader) { - var symbols = []; + const symbols = []; reader.stepIn(); while (reader.next()) { symbols.push(reader.stringValue()); @@ -5838,11 +4916,11 @@ function load_symbols(reader) { return symbols; } function makeSymbolTable(catalog, reader, currentSymbolTable) { - var import_ = null; - var symbols = []; - var foundSymbols = false; - var foundImports = false; - var foundLstAppend = false; + let import_ = null; + let symbols = []; + let foundSymbols = false; + let foundImports = false; + let foundLstAppend = false; reader.stepIn(); while (reader.next()) { switch (reader.fieldName()) { @@ -5850,18 +4928,17 @@ function makeSymbolTable(catalog, reader, currentSymbolTable) { if (foundImports) { throw new Error("Multiple import fields found."); } - var ion_type = reader.type(); + let ion_type = reader.type(); if (ion_type === Ion_1.IonTypes.SYMBOL && reader.stringValue() === exports.ion_symbol_table) { - var _symbols; - import_ = currentSymbolTable["import"]; - var symbols_ = symbols; + import_ = currentSymbolTable.import; + let symbols_ = symbols; symbols = currentSymbolTable.symbols; - (_symbols = symbols).push.apply(_symbols, (0, _toConsumableArray2["default"])(symbols_)); + symbols.push(...symbols_); foundLstAppend = true; } else if (ion_type === Ion_1.IonTypes.LIST) { import_ = load_imports(reader, catalog); } else { - throw new Error("Expected import field name to be a list or symbol found ".concat(ion_type)); + throw new Error(`Expected import field name to be a list or symbol found ${ion_type}`); } foundImports = true; break; @@ -5870,8 +4947,7 @@ function makeSymbolTable(catalog, reader, currentSymbolTable) { throw new Error("Multiple symbol fields found."); } if (foundLstAppend) { - var _symbols2; - (_symbols2 = symbols).push.apply(_symbols2, (0, _toConsumableArray2["default"])(load_symbols(reader))); + symbols.push(...load_symbols(reader)); } else { symbols = load_symbols(reader); } @@ -5884,7 +4960,7 @@ function makeSymbolTable(catalog, reader, currentSymbolTable) { } exports.makeSymbolTable = makeSymbolTable; -},{"./Ion":5,"./IonImport":12,"./IonLocalSymbolTable":13,"./IonSubstituteSymbolTable":20,"./IonSystemSymbolTable":23,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/toConsumableArray":79}],23:[function(require,module,exports){ +},{"./Ion":5,"./IonImport":12,"./IonLocalSymbolTable":13,"./IonSubstituteSymbolTable":20,"./IonSystemSymbolTable":23}],23:[function(require,module,exports){ "use strict"; /*! @@ -5905,9 +4981,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.getSystemSymbolTableImport = exports.getSystemSymbolTable = void 0; -var IonImport_1 = require("./IonImport"); -var IonSharedSymbolTable_1 = require("./IonSharedSymbolTable"); -var systemSymbolTable = new IonSharedSymbolTable_1.SharedSymbolTable("$ion", 1, ["$ion", "$ion_1_0", "$ion_symbol_table", "name", "version", "imports", "symbols", "max_id", "$ion_shared_symbol_table"]); +const IonImport_1 = require("./IonImport"); +const IonSharedSymbolTable_1 = require("./IonSharedSymbolTable"); +const systemSymbolTable = new IonSharedSymbolTable_1.SharedSymbolTable("$ion", 1, ["$ion", "$ion_1_0", "$ion_symbol_table", "name", "version", "imports", "symbols", "max_id", "$ion_shared_symbol_table"]); function getSystemSymbolTable() { return systemSymbolTable; } @@ -5943,10 +5019,10 @@ exports.escape = exports.isDigit = exports.isOperator = exports.isIdentifier = e exports.WHITESPACE_COMMENT1 = -2; exports.WHITESPACE_COMMENT2 = -3; exports.ESCAPED_NEWLINE = -4; -var DOUBLE_QUOTE = 34; -var SINGLE_QUOTE = 39; -var SLASH = 92; -var _escapeStrings = { +const DOUBLE_QUOTE = 34; +const SINGLE_QUOTE = 39; +const SLASH = 92; +const _escapeStrings = { 0: "\\0", 8: "\\b", 9: "\\t", @@ -5957,8 +5033,8 @@ var _escapeStrings = { SLASH: "\\\\" }; function _make_bool_array(str) { - var i = str.length; - var a = []; + let i = str.length; + const a = []; a[128] = false; while (i > 0) { --i; @@ -5966,14 +5042,14 @@ function _make_bool_array(str) { } return a; } -var _is_base64_char = _make_bool_array("+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); -var _is_hex_digit = _make_bool_array("0123456789abcdefABCDEF"); -var _is_letter = _make_bool_array("_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); -var _is_letter_or_digit = _make_bool_array("_$0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); -var _is_numeric_terminator = _make_bool_array("{}[](),\"' \t\n\r\x0B\f"); -var _is_operator_char = _make_bool_array("!#%&*+-./;<=>?@^`|~"); -var _is_whitespace = _make_bool_array(" \t\r\n\x0B\f"); -var isIdentifierArray = _make_bool_array("_$0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); +const _is_base64_char = _make_bool_array("+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); +const _is_hex_digit = _make_bool_array("0123456789abcdefABCDEF"); +const _is_letter = _make_bool_array("_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); +const _is_letter_or_digit = _make_bool_array("_$0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); +const _is_numeric_terminator = _make_bool_array("{}[](),\"' \t\n\r\v\u000c"); +const _is_operator_char = _make_bool_array("!#%&*+-./;<=>?@^`|~"); +const _is_whitespace = _make_bool_array(" \t\r\n\u000b\u000c"); +const isIdentifierArray = _make_bool_array("_$0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); function is_digit(ch) { if (ch < 48 || ch > 57) { return false; @@ -5991,7 +5067,7 @@ function asAscii(s) { } else if (typeof s == "number") { s = "" + s; } else if (typeof s != "string") { - var esc = nextEscape(s, s.length); + const esc = nextEscape(s, s.length); if (esc >= 0) { s = escapeString(s, esc); } @@ -6022,8 +5098,8 @@ function needsEscape(c) { } exports.needsEscape = needsEscape; function escapeString(s, pos) { - var fixes = []; - var c, ii, s2; + const fixes = []; + let c, ii, s2; while (pos >= 0) { c = s.charCodeAt(pos); if (!needsEscape(c)) { @@ -6037,8 +5113,8 @@ function escapeString(s, pos) { ii = fixes.length; pos = s.length; while (ii--) { - var fix = fixes[ii]; - var tail_len = pos - fix[0] - 1; + const fix = fixes[ii]; + const tail_len = pos - fix[0] - 1; if (tail_len > 0) { s2 = escapeSequence(fix[1]) + s.substring(fix[0] + 1, pos) + s2; } else { @@ -6055,7 +5131,7 @@ function escapeString(s, pos) { } exports.escapeString = escapeString; function escapeSequence(c) { - var s = _escapeStrings[c]; + let s = _escapeStrings[c]; if (typeof s === "undefined") { if (c < 256) { s = "\\x" + toHex(c, 2); @@ -6069,7 +5145,7 @@ function escapeSequence(c) { } exports.escapeSequence = escapeSequence; function toHex(c, len) { - var s = ""; + let s = ""; while (c > 0) { s += "0123456789ABCDEF".charAt(c && 0xf); c = c / 16; @@ -6124,8 +5200,8 @@ function is_hex_digit(ch) { return _is_hex_digit[ch]; } exports.is_hex_digit = is_hex_digit; -var base64chars = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/"]; -var base64inv = { +const base64chars = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/"]; +const base64inv = { A: 0, B: 1, C: 2, @@ -6192,21 +5268,21 @@ var base64inv = { "/": 63 }; function fromBase64(str) { - var pad = 0; - for (var i = str.length - 1; str.charAt(i) == "="; i--) { + let pad = 0; + for (let i = str.length - 1; str.charAt(i) == "="; i--) { pad++; } - var buf = new Uint8Array(str.length * 3 / 4 - pad); - for (var _i = 0; _i < str.length - pad; _i += 4) { - var c0 = base64inv[str.charAt(_i)], - c1 = base64inv[str.charAt(_i + 1)], - c2 = base64inv[str.charAt(_i + 2)], - c3 = base64inv[str.charAt(_i + 3)]; - buf[_i * 3 / 4] = c0 << 2 & 255 | c1 >>> 4; - if (_i + 2 < str.length - pad) { - buf[_i * 3 / 4 + 1] = c1 << 4 & 255 | c2 >>> 2; - if (_i + 3 < str.length - pad) { - buf[_i * 3 / 4 + 2] = c2 << 6 & 255 | c3; + const buf = new Uint8Array(str.length * 3 / 4 - pad); + for (let i = 0; i < str.length - pad; i += 4) { + const c0 = base64inv[str.charAt(i)], + c1 = base64inv[str.charAt(i + 1)], + c2 = base64inv[str.charAt(i + 2)], + c3 = base64inv[str.charAt(i + 3)]; + buf[i * 3 / 4] = c0 << 2 & 255 | c1 >>> 4; + if (i + 2 < str.length - pad) { + buf[i * 3 / 4 + 1] = c1 << 4 & 255 | c2 >>> 2; + if (i + 3 < str.length - pad) { + buf[i * 3 / 4 + 2] = c2 << 6 & 255 | c3; } } } @@ -6214,9 +5290,9 @@ function fromBase64(str) { } exports.fromBase64 = fromBase64; function toBase64(buf) { - var str = new Array(Math.ceil(buf.length * 4 / 3)); - for (var i = 0; i < buf.length; i += 3) { - var b0 = buf[i], + const str = new Array(Math.ceil(buf.length * 4 / 3)); + for (let i = 0; i < buf.length; i += 3) { + const b0 = buf[i], b1 = buf[i + 1], b2 = buf[i + 2], b3 = buf[i + 3]; @@ -6266,15 +5342,15 @@ function backslashEscape(s) { return [CharCodes.BACKSLASH, s.charCodeAt(0)]; } function toCharCodes(s) { - var charCodes = new Array(s.length); - for (var i = 0; i < s.length; i++) { + const charCodes = new Array(s.length); + for (let i = 0; i < s.length; i++) { charCodes[i] = s.charCodeAt(i); } return charCodes; } -var _HEX_ESCAPE_PREFIX = [CharCodes.BACKSLASH, CharCodes.LOWERCASE_X]; +const _HEX_ESCAPE_PREFIX = [CharCodes.BACKSLASH, CharCodes.LOWERCASE_X]; function hexEscape(codePoint) { - var hexEscape = codePoint.toString(16); + let hexEscape = codePoint.toString(16); while (hexEscape.length < 2) { hexEscape = "0" + hexEscape; } @@ -6284,12 +5360,12 @@ function populateWithHexEscapes(escapes, start, end) { if (end === undefined) { escapes[start] = hexEscape(start); } else { - for (var i = start; i < end; i++) { + for (let i = start; i < end; i++) { escapes[i] = hexEscape(i); } } } -var CommonEscapes = {}; +const CommonEscapes = {}; CommonEscapes[CharCodes.NULL] = backslashEscape("0"); populateWithHexEscapes(CommonEscapes, 1, 7); CommonEscapes[CharCodes.BELL] = backslashEscape("a"); @@ -6302,22 +5378,22 @@ CommonEscapes[CharCodes.CARRIAGE_RETURN] = backslashEscape("r"); populateWithHexEscapes(CommonEscapes, 14, 32); CommonEscapes[CharCodes.BACKSLASH] = backslashEscape("\\"); populateWithHexEscapes(CommonEscapes, 0x7f, 0xa0); -exports.ClobEscapes = (0, _extends2["default"])({}, CommonEscapes); +exports.ClobEscapes = (0, _extends2.default)({}, CommonEscapes); exports.ClobEscapes[CharCodes.DOUBLE_QUOTE] = backslashEscape('"'); exports.ClobEscapes[CharCodes.SINGLE_QUOTE] = backslashEscape("'"); exports.ClobEscapes[CharCodes.FORWARD_SLASH] = backslashEscape("/"); exports.ClobEscapes[CharCodes.QUESTION_MARK] = backslashEscape("?"); -exports.StringEscapes = (0, _extends2["default"])({}, CommonEscapes); +exports.StringEscapes = (0, _extends2.default)({}, CommonEscapes); exports.StringEscapes[CharCodes.DOUBLE_QUOTE] = backslashEscape('"'); -exports.SymbolEscapes = (0, _extends2["default"])({}, CommonEscapes); +exports.SymbolEscapes = (0, _extends2.default)({}, CommonEscapes); exports.SymbolEscapes[CharCodes.SINGLE_QUOTE] = backslashEscape("'"); function isIdentifier(s) { if (is_digit(s.charCodeAt(0))) { return false; } - for (var i = 0; i < s.length; i++) { - var c = s.charCodeAt(i); - var b = isIdentifierArray[c]; + for (let i = 0; i < s.length; i++) { + const c = s.charCodeAt(i); + const b = isIdentifierArray[c]; if (!b) { return false; } @@ -6326,9 +5402,9 @@ function isIdentifier(s) { } exports.isIdentifier = isIdentifier; function isOperator(s) { - for (var i = 0; i < s.length; i++) { - var c = s.charCodeAt(i); - var b = _is_operator_char[c]; + for (let i = 0; i < s.length; i++) { + const c = s.charCodeAt(i); + const b = _is_operator_char[c]; if (!b) { return false; } @@ -6341,16 +5417,16 @@ function isDigit(charCode) { } exports.isDigit = isDigit; function escape(input, escapes) { - var escapedString = ""; - var escapeSeq = ""; - var charCode; - var escape; - var lastIndex = 0; - for (var i = 0; i < input.length; i++) { + let escapedString = ""; + let escapeSeq = ""; + let charCode; + let escape; + let lastIndex = 0; + for (let i = 0; i < input.length; i++) { charCode = input.charCodeAt(i); escape = escapes[charCode]; if (escape !== undefined) { - for (var j = 0; j < escape.length; j++) { + for (let j = 0; j < escape.length; j++) { escapeSeq += String.fromCharCode(escape[j]); } escapedString += input.slice(lastIndex, i) + escapeSeq; @@ -6362,7 +5438,7 @@ function escape(input, escapes) { } exports.escape = escape; -},{"@babel/runtime/helpers/extends":64,"@babel/runtime/helpers/interopRequireDefault":68}],25:[function(require,module,exports){ +},{"@babel/runtime/helpers/extends":56,"@babel/runtime/helpers/interopRequireDefault":57}],25:[function(require,module,exports){ "use strict"; /*! @@ -6379,9 +5455,6 @@ exports.escape = escape; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var __importDefault = void 0 && (void 0).__importDefault || function (mod) { return mod && mod.__esModule ? mod : { "default": mod @@ -6391,26 +5464,25 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.TextReader = void 0; -var IntSize_1 = __importDefault(require("./IntSize")); -var IonCatalog_1 = require("./IonCatalog"); -var IonDecimal_1 = require("./IonDecimal"); -var IonLocalSymbolTable_1 = require("./IonLocalSymbolTable"); -var IonParserTextRaw_1 = require("./IonParserTextRaw"); -var IonSymbols_1 = require("./IonSymbols"); -var IonText_1 = require("./IonText"); -var IonTimestamp_1 = require("./IonTimestamp"); -var IonTypes_1 = require("./IonTypes"); -var util_1 = require("./util"); -var BEGINNING_OF_CONTAINER = -2; -var EOF = -1; -var T_IDENTIFIER = 9; -var T_STRING1 = 11; -var T_CLOB2 = 14; -var T_CLOB3 = 15; -var T_STRUCT = 19; -var TextReader = /*#__PURE__*/function () { - function TextReader(source, catalog) { - (0, _classCallCheck2["default"])(this, TextReader); +const IntSize_1 = __importDefault(require("./IntSize")); +const IonCatalog_1 = require("./IonCatalog"); +const IonDecimal_1 = require("./IonDecimal"); +const IonLocalSymbolTable_1 = require("./IonLocalSymbolTable"); +const IonParserTextRaw_1 = require("./IonParserTextRaw"); +const IonSymbols_1 = require("./IonSymbols"); +const IonText_1 = require("./IonText"); +const IonTimestamp_1 = require("./IonTimestamp"); +const IonTypes_1 = require("./IonTypes"); +const util_1 = require("./util"); +const BEGINNING_OF_CONTAINER = -2; +const EOF = -1; +const T_IDENTIFIER = 9; +const T_STRING1 = 11; +const T_CLOB2 = 14; +const T_CLOB3 = 15; +const T_STRUCT = 19; +class TextReader { + constructor(source, catalog) { if (!source) { throw new Error("a source Span is required to make a reader"); } @@ -6422,377 +5494,328 @@ var TextReader = /*#__PURE__*/function () { this._raw_type = undefined; this._raw = undefined; } - (0, _createClass2["default"])(TextReader, [{ - key: "load_raw", - value: function load_raw() { - var t = this; - if (t._raw !== undefined) { - return; - } - if (t._raw_type === T_CLOB2 || t._raw_type === T_CLOB3) { - t._raw = t._parser.get_value_as_uint8array(t._raw_type); - } else { - t._raw = t._parser.get_value_as_string(t._raw_type); - } + load_raw() { + const t = this; + if (t._raw !== undefined) { + return; } - }, { - key: "skip_past_container", - value: function skip_past_container() { - var type; - var d = this.depth(); - this.stepIn(); - while (this.depth() > d) { - type = this.next(); - if (type === null) { - this.stepOut(); - } else if (type.isContainer && !this.isNull()) { - this.stepIn(); - } + if (t._raw_type === T_CLOB2 || t._raw_type === T_CLOB3) { + t._raw = t._parser.get_value_as_uint8array(t._raw_type); + } else { + t._raw = t._parser.get_value_as_string(t._raw_type); + } + } + skip_past_container() { + let type; + const d = this.depth(); + this.stepIn(); + while (this.depth() > d) { + type = this.next(); + if (type === null) { + this.stepOut(); + } else if (type.isContainer && !this.isNull()) { + this.stepIn(); } } - }, { - key: "isIVM", - value: function isIVM(input, depth, annotations) { - if (depth > 0) { + } + isIVM(input, depth, annotations) { + if (depth > 0) { + return false; + } + const ivm = "$ion_1_0"; + const prefix = "$ion_"; + if (input.length < ivm.length || annotations.length > 0) { + return false; + } + let i = 0; + while (i < prefix.length) { + if (prefix.charAt(i) !== input.charAt(i)) { return false; } - var ivm = "$ion_1_0"; - var prefix = "$ion_"; - if (input.length < ivm.length || annotations.length > 0) { + i++; + } + while (i < input.length && input.charAt(i) != "_") { + const ch = input.charAt(i); + if (ch < "0" || ch > "9") { return false; } - var i = 0; - while (i < prefix.length) { - if (prefix.charAt(i) !== input.charAt(i)) { - return false; - } - i++; - } - while (i < input.length && input.charAt(i) != "_") { - var ch = input.charAt(i); - if (ch < "0" || ch > "9") { - return false; - } - i++; - } i++; - while (i < input.length) { - var _ch = input.charAt(i); - if (_ch < "0" || _ch > "9") { - return false; - } - i++; - } - if (input !== ivm) { - throw new Error("Only Ion version 1.0 is supported."); + } + i++; + while (i < input.length) { + const ch = input.charAt(i); + if (ch < "0" || ch > "9") { + return false; } - return true; + i++; } - }, { - key: "isLikeIVM", - value: function isLikeIVM() { - return false; + if (input !== ivm) { + throw new Error("Only Ion version 1.0 is supported."); } - }, { - key: "position", - value: function position() { - return this._parser.source().position(); + return true; + } + isLikeIVM() { + return false; + } + position() { + return this._parser.source().position(); + } + next() { + this._raw = undefined; + if (this._raw_type === EOF) { + return null; } - }, { - key: "next", - value: function next() { - this._raw = undefined; - if (this._raw_type === EOF) { - return null; - } - if (this._raw_type !== BEGINNING_OF_CONTAINER && !this.isNull() && this._type && this._type.isContainer) { - this.skip_past_container(); - } - var p = this._parser; - for (;;) { - this._raw_type = p.next(); - if (this._raw_type === T_IDENTIFIER) { - if (this._depth > 0) { - break; - } - this.load_raw(); - if (!this.isIVM(this._raw, this.depth(), this.annotations())) { - break; - } - this._symtab = IonLocalSymbolTable_1.defaultLocalSymbolTable(); - this._raw = undefined; - this._raw_type = undefined; - } else if (this._raw_type === T_STRING1) { - if (this._depth > 0) { - break; - } - this.load_raw(); - if (this._raw !== "$ion_1_0") { - break; - } - this._raw = undefined; - this._raw_type = undefined; - } else if (this._raw_type === T_STRUCT) { - if (p.annotations().length !== 1) { - break; - } - if (p.annotations()[0].getText() != IonSymbols_1.ion_symbol_table) { - break; - } - this._type = IonParserTextRaw_1.get_ion_type(this._raw_type); - this._symtab = IonSymbols_1.makeSymbolTable(this._cat, this, this._symtab); - this._raw = undefined; - this._raw_type = undefined; - } else { + if (this._raw_type !== BEGINNING_OF_CONTAINER && !this.isNull() && this._type && this._type.isContainer) { + this.skip_past_container(); + } + const p = this._parser; + for (;;) { + this._raw_type = p.next(); + if (this._raw_type === T_IDENTIFIER) { + if (this._depth > 0) { break; } - } - this._type = IonParserTextRaw_1.get_ion_type(this._raw_type); - return this._type; - } - }, { - key: "stepIn", - value: function stepIn() { - if (!this._type.isContainer) { - throw new Error("can't step in to a scalar value"); - } - if (this.isNull()) { - throw new Error("Can't step into a null container"); - } - this._parser.clearFieldName(); - this._type = null; - this._raw_type = BEGINNING_OF_CONTAINER; - this._depth++; - } - }, { - key: "stepOut", - value: function stepOut() { - this._parser.clearFieldName(); - while (this._raw_type != EOF) { - this.next(); - } - this._raw_type = undefined; - if (this._depth <= 0) { - throw new Error("Cannot stepOut any further, already at top level"); - } - this._depth--; - } - }, { - key: "type", - value: function type() { - return this._type; - } - }, { - key: "depth", - value: function depth() { - return this._depth; - } - }, { - key: "fieldName", - value: function fieldName() { - var str = this._parser.fieldName(); - if (str !== null) { - var raw_type = this._parser.fieldNameType(); - if (raw_type === T_IDENTIFIER && str.length > 1 && str[0] === "$") { - var tempStr = str.substr(1, str.length); - if (+tempStr === +tempStr) { - var symbol = this._symtab.getSymbolText(Number(tempStr)); - if (symbol === undefined) { - throw new Error("Unresolvable symbol ID, symboltokens unsupported."); - } - return symbol; - } + this.load_raw(); + if (!this.isIVM(this._raw, this.depth(), this.annotations())) { + break; + } + this._symtab = IonLocalSymbolTable_1.defaultLocalSymbolTable(); + this._raw = undefined; + this._raw_type = undefined; + } else if (this._raw_type === T_STRING1) { + if (this._depth > 0) { + break; } + this.load_raw(); + if (this._raw !== "$ion_1_0") { + break; + } + this._raw = undefined; + this._raw_type = undefined; + } else if (this._raw_type === T_STRUCT) { + if (p.annotations().length !== 1) { + break; + } + if (p.annotations()[0].getText() != IonSymbols_1.ion_symbol_table) { + break; + } + this._type = IonParserTextRaw_1.get_ion_type(this._raw_type); + this._symtab = IonSymbols_1.makeSymbolTable(this._cat, this, this._symtab); + this._raw = undefined; + this._raw_type = undefined; + } else { + break; } - return str; } - }, { - key: "annotations", - value: function annotations() { - var _this = this; - return this._parser.annotations().map(function (st) { - var text = st.getText(); - if (text !== null) { - return text; - } else { - var symbol = _this._symtab.getSymbolText(st.getSid()); - if (symbol === undefined || symbol === null) { + this._type = IonParserTextRaw_1.get_ion_type(this._raw_type); + return this._type; + } + stepIn() { + if (!this._type.isContainer) { + throw new Error("can't step in to a scalar value"); + } + if (this.isNull()) { + throw new Error("Can't step into a null container"); + } + this._parser.clearFieldName(); + this._type = null; + this._raw_type = BEGINNING_OF_CONTAINER; + this._depth++; + } + stepOut() { + this._parser.clearFieldName(); + while (this._raw_type != EOF) { + this.next(); + } + this._raw_type = undefined; + if (this._depth <= 0) { + throw new Error("Cannot stepOut any further, already at top level"); + } + this._depth--; + } + type() { + return this._type; + } + depth() { + return this._depth; + } + fieldName() { + const str = this._parser.fieldName(); + if (str !== null) { + const raw_type = this._parser.fieldNameType(); + if (raw_type === T_IDENTIFIER && str.length > 1 && str[0] === "$") { + const tempStr = str.substr(1, str.length); + if (+tempStr === +tempStr) { + const symbol = this._symtab.getSymbolText(Number(tempStr)); + if (symbol === undefined) { throw new Error("Unresolvable symbol ID, symboltokens unsupported."); } return symbol; } - }); - } - }, { - key: "isNull", - value: function isNull() { - if (this._type === IonTypes_1.IonTypes.NULL) { - return true; } - return this._parser.isNull(); } - }, { - key: "_stringRepresentation", - value: function _stringRepresentation() { - this.load_raw(); - if (this.isNull()) { - return this._type === IonTypes_1.IonTypes.NULL ? "null" : "null." + this._type.name; + return str; + } + annotations() { + return this._parser.annotations().map(st => { + const text = st.getText(); + if (text !== null) { + return text; + } else { + const symbol = this._symtab.getSymbolText(st.getSid()); + if (symbol === undefined || symbol === null) { + throw new Error("Unresolvable symbol ID, symboltokens unsupported."); + } + return symbol; } - return this._raw; + }); + } + isNull() { + if (this._type === IonTypes_1.IonTypes.NULL) { + return true; } - }, { - key: "booleanValue", - value: function booleanValue() { - switch (this._type) { - case IonTypes_1.IonTypes.NULL: - return null; - case IonTypes_1.IonTypes.BOOL: - return this._parser.booleanValue(); - } - throw new Error("Current value is not a Boolean."); + return this._parser.isNull(); + } + _stringRepresentation() { + this.load_raw(); + if (this.isNull()) { + return this._type === IonTypes_1.IonTypes.NULL ? "null" : "null." + this._type.name; } - }, { - key: "uInt8ArrayValue", - value: function uInt8ArrayValue() { - this.load_raw(); - switch (this._type) { - case IonTypes_1.IonTypes.NULL: - return null; - case IonTypes_1.IonTypes.BLOB: - if (this.isNull()) { - return null; - } - return IonText_1.fromBase64(this._raw); - case IonTypes_1.IonTypes.CLOB: - if (this.isNull()) { - return null; - } - return this._raw; - } - throw new Error("Current value is not a blob or clob."); + return this._raw; + } + booleanValue() { + switch (this._type) { + case IonTypes_1.IonTypes.NULL: + return null; + case IonTypes_1.IonTypes.BOOL: + return this._parser.booleanValue(); } - }, { - key: "decimalValue", - value: function decimalValue() { - switch (this._type) { - case IonTypes_1.IonTypes.NULL: + throw new Error("Current value is not a Boolean."); + } + uInt8ArrayValue() { + this.load_raw(); + switch (this._type) { + case IonTypes_1.IonTypes.NULL: + return null; + case IonTypes_1.IonTypes.BLOB: + if (this.isNull()) { return null; - case IonTypes_1.IonTypes.DECIMAL: - return IonDecimal_1.Decimal.parse(this._stringRepresentation()); - } - throw new Error("Current value is not a decimal."); - } - }, { - key: "bigIntValue", - value: function bigIntValue() { - switch (this._type) { - case IonTypes_1.IonTypes.NULL: + } + return IonText_1.fromBase64(this._raw); + case IonTypes_1.IonTypes.CLOB: + if (this.isNull()) { return null; - case IonTypes_1.IonTypes.INT: - return this._parser.bigIntValue(); - } - throw new Error("bigIntValue() was called when the current value was a(n) " + this._type.name); + } + return this._raw; } - }, { - key: "intSize", - value: function intSize() { - if (util_1.isSafeInteger(this.bigIntValue())) { - return IntSize_1["default"].Number; - } - return IntSize_1["default"].BigInt; + throw new Error("Current value is not a blob or clob."); + } + decimalValue() { + switch (this._type) { + case IonTypes_1.IonTypes.NULL: + return null; + case IonTypes_1.IonTypes.DECIMAL: + return IonDecimal_1.Decimal.parse(this._stringRepresentation()); + } + throw new Error("Current value is not a decimal."); + } + bigIntValue() { + switch (this._type) { + case IonTypes_1.IonTypes.NULL: + return null; + case IonTypes_1.IonTypes.INT: + return this._parser.bigIntValue(); + } + throw new Error("bigIntValue() was called when the current value was a(n) " + this._type.name); + } + intSize() { + if (util_1.isSafeInteger(this.bigIntValue())) { + return IntSize_1.default.Number; + } + return IntSize_1.default.BigInt; + } + numberValue() { + switch (this._type) { + case IonTypes_1.IonTypes.NULL: + return null; + case IonTypes_1.IonTypes.FLOAT: + case IonTypes_1.IonTypes.INT: + return this._parser.numberValue(); } - }, { - key: "numberValue", - value: function numberValue() { - switch (this._type) { - case IonTypes_1.IonTypes.NULL: + throw new Error("Current value is not a float or int."); + } + stringValue() { + this.load_raw(); + switch (this._type) { + case IonTypes_1.IonTypes.NULL: + return null; + case IonTypes_1.IonTypes.STRING: + if (this._parser.isNull()) { return null; - case IonTypes_1.IonTypes.FLOAT: - case IonTypes_1.IonTypes.INT: - return this._parser.numberValue(); - } - throw new Error("Current value is not a float or int."); - } - }, { - key: "stringValue", - value: function stringValue() { - this.load_raw(); - switch (this._type) { - case IonTypes_1.IonTypes.NULL: + } + return this._raw; + case IonTypes_1.IonTypes.SYMBOL: + if (this._parser.isNull()) { return null; - case IonTypes_1.IonTypes.STRING: - if (this._parser.isNull()) { - return null; - } - return this._raw; - case IonTypes_1.IonTypes.SYMBOL: - if (this._parser.isNull()) { - return null; - } - if (this._raw_type === T_IDENTIFIER && this._raw.length > 1 && this._raw.charAt(0) === "$".charAt(0)) { - var tempStr = this._raw.substr(1, this._raw.length); - if (+tempStr === +tempStr) { - var symbolId = Number(tempStr); - var symbol = this._symtab.getSymbolText(symbolId); - if (symbol === undefined) { - throw new Error("Unresolvable symbol ID, symboltokens unsupported."); - } - return symbol; + } + if (this._raw_type === T_IDENTIFIER && this._raw.length > 1 && this._raw.charAt(0) === "$".charAt(0)) { + const tempStr = this._raw.substr(1, this._raw.length); + if (+tempStr === +tempStr) { + const symbolId = Number(tempStr); + const symbol = this._symtab.getSymbolText(symbolId); + if (symbol === undefined) { + throw new Error("Unresolvable symbol ID, symboltokens unsupported."); } + return symbol; } - return this._raw; - } - throw new Error("Current value is not a string or symbol."); + } + return this._raw; } - }, { - key: "timestampValue", - value: function timestampValue() { - switch (this._type) { - case IonTypes_1.IonTypes.NULL: - return null; - case IonTypes_1.IonTypes.TIMESTAMP: - return IonTimestamp_1.Timestamp.parse(this._stringRepresentation()); - } - throw new Error("Current value is not a timestamp."); + throw new Error("Current value is not a string or symbol."); + } + timestampValue() { + switch (this._type) { + case IonTypes_1.IonTypes.NULL: + return null; + case IonTypes_1.IonTypes.TIMESTAMP: + return IonTimestamp_1.Timestamp.parse(this._stringRepresentation()); } - }, { - key: "value", - value: function value() { - if (this._type && this._type.isContainer) { - if (this.isNull()) { - return null; - } - throw new Error("Unable to provide a value for " + this._type.name + " containers."); - } - switch (this._type) { - case IonTypes_1.IonTypes.NULL: - return null; - case IonTypes_1.IonTypes.BLOB: - case IonTypes_1.IonTypes.CLOB: - return this.uInt8ArrayValue(); - case IonTypes_1.IonTypes.BOOL: - return this.booleanValue(); - case IonTypes_1.IonTypes.DECIMAL: - return this.decimalValue(); - case IonTypes_1.IonTypes.INT: - return this.bigIntValue(); - case IonTypes_1.IonTypes.FLOAT: - return this.numberValue(); - case IonTypes_1.IonTypes.STRING: - case IonTypes_1.IonTypes.SYMBOL: - return this.stringValue(); - case IonTypes_1.IonTypes.TIMESTAMP: - return this.timestampValue(); - default: - throw new Error("There is no current value."); + throw new Error("Current value is not a timestamp."); + } + value() { + if (this._type && this._type.isContainer) { + if (this.isNull()) { + return null; } + throw new Error("Unable to provide a value for " + this._type.name + " containers."); } - }]); - return TextReader; -}(); + switch (this._type) { + case IonTypes_1.IonTypes.NULL: + return null; + case IonTypes_1.IonTypes.BLOB: + case IonTypes_1.IonTypes.CLOB: + return this.uInt8ArrayValue(); + case IonTypes_1.IonTypes.BOOL: + return this.booleanValue(); + case IonTypes_1.IonTypes.DECIMAL: + return this.decimalValue(); + case IonTypes_1.IonTypes.INT: + return this.bigIntValue(); + case IonTypes_1.IonTypes.FLOAT: + return this.numberValue(); + case IonTypes_1.IonTypes.STRING: + case IonTypes_1.IonTypes.SYMBOL: + return this.stringValue(); + case IonTypes_1.IonTypes.TIMESTAMP: + return this.timestampValue(); + default: + throw new Error("There is no current value."); + } + } +} exports.TextReader = TextReader; -},{"./IntSize":4,"./IonCatalog":9,"./IonDecimal":11,"./IonLocalSymbolTable":13,"./IonParserTextRaw":16,"./IonSymbols":22,"./IonText":24,"./IonTimestamp":27,"./IonTypes":29,"./util":55,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],26:[function(require,module,exports){ +},{"./IntSize":4,"./IonCatalog":9,"./IonDecimal":11,"./IonLocalSymbolTable":13,"./IonParserTextRaw":16,"./IonSymbols":22,"./IonText":24,"./IonTimestamp":27,"./IonTypes":29,"./util":55}],26:[function(require,module,exports){ "use strict"; /*! @@ -6809,442 +5832,347 @@ exports.TextReader = TextReader; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.TextWriter = exports.Context = exports.State = void 0; -var AbstractWriter_1 = require("./AbstractWriter"); -var IonText_1 = require("./IonText"); -var IonTypes_1 = require("./IonTypes"); -var IonUnicode_1 = require("./IonUnicode"); -var util_1 = require("./util"); +const AbstractWriter_1 = require("./AbstractWriter"); +const IonText_1 = require("./IonText"); +const IonTypes_1 = require("./IonTypes"); +const IonUnicode_1 = require("./IonUnicode"); +const util_1 = require("./util"); var State; (function (State) { State[State["VALUE"] = 0] = "VALUE"; State[State["STRUCT_FIELD"] = 1] = "STRUCT_FIELD"; })(State = exports.State || (exports.State = {})); -var Context = /*#__PURE__*/(0, _createClass2["default"])(function Context(myType) { - (0, _classCallCheck2["default"])(this, Context); - this.state = myType === IonTypes_1.IonTypes.STRUCT ? State.STRUCT_FIELD : State.VALUE; - this.clean = true; - this.containerType = myType; -}); +class Context { + constructor(myType) { + this.state = myType === IonTypes_1.IonTypes.STRUCT ? State.STRUCT_FIELD : State.VALUE; + this.clean = true; + this.containerType = myType; + } +} exports.Context = Context; -var TextWriter = /*#__PURE__*/function (_AbstractWriter_1$Abs) { - (0, _inherits2["default"])(TextWriter, _AbstractWriter_1$Abs); - var _super = _createSuper(TextWriter); - function TextWriter(writeable) { - var _this; - (0, _classCallCheck2["default"])(this, TextWriter); - _this = _super.call(this); - _this.writeable = writeable; - _this._floatSerializer = function (value) { - TextWriter._serializeFloat((0, _assertThisInitialized2["default"])(_this), value); +class TextWriter extends AbstractWriter_1.AbstractWriter { + constructor(writeable) { + super(); + this.writeable = writeable; + this._floatSerializer = value => { + TextWriter._serializeFloat(this, value); }; - _this.containerContext = [new Context(null)]; - return _this; - } - (0, _createClass2["default"])(TextWriter, [{ - key: "isTopLevel", - get: function get() { - return this.depth() === 0; - } - }, { - key: "currentContainer", - get: function get() { - return this.containerContext[this.depth()]; - } - }, { - key: "getBytes", - value: function getBytes() { - return this.writeable.getBytes(); - } - }, { - key: "writeBlob", - value: function writeBlob(value) { - var _this2 = this; - util_1._assertDefined(value); - this._serializeValue(IonTypes_1.IonTypes.BLOB, value, function (value) { - _this2.writeable.writeBytes(IonUnicode_1.encodeUtf8("{{" + IonText_1.toBase64(value) + "}}")); - }); - } - }, { - key: "writeBoolean", - value: function writeBoolean(value) { - var _this3 = this; - util_1._assertDefined(value); - this._serializeValue(IonTypes_1.IonTypes.BOOL, value, function (value) { - _this3.writeUtf8(value ? "true" : "false"); - }); + this.containerContext = [new Context(null)]; + } + get isTopLevel() { + return this.depth() === 0; + } + get currentContainer() { + return this.containerContext[this.depth()]; + } + static _serializeFloat(writer, value) { + let text; + if (value === Number.POSITIVE_INFINITY) { + text = "+inf"; + } else if (value === Number.NEGATIVE_INFINITY) { + text = "-inf"; + } else if (Object.is(value, Number.NaN)) { + text = "nan"; + } else if (Object.is(value, -0)) { + text = "-0e0"; + } else { + text = value.toExponential(); + const plusSignIndex = text.lastIndexOf("+"); + if (plusSignIndex > -1) { + text = text.slice(0, plusSignIndex) + text.slice(plusSignIndex + 1); + } } - }, { - key: "writeClob", - value: function writeClob(value) { - var _this4 = this; - util_1._assertDefined(value); - this._serializeValue(IonTypes_1.IonTypes.CLOB, value, function (value) { - var hexStr; - _this4.writeUtf8('{{"'); - for (var i = 0; i < value.length; i++) { - var c = value[i]; - if (c > 127 && c < 256) { - hexStr = "\\x" + c.toString(16); - for (var j = 0; j < hexStr.length; j++) { - _this4.writeable.writeByte(hexStr.charCodeAt(j)); - } - } else { - var _escape = IonText_1.ClobEscapes[c]; - if (_escape === undefined) { - if (c < 32) { - hexStr = "\\x" + c.toString(16); - for (var _j = 0; _j < hexStr.length; _j++) { - _this4.writeable.writeByte(hexStr.charCodeAt(_j)); - } - } else { - _this4.writeable.writeByte(c); + writer.writeUtf8(text); + } + getBytes() { + return this.writeable.getBytes(); + } + writeBlob(value) { + util_1._assertDefined(value); + this._serializeValue(IonTypes_1.IonTypes.BLOB, value, value => { + this.writeable.writeBytes(IonUnicode_1.encodeUtf8("{{" + IonText_1.toBase64(value) + "}}")); + }); + } + writeBoolean(value) { + util_1._assertDefined(value); + this._serializeValue(IonTypes_1.IonTypes.BOOL, value, value => { + this.writeUtf8(value ? "true" : "false"); + }); + } + writeClob(value) { + util_1._assertDefined(value); + this._serializeValue(IonTypes_1.IonTypes.CLOB, value, value => { + let hexStr; + this.writeUtf8('{{"'); + for (let i = 0; i < value.length; i++) { + const c = value[i]; + if (c > 127 && c < 256) { + hexStr = "\\x" + c.toString(16); + for (let j = 0; j < hexStr.length; j++) { + this.writeable.writeByte(hexStr.charCodeAt(j)); + } + } else { + const escape = IonText_1.ClobEscapes[c]; + if (escape === undefined) { + if (c < 32) { + hexStr = "\\x" + c.toString(16); + for (let j = 0; j < hexStr.length; j++) { + this.writeable.writeByte(hexStr.charCodeAt(j)); } } else { - _this4.writeable.writeBytes(new Uint8Array(_escape)); + this.writeable.writeByte(c); } - } - } - _this4.writeUtf8('"}}'); - }); - } - }, { - key: "writeDecimal", - value: function writeDecimal(value) { - var _this5 = this; - util_1._assertDefined(value); - this._serializeValue(IonTypes_1.IonTypes.DECIMAL, value, function (value) { - var s = ""; - var coefficient = value.getCoefficient(); - if (coefficient < 0n) { - coefficient = -coefficient; - } - if (value.isNegative()) { - s += "-"; - } - var exponent = value.getExponent(); - var scale = -exponent; - if (exponent == 0) { - s += coefficient.toString() + "."; - } else if (exponent < 0) { - var significantDigits = coefficient.toString().length; - var adjustedExponent = significantDigits - 1 - scale; - if (adjustedExponent >= 0) { - var wholeDigits = significantDigits - scale; - s += coefficient.toString().substring(0, wholeDigits); - s += "."; - s += coefficient.toString().substring(wholeDigits, significantDigits); - } else if (adjustedExponent >= -6) { - s += "0."; - s += "00000".substring(0, scale - significantDigits); - s += coefficient.toString(); } else { - s += coefficient.toString(); - s += "d-"; - s += scale.toString(); + this.writeable.writeBytes(new Uint8Array(escape)); } + } + } + this.writeUtf8('"}}'); + }); + } + writeDecimal(value) { + util_1._assertDefined(value); + this._serializeValue(IonTypes_1.IonTypes.DECIMAL, value, value => { + let s = ""; + let coefficient = value.getCoefficient(); + if (coefficient < 0n) { + coefficient = -coefficient; + } + if (value.isNegative()) { + s += "-"; + } + const exponent = value.getExponent(); + const scale = -exponent; + if (exponent == 0) { + s += coefficient.toString() + "."; + } else if (exponent < 0) { + const significantDigits = coefficient.toString().length; + const adjustedExponent = significantDigits - 1 - scale; + if (adjustedExponent >= 0) { + const wholeDigits = significantDigits - scale; + s += coefficient.toString().substring(0, wholeDigits); + s += "."; + s += coefficient.toString().substring(wholeDigits, significantDigits); + } else if (adjustedExponent >= -6) { + s += "0."; + s += "00000".substring(0, scale - significantDigits); + s += coefficient.toString(); } else { - s += coefficient.toString() + "d" + exponent; + s += coefficient.toString(); + s += "d-"; + s += scale.toString(); } - _this5.writeUtf8(s); - }); - } - }, { - key: "_isInStruct", - value: function _isInStruct() { - return this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT; - } - }, { - key: "writeFieldName", - value: function writeFieldName(fieldName) { - util_1._assertDefined(fieldName); - if (this.currentContainer.containerType !== IonTypes_1.IonTypes.STRUCT) { - throw new Error("Cannot write field name outside of a struct"); - } - if (this.currentContainer.state !== State.STRUCT_FIELD) { - throw new Error("Expecting a struct value"); - } - if (!this.currentContainer.clean) { - this.writeable.writeByte(IonText_1.CharCodes.COMMA); - } - this.writeSymbolToken(fieldName); - this.writeable.writeByte(IonText_1.CharCodes.COLON); - this.currentContainer.state = State.VALUE; - } - }, { - key: "writeFloat32", - value: function writeFloat32(value) { - util_1._assertDefined(value); - this._writeFloat(value); - } - }, { - key: "writeFloat64", - value: function writeFloat64(value) { - util_1._assertDefined(value); - this._writeFloat(value); - } - }, { - key: "writeInt", - value: function writeInt(value) { - var _this6 = this; - util_1._assertDefined(value); - this._serializeValue(IonTypes_1.IonTypes.INT, value, function (value) { - _this6.writeUtf8(value.toString(10)); - }); - } - }, { - key: "_writeNull", - value: function _writeNull(type) { - if (type === IonTypes_1.IonTypes.NULL) { - this.writeUtf8("null"); } else { - this.writeUtf8("null." + type.name); + s += coefficient.toString() + "d" + exponent; } + this.writeUtf8(s); + }); + } + _isInStruct() { + return this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT; + } + writeFieldName(fieldName) { + util_1._assertDefined(fieldName); + if (this.currentContainer.containerType !== IonTypes_1.IonTypes.STRUCT) { + throw new Error("Cannot write field name outside of a struct"); } - }, { - key: "writeNull", - value: function writeNull(type) { - if (type === undefined || type === null) { - type = IonTypes_1.IonTypes.NULL; - } - this.handleSeparator(); - this.writeAnnotations(); - this._writeNull(type); - if (this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT) { - this.currentContainer.state = State.STRUCT_FIELD; - } + if (this.currentContainer.state !== State.STRUCT_FIELD) { + throw new Error("Expecting a struct value"); } - }, { - key: "writeString", - value: function writeString(value) { - var _this7 = this; - util_1._assertDefined(value); - this._serializeValue(IonTypes_1.IonTypes.STRING, value, function (value) { - _this7.writeable.writeBytes(IonUnicode_1.encodeUtf8('"' + IonText_1.escape(value, IonText_1.StringEscapes) + '"')); - }); + if (!this.currentContainer.clean) { + this.writeable.writeByte(IonText_1.CharCodes.COMMA); } - }, { - key: "writeSymbol", - value: function writeSymbol(value) { - var _this8 = this; - util_1._assertDefined(value); - this._serializeValue(IonTypes_1.IonTypes.SYMBOL, value, function (value) { - _this8.writeSymbolToken(value); - }); + this.writeSymbolToken(fieldName); + this.writeable.writeByte(IonText_1.CharCodes.COLON); + this.currentContainer.state = State.VALUE; + } + writeFloat32(value) { + util_1._assertDefined(value); + this._writeFloat(value); + } + writeFloat64(value) { + util_1._assertDefined(value); + this._writeFloat(value); + } + writeInt(value) { + util_1._assertDefined(value); + this._serializeValue(IonTypes_1.IonTypes.INT, value, value => { + this.writeUtf8(value.toString(10)); + }); + } + _writeNull(type) { + if (type === IonTypes_1.IonTypes.NULL) { + this.writeUtf8("null"); + } else { + this.writeUtf8("null." + type.name); } - }, { - key: "writeTimestamp", - value: function writeTimestamp(value) { - var _this9 = this; - util_1._assertDefined(value); - this._serializeValue(IonTypes_1.IonTypes.TIMESTAMP, value, function (value) { - _this9.writeUtf8(value.toString()); - }); + } + writeNull(type) { + if (type === undefined || type === null) { + type = IonTypes_1.IonTypes.NULL; } - }, { - key: "stepIn", - value: function stepIn(type) { - if (this.currentContainer.state === State.STRUCT_FIELD) { - throw new Error("Started writing a ".concat(this.currentContainer.containerType.name, " inside a struct\"\n + \" without writing the field name first. Call writeFieldName(string) with the desired name\"\n + \" before calling stepIn(").concat(this.currentContainer.containerType.name, ").")); - } - switch (type) { - case IonTypes_1.IonTypes.LIST: - this.writeContainer(type, IonText_1.CharCodes.LEFT_BRACKET); - break; - case IonTypes_1.IonTypes.SEXP: - this.writeContainer(type, IonText_1.CharCodes.LEFT_PARENTHESIS); - break; - case IonTypes_1.IonTypes.STRUCT: - if (this._annotations !== undefined && this._annotations[0] === "$ion_symbol_table" && this.depth() === 0) { - throw new Error("Unable to alter symbol table context, it allows invalid ion to be written."); - } - this.writeContainer(type, IonText_1.CharCodes.LEFT_BRACE); - break; - default: - throw new Error("Unrecognized container type"); - } + this.handleSeparator(); + this.writeAnnotations(); + this._writeNull(type); + if (this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT) { + this.currentContainer.state = State.STRUCT_FIELD; } - }, { - key: "stepOut", - value: function stepOut() { - var currentContainer = this.containerContext.pop(); - if (!currentContainer || !currentContainer.containerType) { - throw new Error("Can't step out when not in a container"); - } else if (currentContainer.containerType === IonTypes_1.IonTypes.STRUCT && currentContainer.state === State.VALUE) { - throw new Error("Expecting a struct value"); - } - switch (currentContainer.containerType) { - case IonTypes_1.IonTypes.LIST: - this.writeable.writeByte(IonText_1.CharCodes.RIGHT_BRACKET); - break; - case IonTypes_1.IonTypes.SEXP: - this.writeable.writeByte(IonText_1.CharCodes.RIGHT_PARENTHESIS); - break; - case IonTypes_1.IonTypes.STRUCT: - this.writeable.writeByte(IonText_1.CharCodes.RIGHT_BRACE); - break; - default: - throw new Error("Unexpected container TypeCode"); - } + } + writeString(value) { + util_1._assertDefined(value); + this._serializeValue(IonTypes_1.IonTypes.STRING, value, value => { + this.writeable.writeBytes(IonUnicode_1.encodeUtf8('"' + IonText_1.escape(value, IonText_1.StringEscapes) + '"')); + }); + } + writeSymbol(value) { + util_1._assertDefined(value); + this._serializeValue(IonTypes_1.IonTypes.SYMBOL, value, value => { + this.writeSymbolToken(value); + }); + } + writeTimestamp(value) { + util_1._assertDefined(value); + this._serializeValue(IonTypes_1.IonTypes.TIMESTAMP, value, value => { + this.writeUtf8(value.toString()); + }); + } + stepIn(type) { + if (this.currentContainer.state === State.STRUCT_FIELD) { + throw new Error(`Started writing a ${this.currentContainer.containerType.name} inside a struct" + + " without writing the field name first. Call writeFieldName(string) with the desired name" + + " before calling stepIn(${this.currentContainer.containerType.name}).`); } - }, { - key: "close", - value: function close() { - if (this.depth() > 0) { - throw new Error("Writer has one or more open containers; call stepOut() for each container prior to close()"); - } + switch (type) { + case IonTypes_1.IonTypes.LIST: + this.writeContainer(type, IonText_1.CharCodes.LEFT_BRACKET); + break; + case IonTypes_1.IonTypes.SEXP: + this.writeContainer(type, IonText_1.CharCodes.LEFT_PARENTHESIS); + break; + case IonTypes_1.IonTypes.STRUCT: + if (this._annotations !== undefined && this._annotations[0] === "$ion_symbol_table" && this.depth() === 0) { + throw new Error("Unable to alter symbol table context, it allows invalid ion to be written."); + } + this.writeContainer(type, IonText_1.CharCodes.LEFT_BRACE); + break; + default: + throw new Error("Unrecognized container type"); } - }, { - key: "depth", - value: function depth() { - return this.containerContext.length - 1; + } + stepOut() { + const currentContainer = this.containerContext.pop(); + if (!currentContainer || !currentContainer.containerType) { + throw new Error("Can't step out when not in a container"); + } else if (currentContainer.containerType === IonTypes_1.IonTypes.STRUCT && currentContainer.state === State.VALUE) { + throw new Error("Expecting a struct value"); } - }, { - key: "_serializeValue", - value: function _serializeValue(type, value, serialize) { - if (this.currentContainer.state === State.STRUCT_FIELD) { - throw new Error("Expecting a struct field"); - } - if (value === null) { - this.writeNull(type); - return; - } - this.handleSeparator(); - this.writeAnnotations(); - serialize(value); - if (this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT) { - this.currentContainer.state = State.STRUCT_FIELD; - } - } - }, { - key: "writeContainer", - value: function writeContainer(type, openingCharacter) { - if (this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT && this.currentContainer.state === State.VALUE) { - this.currentContainer.state = State.STRUCT_FIELD; - } - this.handleSeparator(); - this.writeAnnotations(); - this.writeable.writeByte(openingCharacter); - this._stepIn(type); - } - }, { - key: "handleSeparator", - value: function handleSeparator() { - if (this.depth() === 0) { - if (this.currentContainer.clean) { - this.currentContainer.clean = false; - } else { - this.writeable.writeByte(IonText_1.CharCodes.LINE_FEED); - } - } else { - if (this.currentContainer.clean) { - this.currentContainer.clean = false; - } else { - switch (this.currentContainer.containerType) { - case IonTypes_1.IonTypes.LIST: - this.writeable.writeByte(IonText_1.CharCodes.COMMA); - break; - case IonTypes_1.IonTypes.SEXP: - this.writeable.writeByte(IonText_1.CharCodes.SPACE); - break; - default: - } - } - } + switch (currentContainer.containerType) { + case IonTypes_1.IonTypes.LIST: + this.writeable.writeByte(IonText_1.CharCodes.RIGHT_BRACKET); + break; + case IonTypes_1.IonTypes.SEXP: + this.writeable.writeByte(IonText_1.CharCodes.RIGHT_PARENTHESIS); + break; + case IonTypes_1.IonTypes.STRUCT: + this.writeable.writeByte(IonText_1.CharCodes.RIGHT_BRACE); + break; + default: + throw new Error("Unexpected container TypeCode"); } - }, { - key: "writeUtf8", - value: function writeUtf8(s) { - this.writeable.writeBytes(IonUnicode_1.encodeUtf8(s)); - } - }, { - key: "writeAnnotations", - value: function writeAnnotations() { - var _iterator = _createForOfIteratorHelper(this._annotations), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var annotation = _step.value; - this.writeSymbolToken(annotation); - this.writeUtf8("::"); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - this._clearAnnotations(); - } - }, { - key: "_stepIn", - value: function _stepIn(container) { - this.containerContext.push(new Context(container)); - } - }, { - key: "writeSymbolToken", - value: function writeSymbolToken(s) { - if (s.length === 0 || IonText_1.is_keyword(s) || this.isSid(s) || !IonText_1.isIdentifier(s) && !IonText_1.isOperator(s) || IonText_1.isOperator(s) && this.currentContainer.containerType != IonTypes_1.IonTypes.SEXP) { - this.writeable.writeBytes(IonUnicode_1.encodeUtf8("'" + IonText_1.escape(s, IonText_1.SymbolEscapes) + "'")); - } else { - this.writeUtf8(s); - } + } + close() { + if (this.depth() > 0) { + throw new Error("Writer has one or more open containers; call stepOut() for each container prior to close()"); } - }, { - key: "_writeFloat", - value: function _writeFloat(value) { - this._serializeValue(IonTypes_1.IonTypes.FLOAT, value, this._floatSerializer); + } + depth() { + return this.containerContext.length - 1; + } + _serializeValue(type, value, serialize) { + if (this.currentContainer.state === State.STRUCT_FIELD) { + throw new Error("Expecting a struct field"); } - }, { - key: "isSid", - value: function isSid(s) { - if (s.length > 1 && s.charAt(0) === "$".charAt(0)) { - var t = s.substr(1, s.length); - return +t === +t; - } - return false; + if (value === null) { + this.writeNull(type); + return; + } + this.handleSeparator(); + this.writeAnnotations(); + serialize(value); + if (this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT) { + this.currentContainer.state = State.STRUCT_FIELD; + } + } + writeContainer(type, openingCharacter) { + if (this.currentContainer.containerType === IonTypes_1.IonTypes.STRUCT && this.currentContainer.state === State.VALUE) { + this.currentContainer.state = State.STRUCT_FIELD; } - }], [{ - key: "_serializeFloat", - value: function _serializeFloat(writer, value) { - var text; - if (value === Number.POSITIVE_INFINITY) { - text = "+inf"; - } else if (value === Number.NEGATIVE_INFINITY) { - text = "-inf"; - } else if (Object.is(value, Number.NaN)) { - text = "nan"; - } else if (Object.is(value, -0)) { - text = "-0e0"; + this.handleSeparator(); + this.writeAnnotations(); + this.writeable.writeByte(openingCharacter); + this._stepIn(type); + } + handleSeparator() { + if (this.depth() === 0) { + if (this.currentContainer.clean) { + this.currentContainer.clean = false; + } else { + this.writeable.writeByte(IonText_1.CharCodes.LINE_FEED); + } + } else { + if (this.currentContainer.clean) { + this.currentContainer.clean = false; } else { - text = value.toExponential(); - var plusSignIndex = text.lastIndexOf("+"); - if (plusSignIndex > -1) { - text = text.slice(0, plusSignIndex) + text.slice(plusSignIndex + 1); + switch (this.currentContainer.containerType) { + case IonTypes_1.IonTypes.LIST: + this.writeable.writeByte(IonText_1.CharCodes.COMMA); + break; + case IonTypes_1.IonTypes.SEXP: + this.writeable.writeByte(IonText_1.CharCodes.SPACE); + break; + default: } } - writer.writeUtf8(text); } - }]); - return TextWriter; -}(AbstractWriter_1.AbstractWriter); + } + writeUtf8(s) { + this.writeable.writeBytes(IonUnicode_1.encodeUtf8(s)); + } + writeAnnotations() { + for (const annotation of this._annotations) { + this.writeSymbolToken(annotation); + this.writeUtf8("::"); + } + this._clearAnnotations(); + } + _stepIn(container) { + this.containerContext.push(new Context(container)); + } + writeSymbolToken(s) { + if (s.length === 0 || IonText_1.is_keyword(s) || this.isSid(s) || !IonText_1.isIdentifier(s) && !IonText_1.isOperator(s) || IonText_1.isOperator(s) && this.currentContainer.containerType != IonTypes_1.IonTypes.SEXP) { + this.writeable.writeBytes(IonUnicode_1.encodeUtf8("'" + IonText_1.escape(s, IonText_1.SymbolEscapes) + "'")); + } else { + this.writeUtf8(s); + } + } + _writeFloat(value) { + this._serializeValue(IonTypes_1.IonTypes.FLOAT, value, this._floatSerializer); + } + isSid(s) { + if (s.length > 1 && s.charAt(0) === "$".charAt(0)) { + const t = s.substr(1, s.length); + return +t === +t; + } + return false; + } +} exports.TextWriter = TextWriter; -},{"./AbstractWriter":1,"./IonText":24,"./IonTypes":29,"./IonUnicode":30,"./util":55,"@babel/runtime/helpers/assertThisInitialized":59,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],27:[function(require,module,exports){ +},{"./AbstractWriter":1,"./IonText":24,"./IonTypes":29,"./IonUnicode":30,"./util":55}],27:[function(require,module,exports){ "use strict"; /*! @@ -7261,19 +6189,13 @@ exports.TextWriter = TextWriter; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); -var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _TimestampParser$_tim; Object.defineProperty(exports, "__esModule", { value: true }); exports.Timestamp = exports.TimestampPrecision = void 0; -var IonDecimal_1 = require("./IonDecimal"); -var IonText_1 = require("./IonText"); -var util_1 = require("./util"); +const IonDecimal_1 = require("./IonDecimal"); +const IonText_1 = require("./IonText"); +const util_1 = require("./util"); var TimestampPrecision; (function (TimestampPrecision) { TimestampPrecision[TimestampPrecision["YEAR"] = 1] = "YEAR"; @@ -7282,29 +6204,28 @@ var TimestampPrecision; TimestampPrecision[TimestampPrecision["HOUR_AND_MINUTE"] = 4] = "HOUR_AND_MINUTE"; TimestampPrecision[TimestampPrecision["SECONDS"] = 5] = "SECONDS"; })(TimestampPrecision = exports.TimestampPrecision || (exports.TimestampPrecision = {})); -var Timestamp = /*#__PURE__*/function () { - function Timestamp() { - var dateOrLocalOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - var year = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - var month = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - var day = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - var hour = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; - var minutes = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; - var seconds = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; - (0, _classCallCheck2["default"])(this, Timestamp); +class Timestamp { + constructor() { + let dateOrLocalOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + let year = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + let month = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + let day = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + let hour = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; + let minutes = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; + let seconds = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; if (dateOrLocalOffset instanceof Date) { - var date = dateOrLocalOffset; - var _seconds = date.getMilliseconds() === 0 ? new IonDecimal_1.Decimal(date.getSeconds(), 0) : new IonDecimal_1.Decimal(date.getSeconds() * 1000 + date.getMilliseconds(), -3); + const date = dateOrLocalOffset; + const seconds = date.getMilliseconds() === 0 ? new IonDecimal_1.Decimal(date.getSeconds(), 0) : new IonDecimal_1.Decimal(date.getSeconds() * 1000 + date.getMilliseconds(), -3); this._localOffset = date.getTimezoneOffset() * -1; this._year = date.getFullYear(); this._month = date.getMonth() + 1; this._day = date.getDate(); this._hour = date.getHours(); this._minutes = date.getMinutes(); - this._secondsDecimal = _seconds; + this._secondsDecimal = seconds; this._precision = TimestampPrecision.YEAR; } else { - var localOffset = dateOrLocalOffset; + const localOffset = dateOrLocalOffset; if (localOffset === null) { throw new Error("Timestamp's constructor was called without localOffset"); } else if (year === null) { @@ -7341,251 +6262,202 @@ var Timestamp = /*#__PURE__*/function () { this._localOffset = -0; } if (this._precision > TimestampPrecision.MONTH) { - var tempDate = new Date(this._year, this._month, 0); + const tempDate = new Date(this._year, this._month, 0); tempDate.setUTCFullYear(this._year); if (this._day > tempDate.getDate()) { - throw new Error("Month ".concat(this._month, " has less than ").concat(this._day, " days")); + throw new Error(`Month ${this._month} has less than ${this._day} days`); } if (this._month === 2 && this._day === 29) { if (!this._isLeapYear(this._year)) { - throw new Error("Given February 29th but year ".concat(this._year, " is not a leap year")); + throw new Error(`Given February 29th but year ${this._year} is not a leap year`); } } } - var utcYear = this.getDate().getUTCFullYear(); + const utcYear = this.getDate().getUTCFullYear(); this._checkFieldRange("Year", utcYear, Timestamp._MIN_YEAR, Timestamp._MAX_YEAR); } - (0, _createClass2["default"])(Timestamp, [{ - key: "getLocalOffset", - value: function getLocalOffset() { - return this._localOffset; - } - }, { - key: "getPrecision", - value: function getPrecision() { - return this._precision; - } - }, { - key: "getDate", - value: function getDate() { - var ms = 0; - if (this._precision === TimestampPrecision.SECONDS) { - ms = Math.round((this._secondsDecimal.numberValue() - this.getSecondsInt()) * 1000); - } - var msSinceEpoch = Date.UTC(this._year, this._precision === TimestampPrecision.YEAR ? 0 : this._month - 1, this._day, this._hour, this._minutes, this.getSecondsInt(), ms); - msSinceEpoch = Timestamp._adjustMsSinceEpochIfNeeded(this._year, msSinceEpoch); - var offsetShiftMs = this._localOffset * 60 * 1000; - return new Date(msSinceEpoch - offsetShiftMs); - } - }, { - key: "getSecondsInt", - value: function getSecondsInt() { - return this._secondsDecimal.intValue(); - } - }, { - key: "getSecondsDecimal", - value: function getSecondsDecimal() { - return this._secondsDecimal; - } - }, { - key: "_getFractionalSeconds", - value: function _getFractionalSeconds() { - var _Timestamp$_splitSeco = Timestamp._splitSecondsDecimal(this._secondsDecimal), - _Timestamp$_splitSeco2 = (0, _slicedToArray2["default"])(_Timestamp$_splitSeco, 2), - _ = _Timestamp$_splitSeco2[0], - fractionStr = _Timestamp$_splitSeco2[1]; - if (fractionStr === "") { - return IonDecimal_1.Decimal.ZERO; - } - return IonDecimal_1.Decimal.parse(fractionStr + "d-" + fractionStr.length); - } - }, { - key: "equals", - value: function equals(that) { - return this.getPrecision() === that.getPrecision() && this.getLocalOffset() === that.getLocalOffset() && util_1._sign(this.getLocalOffset()) === util_1._sign(that.getLocalOffset()) && this.compareTo(that) === 0 && this._secondsDecimal.equals(that._secondsDecimal); - } - }, { - key: "compareTo", - value: function compareTo(that) { - var thisMs = this.getDate().getTime(); - var thatMs = that.getDate().getTime(); - if (thisMs === thatMs) { - return this.getSecondsDecimal().compareTo(that.getSecondsDecimal()); - } - return thisMs < thatMs ? -1 : 1; - } - }, { - key: "toString", - value: function toString() { - var strVal = ""; - switch (this._precision) { - default: - throw new Error("unrecognized timestamp precision " + this._precision); - case TimestampPrecision.SECONDS: - var _Timestamp$_splitSeco3 = Timestamp._splitSecondsDecimal(this._secondsDecimal), - _Timestamp$_splitSeco4 = (0, _slicedToArray2["default"])(_Timestamp$_splitSeco3, 2), - secondsStr = _Timestamp$_splitSeco4[0], - fractionStr = _Timestamp$_splitSeco4[1]; - strVal = this._lpadZeros(secondsStr, 2); - if (fractionStr.length > 0) { - strVal += "." + fractionStr; - } - case TimestampPrecision.HOUR_AND_MINUTE: - strVal = this._lpadZeros(this._minutes, 2) + (strVal ? ":" + strVal : ""); - strVal = this._lpadZeros(this._hour, 2) + (strVal ? ":" + strVal : ""); - case TimestampPrecision.DAY: - strVal = this._lpadZeros(this._day, 2) + (strVal ? "T" + strVal : "T"); - case TimestampPrecision.MONTH: - strVal = this._lpadZeros(this._month, 2) + (strVal ? "-" + strVal : ""); - case TimestampPrecision.YEAR: - if (this._precision === TimestampPrecision.YEAR) { - strVal = this._lpadZeros(this._year, 4) + "T"; - } else if (this._precision === TimestampPrecision.MONTH) { - strVal = this._lpadZeros(this._year, 4) + "-" + strVal + "T"; - } else { - strVal = this._lpadZeros(this._year, 4) + "-" + strVal; - } - } - var o = this._localOffset; - if (this._precision > TimestampPrecision.DAY) { - if (o === 0 && util_1._sign(o) === 1) { - strVal = strVal + "Z"; + static parse(str) { + return _TimestampParser._parse(str); + } + static _adjustMsSinceEpochIfNeeded(year, msSinceEpoch) { + if (year >= 100) { + return msSinceEpoch; + } + const date = new Date(msSinceEpoch); + date.setUTCFullYear(year); + return date.getTime(); + } + static _splitSecondsDecimal(secondsDecimal) { + const coefStr = secondsDecimal.getCoefficient().toString(); + const exp = secondsDecimal.getExponent(); + let secondsStr = ""; + let fractionStr = ""; + if (exp < 0) { + const idx = Math.max(coefStr.length + exp, 0); + secondsStr = coefStr.substring(0, idx); + fractionStr = coefStr.substring(idx); + if (-secondsDecimal.getExponent() - coefStr.length > 0) { + fractionStr = "0".repeat(-exp - coefStr.length) + fractionStr; + } + } else if (exp > 0) { + secondsStr = coefStr + "0".repeat(exp); + } else { + secondsStr = coefStr; + } + return [secondsStr, fractionStr]; + } + static _valueOf(date, localOffset, fractionalSeconds, precision) { + const msSinceEpoch = date.getTime() + localOffset * 60 * 1000; + date = new Date(msSinceEpoch); + let secondsDecimal; + if (fractionalSeconds != null) { + const [_, fractionStr] = Timestamp._splitSecondsDecimal(fractionalSeconds); + secondsDecimal = IonDecimal_1.Decimal.parse(date.getUTCSeconds() + "." + fractionStr); + } else { + secondsDecimal = IonDecimal_1.Decimal.parse(date.getUTCSeconds() + "." + date.getUTCMilliseconds()); + } + switch (precision) { + case TimestampPrecision.YEAR: + return new Timestamp(localOffset, date.getUTCFullYear()); + case TimestampPrecision.MONTH: + return new Timestamp(localOffset, date.getUTCFullYear(), date.getUTCMonth() + 1); + case TimestampPrecision.DAY: + return new Timestamp(localOffset, date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()); + case TimestampPrecision.HOUR_AND_MINUTE: + return new Timestamp(localOffset, date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes()); + case TimestampPrecision.SECONDS: + default: + return new Timestamp(localOffset, date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), secondsDecimal); + } + } + getLocalOffset() { + return this._localOffset; + } + getPrecision() { + return this._precision; + } + getDate() { + let ms = 0; + if (this._precision === TimestampPrecision.SECONDS) { + ms = Math.round((this._secondsDecimal.numberValue() - this.getSecondsInt()) * 1000); + } + let msSinceEpoch = Date.UTC(this._year, this._precision === TimestampPrecision.YEAR ? 0 : this._month - 1, this._day, this._hour, this._minutes, this.getSecondsInt(), ms); + msSinceEpoch = Timestamp._adjustMsSinceEpochIfNeeded(this._year, msSinceEpoch); + const offsetShiftMs = this._localOffset * 60 * 1000; + return new Date(msSinceEpoch - offsetShiftMs); + } + getSecondsInt() { + return this._secondsDecimal.intValue(); + } + getSecondsDecimal() { + return this._secondsDecimal; + } + _getFractionalSeconds() { + const [_, fractionStr] = Timestamp._splitSecondsDecimal(this._secondsDecimal); + if (fractionStr === "") { + return IonDecimal_1.Decimal.ZERO; + } + return IonDecimal_1.Decimal.parse(fractionStr + "d-" + fractionStr.length); + } + equals(that) { + return this.getPrecision() === that.getPrecision() && this.getLocalOffset() === that.getLocalOffset() && util_1._sign(this.getLocalOffset()) === util_1._sign(that.getLocalOffset()) && this.compareTo(that) === 0 && this._secondsDecimal.equals(that._secondsDecimal); + } + compareTo(that) { + const thisMs = this.getDate().getTime(); + const thatMs = that.getDate().getTime(); + if (thisMs === thatMs) { + return this.getSecondsDecimal().compareTo(that.getSecondsDecimal()); + } + return thisMs < thatMs ? -1 : 1; + } + toString() { + let strVal = ""; + switch (this._precision) { + default: + throw new Error("unrecognized timestamp precision " + this._precision); + case TimestampPrecision.SECONDS: + const [secondsStr, fractionStr] = Timestamp._splitSecondsDecimal(this._secondsDecimal); + strVal = this._lpadZeros(secondsStr, 2); + if (fractionStr.length > 0) { + strVal += "." + fractionStr; + } + case TimestampPrecision.HOUR_AND_MINUTE: + strVal = this._lpadZeros(this._minutes, 2) + (strVal ? ":" + strVal : ""); + strVal = this._lpadZeros(this._hour, 2) + (strVal ? ":" + strVal : ""); + case TimestampPrecision.DAY: + strVal = this._lpadZeros(this._day, 2) + (strVal ? "T" + strVal : "T"); + case TimestampPrecision.MONTH: + strVal = this._lpadZeros(this._month, 2) + (strVal ? "-" + strVal : ""); + case TimestampPrecision.YEAR: + if (this._precision === TimestampPrecision.YEAR) { + strVal = this._lpadZeros(this._year, 4) + "T"; + } else if (this._precision === TimestampPrecision.MONTH) { + strVal = this._lpadZeros(this._year, 4) + "-" + strVal + "T"; } else { - strVal += (util_1._sign(o) === -1 ? "-" : "+") + this._lpadZeros(Math.floor(Math.abs(o) / 60), 2) + ":" + this._lpadZeros(Math.abs(o) % 60, 2); + strVal = this._lpadZeros(this._year, 4) + "-" + strVal; } - } - return strVal; } - }, { - key: "toJSON", - value: function toJSON() { - return this.getDate().toISOString(); - } - }, { - key: "_checkRequiredField", - value: function _checkRequiredField(fieldName, value, min, max) { - if (!util_1._hasValue(value)) { - throw new Error("".concat(fieldName, " cannot be ").concat(value)); + const o = this._localOffset; + if (this._precision > TimestampPrecision.DAY) { + if (o === 0 && util_1._sign(o) === 1) { + strVal = strVal + "Z"; + } else { + strVal += (util_1._sign(o) === -1 ? "-" : "+") + this._lpadZeros(Math.floor(Math.abs(o) / 60), 2) + ":" + this._lpadZeros(Math.abs(o) % 60, 2); } - this._checkFieldRange(fieldName, value, min, max); } - }, { - key: "_checkOptionalField", - value: function _checkOptionalField(fieldName, value, min, max, defaultValue, precision) { - if (!util_1._hasValue(value)) { - return defaultValue; - } - this._checkFieldRange(fieldName, value, min, max); - this._precision = precision; - return value; + return strVal; + } + toJSON() { + return this.getDate().toISOString(); + } + _checkRequiredField(fieldName, value, min, max) { + if (!util_1._hasValue(value)) { + throw new Error(`${fieldName} cannot be ${value}`); } - }, { - key: "_checkFieldRange", - value: function _checkFieldRange(fieldName, value, min, max) { - if (value instanceof IonDecimal_1.Decimal) { - if (util_1._hasValue(value) && (value.compareTo(min) < 0 || value.compareTo(max) >= 0)) { - throw new Error("".concat(fieldName, " ").concat(value, " must be between ").concat(min, " inclusive, and ").concat(max, " exclusive")); - } - } else { - if (!Number.isInteger(value)) { - throw new Error("".concat(fieldName, " ").concat(value, " must be an integer")); - } - if (value < min || value > max) { - throw new Error("".concat(fieldName, " ").concat(value, " must be between ").concat(min, " and ").concat(max, " inclusive")); - } - } + this._checkFieldRange(fieldName, value, min, max); + } + _checkOptionalField(fieldName, value, min, max, defaultValue, precision) { + if (!util_1._hasValue(value)) { + return defaultValue; } - }, { - key: "_isLeapYear", - value: function _isLeapYear(year) { - if (year % 4 !== 0) { - return false; + this._checkFieldRange(fieldName, value, min, max); + this._precision = precision; + return value; + } + _checkFieldRange(fieldName, value, min, max) { + if (value instanceof IonDecimal_1.Decimal) { + if (util_1._hasValue(value) && (value.compareTo(min) < 0 || value.compareTo(max) >= 0)) { + throw new Error(`${fieldName} ${value} must be between ${min} inclusive, and ${max} exclusive`); } - if (year % 400 === 0) { - return true; + } else { + if (!Number.isInteger(value)) { + throw new Error(`${fieldName} ${value} must be an integer`); } - if (year % 100 === 0) { - return year < 1600; + if (value < min || value > max) { + throw new Error(`${fieldName} ${value} must be between ${min} and ${max} inclusive`); } + } + } + _isLeapYear(year) { + if (year % 4 !== 0) { + return false; + } + if (year % 400 === 0) { return true; } - }, { - key: "_lpadZeros", - value: function _lpadZeros(v, size) { - var s = v.toString(); - if (s.length <= size) { - return "0".repeat(size - s.length) + s; - } - throw new Error("Unable to fit '" + s + "' into " + size + " characters"); - } - }], [{ - key: "parse", - value: function parse(str) { - return _TimestampParser._parse(str); - } - }, { - key: "_adjustMsSinceEpochIfNeeded", - value: function _adjustMsSinceEpochIfNeeded(year, msSinceEpoch) { - if (year >= 100) { - return msSinceEpoch; - } - var date = new Date(msSinceEpoch); - date.setUTCFullYear(year); - return date.getTime(); - } - }, { - key: "_splitSecondsDecimal", - value: function _splitSecondsDecimal(secondsDecimal) { - var coefStr = secondsDecimal.getCoefficient().toString(); - var exp = secondsDecimal.getExponent(); - var secondsStr = ""; - var fractionStr = ""; - if (exp < 0) { - var idx = Math.max(coefStr.length + exp, 0); - secondsStr = coefStr.substring(0, idx); - fractionStr = coefStr.substring(idx); - if (-secondsDecimal.getExponent() - coefStr.length > 0) { - fractionStr = "0".repeat(-exp - coefStr.length) + fractionStr; - } - } else if (exp > 0) { - secondsStr = coefStr + "0".repeat(exp); - } else { - secondsStr = coefStr; - } - return [secondsStr, fractionStr]; - } - }, { - key: "_valueOf", - value: function _valueOf(date, localOffset, fractionalSeconds, precision) { - var msSinceEpoch = date.getTime() + localOffset * 60 * 1000; - date = new Date(msSinceEpoch); - var secondsDecimal; - if (fractionalSeconds != null) { - var _Timestamp$_splitSeco5 = Timestamp._splitSecondsDecimal(fractionalSeconds), - _Timestamp$_splitSeco6 = (0, _slicedToArray2["default"])(_Timestamp$_splitSeco5, 2), - _ = _Timestamp$_splitSeco6[0], - fractionStr = _Timestamp$_splitSeco6[1]; - secondsDecimal = IonDecimal_1.Decimal.parse(date.getUTCSeconds() + "." + fractionStr); - } else { - secondsDecimal = IonDecimal_1.Decimal.parse(date.getUTCSeconds() + "." + date.getUTCMilliseconds()); - } - switch (precision) { - case TimestampPrecision.YEAR: - return new Timestamp(localOffset, date.getUTCFullYear()); - case TimestampPrecision.MONTH: - return new Timestamp(localOffset, date.getUTCFullYear(), date.getUTCMonth() + 1); - case TimestampPrecision.DAY: - return new Timestamp(localOffset, date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()); - case TimestampPrecision.HOUR_AND_MINUTE: - return new Timestamp(localOffset, date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes()); - case TimestampPrecision.SECONDS: - default: - return new Timestamp(localOffset, date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), secondsDecimal); - } + if (year % 100 === 0) { + return year < 1600; + } + return true; + } + _lpadZeros(v, size) { + const s = v.toString(); + if (s.length <= size) { + return "0".repeat(size - s.length) + s; } - }]); - return Timestamp; -}(); + throw new Error("Unable to fit '" + s + "' into " + size + " characters"); + } +} exports.Timestamp = Timestamp; Timestamp._MIN_SECONDS = IonDecimal_1.Decimal.ZERO; Timestamp._MAX_SECONDS = IonDecimal_1.Decimal.parse("60"); @@ -7616,192 +6488,195 @@ var _States; _States[_States["OFFSET_ZULU"] = 10] = "OFFSET_ZULU"; _States[_States["OFFSET_UNKNOWN"] = 11] = "OFFSET_UNKNOWN"; })(_States || (_States = {})); -var _TimeParserState = /*#__PURE__*/(0, _createClass2["default"])(function _TimeParserState(f, len) { - var t = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - (0, _classCallCheck2["default"])(this, _TimeParserState); - this.f = f; - this.len = len; - this.t = t; -}); -var _TimestampParser = /*#__PURE__*/function () { - function _TimestampParser() { - (0, _classCallCheck2["default"])(this, _TimestampParser); - } - (0, _createClass2["default"])(_TimestampParser, null, [{ - key: "_parse", - value: function _parse(str) { - if (str.length < 1) { +class _TimeParserState { + constructor(f, len) { + let t = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + this.f = f; + this.len = len; + this.t = t; + } +} +class _TimestampParser { + static _parse(str) { + if (str.length < 1) { + return null; + } + if (str.charCodeAt(0) === 110) { + if (str === "null" || str === "null.timestamp") { return null; } - if (str.charCodeAt(0) === 110) { - if (str === "null" || str === "null.timestamp") { - return null; - } - throw new Error("Illegal timestamp: " + str); - } - var offsetSign; - var offset = null; - var year = 0; - var month = null; - var day = null; - var hour = null; - var minute = null; - var secondsInt = null; - var fractionStr = ""; - var pos = 0; - var state = _TimestampParser._timeParserStates[_States.YEAR]; - var limit = str.length; - var v; - while (pos < limit) { - if (state.len === null) { - var digits = _TimestampParser._readUnknownDigits(str, pos); - if (digits.length === 0) { - throw new Error("No digits found at pos: " + pos); - } - v = parseInt(digits, 10); - pos += digits.length; - } else if (state.len > 0) { - v = _TimestampParser._readDigits(str, pos, state.len); - if (v < 0) { - throw new Error("Non-digit value found at pos " + pos); + throw new Error("Illegal timestamp: " + str); + } + let offsetSign; + let offset = null; + let year = 0; + let month = null; + let day = null; + let hour = null; + let minute = null; + let secondsInt = null; + let fractionStr = ""; + let pos = 0; + let state = _TimestampParser._timeParserStates[_States.YEAR]; + const limit = str.length; + let v; + while (pos < limit) { + if (state.len === null) { + const digits = _TimestampParser._readUnknownDigits(str, pos); + if (digits.length === 0) { + throw new Error("No digits found at pos: " + pos); + } + v = parseInt(digits, 10); + pos += digits.length; + } else if (state.len > 0) { + v = _TimestampParser._readDigits(str, pos, state.len); + if (v < 0) { + throw new Error("Non-digit value found at pos " + pos); + } + pos = pos + state.len; + } + v = v; + switch (state.f) { + case _States.YEAR: + year = v; + break; + case _States.MONTH: + month = v; + break; + case _States.DAY: + day = v; + break; + case _States.HOUR: + hour = v; + break; + case _States.MINUTE: + minute = v; + break; + case _States.SECONDS: + secondsInt = v; + break; + case _States.FRACTIONAL_SECONDS: + fractionStr = str.substring(20, pos); + break; + case _States.OFFSET_POSITIVE: + offsetSign = 1; + offset = v * 60; + break; + case _States.OFFSET_NEGATIVE: + offsetSign = -1; + offset = v * 60; + break; + case _States.OFFSET_MINUTES: + offset += v; + if (v >= 60) { + throw new Error("Minute offset " + String(v) + " above maximum or equal to : 60"); } - pos = pos + state.len; - } - v = v; - switch (state.f) { - case _States.YEAR: - year = v; - break; - case _States.MONTH: - month = v; - break; - case _States.DAY: - day = v; - break; - case _States.HOUR: - hour = v; - break; - case _States.MINUTE: - minute = v; - break; - case _States.SECONDS: - secondsInt = v; - break; - case _States.FRACTIONAL_SECONDS: - fractionStr = str.substring(20, pos); - break; - case _States.OFFSET_POSITIVE: - offsetSign = 1; - offset = v * 60; - break; - case _States.OFFSET_NEGATIVE: - offsetSign = -1; - offset = v * 60; - break; - case _States.OFFSET_MINUTES: - offset += v; - if (v >= 60) { - throw new Error("Minute offset " + String(v) + " above maximum or equal to : 60"); - } - break; - case _States.OFFSET_ZULU: - offsetSign = 1; - offset = 0; - break; - case _States.OFFSET_UNKNOWN: - offset = -0; - break; - default: - throw new Error("invalid internal state"); - } - if (pos >= limit) { break; + case _States.OFFSET_ZULU: + offsetSign = 1; + offset = 0; + break; + case _States.OFFSET_UNKNOWN: + offset = -0; + break; + default: + throw new Error("invalid internal state"); + } + if (pos >= limit) { + break; + } + if (state.t !== null) { + const c = String.fromCharCode(str.charCodeAt(pos)); + state = _TimestampParser._timeParserStates[state.t[c]]; + if (state === undefined) { + throw new Error("State was not set pos:" + pos); } - if (state.t !== null) { - var c = String.fromCharCode(str.charCodeAt(pos)); - state = _TimestampParser._timeParserStates[state.t[c]]; - if (state === undefined) { - throw new Error("State was not set pos:" + pos); - } - if (state.f === _States.OFFSET_ZULU) { - offsetSign = 1; - offset = 0; - } + if (state.f === _States.OFFSET_ZULU) { + offsetSign = 1; + offset = 0; } - pos++; } - if (offset === null) { - if (minute !== null) { - throw new Error('invalid timestamp, missing local offset: "' + str + '"'); - } - offset = -0; - } else { - offset = offsetSign * offset; + pos++; + } + if (offset === null) { + if (minute !== null) { + throw new Error('invalid timestamp, missing local offset: "' + str + '"'); } - var seconds; - if (secondsInt !== undefined && secondsInt !== null || fractionStr) { - seconds = IonDecimal_1.Decimal.parse(secondsInt + "." + (fractionStr ? fractionStr : "")); + offset = -0; + } else { + offset = offsetSign * offset; + } + let seconds; + if (secondsInt !== undefined && secondsInt !== null || fractionStr) { + seconds = IonDecimal_1.Decimal.parse(secondsInt + "." + (fractionStr ? fractionStr : "")); + } + return new Timestamp(offset, year, month, day, hour, minute, seconds); + } + static _readUnknownDigits(str, pos) { + let i = pos; + for (; i < str.length; i++) { + if (!IonText_1.isDigit(str.charCodeAt(i))) { + break; } - return new Timestamp(offset, year, month, day, hour, minute, seconds); } - }, { - key: "_readUnknownDigits", - value: function _readUnknownDigits(str, pos) { - var i = pos; - for (; i < str.length; i++) { - if (!IonText_1.isDigit(str.charCodeAt(i))) { - break; - } + return str.substring(pos, i); + } + static _readDigits(str, pos, len) { + let v = 0; + for (let i = pos; i < pos + len; i++) { + const c = str.charCodeAt(i) - 48; + if (c < 0 && c > 9) { + return -1; } - return str.substring(pos, i); - } - }, { - key: "_readDigits", - value: function _readDigits(str, pos, len) { - var v = 0; - for (var i = pos; i < pos + len; i++) { - var c = str.charCodeAt(i) - 48; - if (c < 0 && c > 9) { - return -1; - } - v = v * 10 + c; - } - return v; - } - }]); - return _TimestampParser; -}(); -_TimestampParser._timeParserStates = (_TimestampParser$_tim = {}, (0, _defineProperty2["default"])(_TimestampParser$_tim, _States.YEAR, new _TimeParserState(_States.YEAR, 4, { - T: _States.OFFSET_UNKNOWN, - "-": _States.MONTH -})), (0, _defineProperty2["default"])(_TimestampParser$_tim, _States.MONTH, new _TimeParserState(_States.MONTH, 2, { - T: _States.OFFSET_UNKNOWN, - "-": _States.DAY -})), (0, _defineProperty2["default"])(_TimestampParser$_tim, _States.DAY, new _TimeParserState(_States.DAY, 2, { - T: _States.HOUR -})), (0, _defineProperty2["default"])(_TimestampParser$_tim, _States.HOUR, new _TimeParserState(_States.HOUR, 2, { - ":": _States.MINUTE -})), (0, _defineProperty2["default"])(_TimestampParser$_tim, _States.MINUTE, new _TimeParserState(_States.MINUTE, 2, { - ":": _States.SECONDS, - "+": _States.OFFSET_POSITIVE, - "-": _States.OFFSET_NEGATIVE, - Z: _States.OFFSET_ZULU -})), (0, _defineProperty2["default"])(_TimestampParser$_tim, _States.SECONDS, new _TimeParserState(_States.SECONDS, 2, { - ".": _States.FRACTIONAL_SECONDS, - "+": _States.OFFSET_POSITIVE, - "-": _States.OFFSET_NEGATIVE, - Z: _States.OFFSET_ZULU -})), (0, _defineProperty2["default"])(_TimestampParser$_tim, _States.FRACTIONAL_SECONDS, new _TimeParserState(_States.FRACTIONAL_SECONDS, null, { - "+": _States.OFFSET_POSITIVE, - "-": _States.OFFSET_NEGATIVE, - Z: _States.OFFSET_ZULU -})), (0, _defineProperty2["default"])(_TimestampParser$_tim, _States.OFFSET_POSITIVE, new _TimeParserState(_States.OFFSET_POSITIVE, 2, { - ":": _States.OFFSET_MINUTES -})), (0, _defineProperty2["default"])(_TimestampParser$_tim, _States.OFFSET_NEGATIVE, new _TimeParserState(_States.OFFSET_NEGATIVE, 2, { - ":": _States.OFFSET_MINUTES -})), (0, _defineProperty2["default"])(_TimestampParser$_tim, _States.OFFSET_MINUTES, new _TimeParserState(_States.OFFSET_MINUTES, 2)), (0, _defineProperty2["default"])(_TimestampParser$_tim, _States.OFFSET_ZULU, new _TimeParserState(_States.OFFSET_ZULU, 0)), (0, _defineProperty2["default"])(_TimestampParser$_tim, _States.OFFSET_UNKNOWN, new _TimeParserState(_States.OFFSET_UNKNOWN, 0)), _TimestampParser$_tim); + v = v * 10 + c; + } + return v; + } +} +_TimestampParser._timeParserStates = { + [_States.YEAR]: new _TimeParserState(_States.YEAR, 4, { + T: _States.OFFSET_UNKNOWN, + "-": _States.MONTH + }), + [_States.MONTH]: new _TimeParserState(_States.MONTH, 2, { + T: _States.OFFSET_UNKNOWN, + "-": _States.DAY + }), + [_States.DAY]: new _TimeParserState(_States.DAY, 2, { + T: _States.HOUR + }), + [_States.HOUR]: new _TimeParserState(_States.HOUR, 2, { + ":": _States.MINUTE + }), + [_States.MINUTE]: new _TimeParserState(_States.MINUTE, 2, { + ":": _States.SECONDS, + "+": _States.OFFSET_POSITIVE, + "-": _States.OFFSET_NEGATIVE, + Z: _States.OFFSET_ZULU + }), + [_States.SECONDS]: new _TimeParserState(_States.SECONDS, 2, { + ".": _States.FRACTIONAL_SECONDS, + "+": _States.OFFSET_POSITIVE, + "-": _States.OFFSET_NEGATIVE, + Z: _States.OFFSET_ZULU + }), + [_States.FRACTIONAL_SECONDS]: new _TimeParserState(_States.FRACTIONAL_SECONDS, null, { + "+": _States.OFFSET_POSITIVE, + "-": _States.OFFSET_NEGATIVE, + Z: _States.OFFSET_ZULU + }), + [_States.OFFSET_POSITIVE]: new _TimeParserState(_States.OFFSET_POSITIVE, 2, { + ":": _States.OFFSET_MINUTES + }), + [_States.OFFSET_NEGATIVE]: new _TimeParserState(_States.OFFSET_NEGATIVE, 2, { + ":": _States.OFFSET_MINUTES + }), + [_States.OFFSET_MINUTES]: new _TimeParserState(_States.OFFSET_MINUTES, 2), + [_States.OFFSET_ZULU]: new _TimeParserState(_States.OFFSET_ZULU, 0), + [_States.OFFSET_UNKNOWN]: new _TimeParserState(_States.OFFSET_UNKNOWN, 0) +}; -},{"./IonDecimal":11,"./IonText":24,"./util":55,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/defineProperty":63,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/slicedToArray":77}],28:[function(require,module,exports){ +},{"./IonDecimal":11,"./IonText":24,"./util":55}],28:[function(require,module,exports){ "use strict"; /*! @@ -7818,25 +6693,23 @@ _TimestampParser._timeParserStates = (_TimestampParser$_tim = {}, (0, _definePro * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); Object.defineProperty(exports, "__esModule", { value: true }); exports.IonType = void 0; -var IonType = /*#__PURE__*/(0, _createClass2["default"])(function IonType(binaryTypeId, name, isScalar, isLob, isNumeric, isContainer) { - (0, _classCallCheck2["default"])(this, IonType); - this.binaryTypeId = binaryTypeId; - this.name = name; - this.isScalar = isScalar; - this.isLob = isLob; - this.isNumeric = isNumeric; - this.isContainer = isContainer; -}); +class IonType { + constructor(binaryTypeId, name, isScalar, isLob, isNumeric, isContainer) { + this.binaryTypeId = binaryTypeId; + this.name = name; + this.isScalar = isScalar; + this.isLob = isLob; + this.isNumeric = isNumeric; + this.isContainer = isContainer; + } +} exports.IonType = IonType; -},{"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],29:[function(require,module,exports){ +},{}],29:[function(require,module,exports){ "use strict"; /*! @@ -7857,7 +6730,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.IonTypes = void 0; -var IonType_1 = require("./IonType"); +const IonType_1 = require("./IonType"); exports.IonTypes = { NULL: new IonType_1.IonType(0, "null", true, false, false, false), BOOL: new IonType_1.IonType(1, "bool", true, false, false, false), @@ -7895,8 +6768,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.decodeUtf8 = exports.encodeUtf8 = void 0; -var JS_DECODER_MAX_BYTES = 512; -var textDecoder; +const JS_DECODER_MAX_BYTES = 512; +let textDecoder; if (typeof TextDecoder !== "undefined") { textDecoder = new TextDecoder("utf8", { fatal: true @@ -7905,10 +6778,10 @@ if (typeof TextDecoder !== "undefined") { textDecoder = null; } function encodeUtf8(s) { - var i = 0, + let i = 0, c; - var bytes = new Uint8Array(s.length * 4); - for (var ci = 0; ci < s.length; ci++) { + const bytes = new Uint8Array(s.length * 4); + for (let ci = 0; ci < s.length; ci++) { c = s.charCodeAt(ci); if (c < 128) { bytes[i++] = c; @@ -7921,7 +6794,7 @@ function encodeUtf8(s) { if (++ci >= s.length) { throw new Error("UTF-8 encode: incomplete surrogate pair"); } - var c2 = s.charCodeAt(ci); + const c2 = s.charCodeAt(ci); if (c2 < 0xdc00 || c2 > 0xdfff) { throw new Error("UTF-8 encode: second surrogate character 0x" + c2.toString(16) + " at index " + ci + " out of range"); } @@ -7942,7 +6815,7 @@ function decodeUtf8(bytes) { if (bytes.length > JS_DECODER_MAX_BYTES && textDecoder != null) { return textDecoder.decode(bytes); } - var i = 0, + let i = 0, s = "", c; while (i < bytes.length) { @@ -7998,88 +6871,72 @@ exports.decodeUtf8 = decodeUtf8; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); Object.defineProperty(exports, "__esModule", { value: true }); exports.Writeable = void 0; -var Writeable = /*#__PURE__*/function () { - function Writeable(bufferSize) { - (0, _classCallCheck2["default"])(this, Writeable); +class Writeable { + constructor(bufferSize) { this.bufferSize = bufferSize ? bufferSize : 4096; this.buffers = [new Uint8Array(this.bufferSize)]; this.index = 0; this.clean = false; } - (0, _createClass2["default"])(Writeable, [{ - key: "currentBuffer", - get: function get() { - return this.buffers[this.buffers.length - 1]; + get currentBuffer() { + return this.buffers[this.buffers.length - 1]; + } + get totalSize() { + let size = 0; + for (let i = 0; i < this.buffers.length - 1; i++) { + size += this.buffers[i].length; } - }, { - key: "totalSize", - get: function get() { - var size = 0; - for (var i = 0; i < this.buffers.length - 1; i++) { - size += this.buffers[i].length; - } - return size + this.index; + return size + this.index; + } + writeByte(byte) { + this.clean = false; + this.currentBuffer[this.index] = byte; + this.index++; + if (this.index === this.bufferSize) { + this.buffers.push(new Uint8Array(this.bufferSize)); + this.index = 0; + } + } + writeBytes(buf, offset, length) { + if (offset === undefined) { + offset = 0; } - }, { - key: "writeByte", - value: function writeByte(_byte) { + const writeLength = length !== undefined ? Math.min(buf.length - offset, length) : buf.length - offset; + if (writeLength < this.currentBuffer.length - this.index - 1) { + this.currentBuffer.set(buf.subarray(offset, offset + writeLength), this.index); + this.index += writeLength; + } else { + this.buffers[this.buffers.length - 1] = this.currentBuffer.slice(0, this.index); + this.buffers.push(buf.subarray(offset, length)); + this.buffers.push(new Uint8Array(this.bufferSize)); this.clean = false; - this.currentBuffer[this.index] = _byte; - this.index++; - if (this.index === this.bufferSize) { - this.buffers.push(new Uint8Array(this.bufferSize)); - this.index = 0; - } - } - }, { - key: "writeBytes", - value: function writeBytes(buf, offset, length) { - if (offset === undefined) { - offset = 0; - } - var writeLength = length !== undefined ? Math.min(buf.length - offset, length) : buf.length - offset; - if (writeLength < this.currentBuffer.length - this.index - 1) { - this.currentBuffer.set(buf.subarray(offset, offset + writeLength), this.index); - this.index += writeLength; - } else { - this.buffers[this.buffers.length - 1] = this.currentBuffer.slice(0, this.index); - this.buffers.push(buf.subarray(offset, length)); - this.buffers.push(new Uint8Array(this.bufferSize)); - this.clean = false; - this.index = 0; - } - } - }, { - key: "getBytes", - value: function getBytes() { - if (this.clean) { - return this.buffers[0]; - } - var buffer = new Uint8Array(this.totalSize); - var tempLength = 0; - for (var i = 0; i < this.buffers.length - 1; i++) { - buffer.set(this.buffers[i], tempLength); - tempLength += this.buffers[i].length; - } - buffer.set(this.currentBuffer.subarray(0, this.index), tempLength); - this.buffers = [buffer, new Uint8Array(this.bufferSize)]; this.index = 0; - this.clean = true; - return buffer; } - }]); - return Writeable; -}(); + } + getBytes() { + if (this.clean) { + return this.buffers[0]; + } + const buffer = new Uint8Array(this.totalSize); + let tempLength = 0; + for (let i = 0; i < this.buffers.length - 1; i++) { + buffer.set(this.buffers[i], tempLength); + tempLength += this.buffers[i].length; + } + buffer.set(this.currentBuffer.subarray(0, this.index), tempLength); + this.buffers = [buffer, new Uint8Array(this.bufferSize)]; + this.index = 0; + this.clean = true; + return buffer; + } +} exports.Writeable = Writeable; -},{"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],32:[function(require,module,exports){ +},{}],32:[function(require,module,exports){ "use strict"; /*! @@ -8096,245 +6953,156 @@ exports.Writeable = Writeable; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); Object.defineProperty(exports, "__esModule", { value: true }); -var SignAndMagnitudeInt = /*#__PURE__*/function () { - function SignAndMagnitudeInt(_magnitude) { - var _isNegative = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _magnitude < 0n; - (0, _classCallCheck2["default"])(this, SignAndMagnitudeInt); +class SignAndMagnitudeInt { + constructor(_magnitude) { + let _isNegative = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _magnitude < 0n; this._magnitude = _magnitude; this._isNegative = _isNegative; } - (0, _createClass2["default"])(SignAndMagnitudeInt, [{ - key: "magnitude", - get: function get() { - return this._magnitude; - } - }, { - key: "isNegative", - get: function get() { - return this._isNegative; - } - }, { - key: "equals", - value: function equals(other) { - return this._magnitude === other._magnitude && this._isNegative === other._isNegative; - } - }], [{ - key: "fromNumber", - value: function fromNumber(value) { - var isNegative = value < 0 || Object.is(value, -0); - var absoluteValue = Math.abs(value); - var magnitude = BigInt(absoluteValue); - return new SignAndMagnitudeInt(magnitude, isNegative); - } - }]); - return SignAndMagnitudeInt; -}(); -exports["default"] = SignAndMagnitudeInt; + get magnitude() { + return this._magnitude; + } + get isNegative() { + return this._isNegative; + } + static fromNumber(value) { + const isNegative = value < 0 || Object.is(value, -0); + const absoluteValue = Math.abs(value); + const magnitude = BigInt(absoluteValue); + return new SignAndMagnitudeInt(magnitude, isNegative); + } + equals(other) { + return this._magnitude === other._magnitude && this._isNegative === other._isNegative; + } +} +exports.default = SignAndMagnitudeInt; -},{"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],33:[function(require,module,exports){ +},{}],33:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.Blob = void 0; -var Ion_1 = require("../Ion"); -var Lob_1 = require("./Lob"); -var Blob = /*#__PURE__*/function (_Lob_1$Lob) { - (0, _inherits2["default"])(Blob, _Lob_1$Lob); - var _super = _createSuper(Blob); - function Blob(data) { - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, Blob); - return _super.call(this, data, annotations); - } - (0, _createClass2["default"])(Blob, [{ - key: "toJSON", - value: function toJSON() { - return Ion_1.toBase64(this); - } - }, { - key: "writeTo", - value: function writeTo(writer) { - writer.setAnnotations(this.getAnnotations()); - writer.writeBlob(this); - } - }]); - return Blob; -}(Lob_1.Lob(Ion_1.IonTypes.BLOB)); +const Ion_1 = require("../Ion"); +const Lob_1 = require("./Lob"); +class Blob extends Lob_1.Lob(Ion_1.IonTypes.BLOB) { + constructor(data) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + super(data, annotations); + } + toJSON() { + return Ion_1.toBase64(this); + } + writeTo(writer) { + writer.setAnnotations(this.getAnnotations()); + writer.writeBlob(this); + } +} exports.Blob = Blob; -},{"../Ion":5,"./Lob":42,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],34:[function(require,module,exports){ +},{"../Ion":5,"./Lob":42}],34:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.Boolean = void 0; -var Ion_1 = require("../Ion"); -var FromJsConstructor_1 = require("./FromJsConstructor"); -var JsValueConversion_1 = require("./JsValueConversion"); -var Value_1 = require("./Value"); -var _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withPrimitives(FromJsConstructor_1.Primitives.Boolean).withClassesToUnbox(JsValueConversion_1._NativeJsBoolean).build(); -var _Boolean = /*#__PURE__*/function (_Value_1$Value) { - (0, _inherits2["default"])(Boolean, _Value_1$Value); - var _super = _createSuper(Boolean); - function Boolean(value) { - var _this; - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, Boolean); - _this = _super.call(this, value); - _this._setAnnotations(annotations); - return _this; - } - (0, _createClass2["default"])(Boolean, [{ - key: "booleanValue", - value: function booleanValue() { - return this.valueOf(); - } - }, { - key: "writeTo", - value: function writeTo(writer) { - writer.setAnnotations(this.getAnnotations()); - writer.writeBoolean(this.booleanValue()); - } - }, { - key: "_valueEquals", - value: function _valueEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null, - ignoreAnnotations: false, - ignoreTimestampPrecision: false, - onlyCompareIon: true - }; - var isSupportedType = false; - var valueToCompare = null; - if (other instanceof _Boolean) { +const Ion_1 = require("../Ion"); +const FromJsConstructor_1 = require("./FromJsConstructor"); +const JsValueConversion_1 = require("./JsValueConversion"); +const Value_1 = require("./Value"); +const _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withPrimitives(FromJsConstructor_1.Primitives.Boolean).withClassesToUnbox(JsValueConversion_1._NativeJsBoolean).build(); +class Boolean extends Value_1.Value(JsValueConversion_1._NativeJsBoolean, Ion_1.IonTypes.BOOL, _fromJsConstructor) { + constructor(value) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + super(value); + this._setAnnotations(annotations); + } + booleanValue() { + return this.valueOf(); + } + writeTo(writer) { + writer.setAnnotations(this.getAnnotations()); + writer.writeBoolean(this.booleanValue()); + } + _valueEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null, + ignoreAnnotations: false, + ignoreTimestampPrecision: false, + onlyCompareIon: true + }; + let isSupportedType = false; + let valueToCompare = null; + if (other instanceof Boolean) { + isSupportedType = true; + valueToCompare = other.booleanValue(); + } else if (!options.onlyCompareIon) { + if (typeof other === "boolean" || other instanceof JsValueConversion_1._NativeJsBoolean) { isSupportedType = true; - valueToCompare = other.booleanValue(); - } else if (!options.onlyCompareIon) { - if (typeof other === "boolean" || other instanceof JsValueConversion_1._NativeJsBoolean) { - isSupportedType = true; - valueToCompare = other.valueOf(); - } - } - if (!isSupportedType) { - return false; - } - if (this.booleanValue() !== valueToCompare) { - return false; + valueToCompare = other.valueOf(); } - return true; } - }]); - return Boolean; -}(Value_1.Value(JsValueConversion_1._NativeJsBoolean, Ion_1.IonTypes.BOOL, _fromJsConstructor)); -exports.Boolean = _Boolean; + if (!isSupportedType) { + return false; + } + if (this.booleanValue() !== valueToCompare) { + return false; + } + return true; + } +} +exports.Boolean = Boolean; -},{"../Ion":5,"./FromJsConstructor":38,"./JsValueConversion":40,"./Value":50,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],35:[function(require,module,exports){ +},{"../Ion":5,"./FromJsConstructor":38,"./JsValueConversion":40,"./Value":50}],35:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.Clob = void 0; -var Ion_1 = require("../Ion"); -var Lob_1 = require("./Lob"); -var Clob = /*#__PURE__*/function (_Lob_1$Lob) { - (0, _inherits2["default"])(Clob, _Lob_1$Lob); - var _super = _createSuper(Clob); - function Clob(bytes) { - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, Clob); - return _super.call(this, bytes, annotations); - } - (0, _createClass2["default"])(Clob, [{ - key: "writeTo", - value: function writeTo(writer) { - writer.setAnnotations(this.getAnnotations()); - writer.writeClob(this); - } - }, { - key: "toJSON", - value: function toJSON() { - var encodedText = ""; - var _iterator = _createForOfIteratorHelper(this), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var _byte = _step.value; - if (_byte >= 32 && _byte <= 126) { - encodedText += String.fromCharCode(_byte); - continue; - } - var hex = _byte.toString(16); - if (hex.length == 1) { - encodedText += "\\u000" + hex; - } else { - encodedText += "\\u00" + hex; - } - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); +const Ion_1 = require("../Ion"); +const Lob_1 = require("./Lob"); +class Clob extends Lob_1.Lob(Ion_1.IonTypes.CLOB) { + constructor(bytes) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + super(bytes, annotations); + } + writeTo(writer) { + writer.setAnnotations(this.getAnnotations()); + writer.writeClob(this); + } + toJSON() { + let encodedText = ""; + for (const byte of this) { + if (byte >= 32 && byte <= 126) { + encodedText += String.fromCharCode(byte); + continue; + } + const hex = byte.toString(16); + if (hex.length == 1) { + encodedText += "\\u000" + hex; + } else { + encodedText += "\\u00" + hex; } - return encodedText; } - }]); - return Clob; -}(Lob_1.Lob(Ion_1.IonTypes.CLOB)); + return encodedText; + } +} exports.Clob = Clob; -},{"../Ion":5,"./Lob":42,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],36:[function(require,module,exports){ +},{"../Ion":5,"./Lob":42}],36:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, - get: function get() { + get: function () { return m[k]; } }); @@ -8361,117 +7129,90 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Decimal = void 0; -var ion = __importStar(require("../Ion")); -var Ion_1 = require("../Ion"); -var FromJsConstructor_1 = require("./FromJsConstructor"); -var Value_1 = require("./Value"); -var Float_1 = require("./Float"); -var _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withClasses(ion.Decimal).build(); -var Decimal = /*#__PURE__*/function (_Value_1$Value) { - (0, _inherits2["default"])(Decimal, _Value_1$Value); - var _super = _createSuper(Decimal); - function Decimal(value) { - var _this; - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, Decimal); +const ion = __importStar(require("../Ion")); +const Ion_1 = require("../Ion"); +const FromJsConstructor_1 = require("./FromJsConstructor"); +const Value_1 = require("./Value"); +const Float_1 = require("./Float"); +const _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withClasses(ion.Decimal).build(); +class Decimal extends Value_1.Value(Number, Ion_1.IonTypes.DECIMAL, _fromJsConstructor) { + constructor(value) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; if (typeof value === "string") { - var numberValue = Number(value); - _this = _super.call(this, numberValue); - _this._decimalValue = new ion.Decimal(value); - _this._numberValue = numberValue; + let numberValue = Number(value); + super(numberValue); + this._decimalValue = new ion.Decimal(value); + this._numberValue = numberValue; } else if (value instanceof ion.Decimal) { - _this = _super.call(this, value.numberValue()); - _this._decimalValue = value; - _this._numberValue = value.numberValue(); + super(value.numberValue()); + this._decimalValue = value; + this._numberValue = value.numberValue(); } else if (typeof value === "number") { - _this = _super.call(this, value); - _this._decimalValue = new ion.Decimal("" + value); - _this._numberValue = value; + super(value); + this._decimalValue = new ion.Decimal("" + value); + this._numberValue = value; } else { throw new Error("Decimal value can only be created from number, ion.Decimal or string"); } - _this._setAnnotations(annotations); - return (0, _possibleConstructorReturn2["default"])(_this); + this._setAnnotations(annotations); } - (0, _createClass2["default"])(Decimal, [{ - key: "numberValue", - value: function numberValue() { - return this._numberValue; - } - }, { - key: "decimalValue", - value: function decimalValue() { - return this._decimalValue; - } - }, { - key: "toString", - value: function toString() { - return this._decimalValue.toString(); - } - }, { - key: "valueOf", - value: function valueOf() { - return this._numberValue; - } - }, { - key: "writeTo", - value: function writeTo(writer) { - writer.setAnnotations(this.getAnnotations()); - writer.writeDecimal(this.decimalValue()); - } - }, { - key: "_valueEquals", - value: function _valueEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null, - ignoreAnnotations: false, - ignoreTimestampPrecision: false, - onlyCompareIon: true, - coerceNumericType: false - }; - var isSupportedType = false; - var valueToCompare = null; - if (other instanceof Decimal) { + numberValue() { + return this._numberValue; + } + decimalValue() { + return this._decimalValue; + } + toString() { + return this._decimalValue.toString(); + } + valueOf() { + return this._numberValue; + } + writeTo(writer) { + writer.setAnnotations(this.getAnnotations()); + writer.writeDecimal(this.decimalValue()); + } + _valueEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null, + ignoreAnnotations: false, + ignoreTimestampPrecision: false, + onlyCompareIon: true, + coerceNumericType: false + }; + let isSupportedType = false; + let valueToCompare = null; + if (other instanceof Decimal) { + isSupportedType = true; + valueToCompare = other.decimalValue(); + } else if (options.coerceNumericType === true && other instanceof Float_1.Float) { + isSupportedType = true; + valueToCompare = new ion.Decimal(other.toString()); + } else if (!options.onlyCompareIon) { + if (other instanceof ion.Decimal) { isSupportedType = true; - valueToCompare = other.decimalValue(); - } else if (options.coerceNumericType === true && other instanceof Float_1.Float) { + valueToCompare = other; + } else if (other instanceof Number || typeof other === "number") { isSupportedType = true; valueToCompare = new ion.Decimal(other.toString()); - } else if (!options.onlyCompareIon) { - if (other instanceof ion.Decimal) { - isSupportedType = true; - valueToCompare = other; - } else if (other instanceof Number || typeof other === "number") { - isSupportedType = true; - valueToCompare = new ion.Decimal(other.toString()); - } - } - if (!isSupportedType) { - return false; } - return this.decimalValue().equals(valueToCompare); } - }]); - return Decimal; -}(Value_1.Value(Number, Ion_1.IonTypes.DECIMAL, _fromJsConstructor)); + if (!isSupportedType) { + return false; + } + return this.decimalValue().equals(valueToCompare); + } +} exports.Decimal = Decimal; -},{"../Ion":5,"./Float":37,"./FromJsConstructor":38,"./Value":50,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],37:[function(require,module,exports){ +},{"../Ion":5,"./Float":37,"./FromJsConstructor":38,"./Value":50}],37:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, - get: function get() { + get: function () { return m[k]; } }); @@ -8498,168 +7239,135 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Float = void 0; -var Ion_1 = require("../Ion"); -var FromJsConstructor_1 = require("./FromJsConstructor"); -var Value_1 = require("./Value"); -var Decimal_1 = require("./Decimal"); -var ion = __importStar(require("../Ion")); -var _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withPrimitives(FromJsConstructor_1.Primitives.Number).withClassesToUnbox(Number).build(); -var Float = /*#__PURE__*/function (_Value_1$Value) { - (0, _inherits2["default"])(Float, _Value_1$Value); - var _super = _createSuper(Float); - function Float(value) { - var _this; - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, Float); - _this = _super.call(this, value); - _this._setAnnotations(annotations); - return _this; - } - (0, _createClass2["default"])(Float, [{ - key: "numberValue", - value: function numberValue() { - return +this.valueOf(); - } - }, { - key: "writeTo", - value: function writeTo(writer) { - writer.setAnnotations(this.getAnnotations()); - writer.writeFloat64(this.numberValue()); - } - }, { - key: "_valueEquals", - value: function _valueEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null, - ignoreAnnotations: false, - ignoreTimestampPrecision: false, - onlyCompareIon: true, - coerceNumericType: false - }; - var isSupportedType = false; - var valueToCompare = null; - if (other instanceof Float) { +const Ion_1 = require("../Ion"); +const FromJsConstructor_1 = require("./FromJsConstructor"); +const Value_1 = require("./Value"); +const Decimal_1 = require("./Decimal"); +const ion = __importStar(require("../Ion")); +const _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withPrimitives(FromJsConstructor_1.Primitives.Number).withClassesToUnbox(Number).build(); +class Float extends Value_1.Value(Number, Ion_1.IonTypes.FLOAT, _fromJsConstructor) { + constructor(value) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + super(value); + this._setAnnotations(annotations); + } + numberValue() { + return +this.valueOf(); + } + writeTo(writer) { + writer.setAnnotations(this.getAnnotations()); + writer.writeFloat64(this.numberValue()); + } + _valueEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null, + ignoreAnnotations: false, + ignoreTimestampPrecision: false, + onlyCompareIon: true, + coerceNumericType: false + }; + let isSupportedType = false; + let valueToCompare = null; + if (other instanceof Float) { + isSupportedType = true; + valueToCompare = other.numberValue(); + } else if (options.coerceNumericType === true && other instanceof Decimal_1.Decimal) { + let thisValue = new ion.Decimal(other.toString()); + return thisValue.equals(other.decimalValue()); + } else if (!options.onlyCompareIon) { + if (other instanceof Number || typeof other === "number") { isSupportedType = true; - valueToCompare = other.numberValue(); - } else if (options.coerceNumericType === true && other instanceof Decimal_1.Decimal) { - var thisValue = new ion.Decimal(other.toString()); - return thisValue.equals(other.decimalValue()); - } else if (!options.onlyCompareIon) { - if (other instanceof Number || typeof other === "number") { - isSupportedType = true; - valueToCompare = other.valueOf(); - } - } - if (!isSupportedType) { - return false; + valueToCompare = other.valueOf(); } - var result = Object.is(this.numberValue(), valueToCompare); - if (options.epsilon != null) { - if (result || Math.abs(this.numberValue() - valueToCompare) <= options.epsilon) { - return true; - } + } + if (!isSupportedType) { + return false; + } + let result = Object.is(this.numberValue(), valueToCompare); + if (options.epsilon != null) { + if (result || Math.abs(this.numberValue() - valueToCompare) <= options.epsilon) { + return true; } - return result; } - }]); - return Float; -}(Value_1.Value(Number, Ion_1.IonTypes.FLOAT, _fromJsConstructor)); + return result; + } +} exports.Float = Float; -},{"../Ion":5,"./Decimal":36,"./FromJsConstructor":38,"./Value":50,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],38:[function(require,module,exports){ +},{"../Ion":5,"./Decimal":36,"./FromJsConstructor":38,"./Value":50}],38:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); Object.defineProperty(exports, "__esModule", { value: true }); exports.Primitives = exports.FromJsConstructor = exports.FromJsConstructorBuilder = void 0; -var Ion_1 = require("../Ion"); -var util_1 = require("../util"); +const Ion_1 = require("../Ion"); +const util_1 = require("../util"); function _newSet(values) { if (util_1._hasValue(values)) { return new Set(values); } return new Set(); } -var FromJsConstructorBuilder = /*#__PURE__*/function () { - function FromJsConstructorBuilder() { - (0, _classCallCheck2["default"])(this, FromJsConstructorBuilder); +class FromJsConstructorBuilder { + constructor() { this._primitives = _newSet(); this._classesToUnbox = _newSet(); this._classes = _newSet(); } - (0, _createClass2["default"])(FromJsConstructorBuilder, [{ - key: "withPrimitives", - value: function withPrimitives() { - for (var _len = arguments.length, primitives = new Array(_len), _key = 0; _key < _len; _key++) { - primitives[_key] = arguments[_key]; - } - this._primitives = _newSet(primitives); - return this; - } - }, { - key: "withClasses", - value: function withClasses() { - for (var _len2 = arguments.length, classes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - classes[_key2] = arguments[_key2]; - } - this._classes = _newSet(classes); - return this; + withPrimitives() { + for (var _len = arguments.length, primitives = new Array(_len), _key = 0; _key < _len; _key++) { + primitives[_key] = arguments[_key]; } - }, { - key: "withClassesToUnbox", - value: function withClassesToUnbox() { - for (var _len3 = arguments.length, classes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - classes[_key3] = arguments[_key3]; - } - this._classesToUnbox = _newSet(classes); - return this; + this._primitives = _newSet(primitives); + return this; + } + withClasses() { + for (var _len2 = arguments.length, classes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + classes[_key2] = arguments[_key2]; } - }, { - key: "build", - value: function build() { - return new FromJsConstructor(this._primitives, this._classesToUnbox, this._classes); + this._classes = _newSet(classes); + return this; + } + withClassesToUnbox() { + for (var _len3 = arguments.length, classes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + classes[_key3] = arguments[_key3]; } - }]); - return FromJsConstructorBuilder; -}(); + this._classesToUnbox = _newSet(classes); + return this; + } + build() { + return new FromJsConstructor(this._primitives, this._classesToUnbox, this._classes); + } +} exports.FromJsConstructorBuilder = FromJsConstructorBuilder; -var FromJsConstructor = /*#__PURE__*/function () { - function FromJsConstructor(_primitives, _classesToUnbox, _classes) { - (0, _classCallCheck2["default"])(this, FromJsConstructor); +class FromJsConstructor { + constructor(_primitives, _classesToUnbox, _classes) { this._primitives = _primitives; this._classesToUnbox = _classesToUnbox; this._classes = _classes; } - (0, _createClass2["default"])(FromJsConstructor, [{ - key: "construct", - value: function construct(constructor, jsValue) { - var annotations = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; - if (jsValue === null) { - return new Ion_1.dom.Null(Ion_1.IonTypes.NULL, annotations); - } - var jsValueType = (0, _typeof2["default"])(jsValue); - if (jsValueType === "object") { - if (this._classesToUnbox.has(jsValue.constructor)) { - return new constructor(jsValue.valueOf(), annotations); - } - if (this._classes.has(jsValue.constructor)) { - return new constructor(jsValue, annotations); - } - throw new Error("Unable to construct a(n) ".concat(constructor.name, " from a ").concat(jsValue.constructor.name, ".")); + construct(constructor, jsValue) { + let annotations = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; + if (jsValue === null) { + return new Ion_1.dom.Null(Ion_1.IonTypes.NULL, annotations); + } + const jsValueType = typeof jsValue; + if (jsValueType === "object") { + if (this._classesToUnbox.has(jsValue.constructor)) { + return new constructor(jsValue.valueOf(), annotations); } - if (this._primitives.has(jsValueType)) { + if (this._classes.has(jsValue.constructor)) { return new constructor(jsValue, annotations); } - throw new Error("Unable to construct a(n) ".concat(constructor.name, " from a ").concat(jsValueType, ".")); + throw new Error(`Unable to construct a(n) ${constructor.name} from a ${jsValue.constructor.name}.`); + } + if (this._primitives.has(jsValueType)) { + return new constructor(jsValue, annotations); } - }]); - return FromJsConstructor; -}(); + throw new Error(`Unable to construct a(n) ${constructor.name} from a ${jsValueType}.`); + } +} exports.FromJsConstructor = FromJsConstructor; (function (FromJsConstructor) { FromJsConstructor.NONE = new FromJsConstructorBuilder().build(); @@ -8671,141 +7379,112 @@ exports.Primitives = { BigInt: "bigint" }; -},{"../Ion":5,"../util":55,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/typeof":82}],39:[function(require,module,exports){ +},{"../Ion":5,"../util":55}],39:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.Integer = void 0; -var Ion_1 = require("../Ion"); -var FromJsConstructor_1 = require("./FromJsConstructor"); -var Value_1 = require("./Value"); -var _bigintConstructor = BigInt; -var _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withPrimitives(FromJsConstructor_1.Primitives.Number, FromJsConstructor_1.Primitives.BigInt).withClassesToUnbox(Number).withClasses(_bigintConstructor).build(); -var Integer = /*#__PURE__*/function (_Value_1$Value) { - (0, _inherits2["default"])(Integer, _Value_1$Value); - var _super = _createSuper(Integer); - function Integer(value) { - var _this; - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, Integer); +const Ion_1 = require("../Ion"); +const FromJsConstructor_1 = require("./FromJsConstructor"); +const Value_1 = require("./Value"); +const _bigintConstructor = BigInt; +const _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withPrimitives(FromJsConstructor_1.Primitives.Number, FromJsConstructor_1.Primitives.BigInt).withClassesToUnbox(Number).withClasses(_bigintConstructor).build(); +class Integer extends Value_1.Value(Number, Ion_1.IonTypes.INT, _fromJsConstructor) { + constructor(value) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; if (typeof value === "number") { - _this = _super.call(this, value); - _this._numberValue = value; - _this._bigIntValue = null; + super(value); + this._numberValue = value; + this._bigIntValue = null; } else { - var numberValue = Number(value); - _this = _super.call(this, numberValue); - _this._bigIntValue = value; - _this._numberValue = numberValue; - } - _this._setAnnotations(annotations); - return (0, _possibleConstructorReturn2["default"])(_this); - } - (0, _createClass2["default"])(Integer, [{ - key: "bigIntValue", - value: function bigIntValue() { - if (this._bigIntValue === null) { - this._bigIntValue = BigInt(this.numberValue()); - } - return this._bigIntValue; - } - }, { - key: "numberValue", - value: function numberValue() { - return this._numberValue; - } - }, { - key: "toString", - value: function toString() { - if (this._bigIntValue === null) { - return this._numberValue.toString(); - } - return this._bigIntValue.toString(); - } - }, { - key: "valueOf", - value: function valueOf() { - return this.numberValue(); - } - }, { - key: "writeTo", - value: function writeTo(writer) { - writer.setAnnotations(this.getAnnotations()); - if (this._bigIntValue === null) { - writer.writeInt(this.numberValue()); + const numberValue = Number(value); + super(numberValue); + this._bigIntValue = value; + this._numberValue = numberValue; + } + this._setAnnotations(annotations); + } + bigIntValue() { + if (this._bigIntValue === null) { + this._bigIntValue = BigInt(this.numberValue()); + } + return this._bigIntValue; + } + numberValue() { + return this._numberValue; + } + toString() { + if (this._bigIntValue === null) { + return this._numberValue.toString(); + } + return this._bigIntValue.toString(); + } + valueOf() { + return this.numberValue(); + } + writeTo(writer) { + writer.setAnnotations(this.getAnnotations()); + if (this._bigIntValue === null) { + writer.writeInt(this.numberValue()); + } else { + writer.writeInt(this._bigIntValue); + } + } + _valueEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null, + ignoreAnnotations: false, + ignoreTimestampPrecision: false, + onlyCompareIon: true + }; + let isSupportedType = false; + let valueToCompare = null; + if (other instanceof Integer) { + isSupportedType = true; + if (this._bigIntValue == null && other._bigIntValue == null) { + valueToCompare = other.numberValue(); } else { - writer.writeInt(this._bigIntValue); + valueToCompare = other.bigIntValue(); } - } - }, { - key: "_valueEquals", - value: function _valueEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null, - ignoreAnnotations: false, - ignoreTimestampPrecision: false, - onlyCompareIon: true - }; - var isSupportedType = false; - var valueToCompare = null; - if (other instanceof Integer) { + } else if (!options.onlyCompareIon) { + if (other instanceof Number || typeof other === "number") { isSupportedType = true; - if (this._bigIntValue == null && other._bigIntValue == null) { - valueToCompare = other.numberValue(); + if (this.bigIntValue == null) { + valueToCompare = other.valueOf(); } else { - valueToCompare = other.bigIntValue(); - } - } else if (!options.onlyCompareIon) { - if (other instanceof Number || typeof other === "number") { - isSupportedType = true; - if (this.bigIntValue == null) { - valueToCompare = other.valueOf(); - } else { - valueToCompare = BigInt(other.valueOf()); - } - } else if (typeof other === "bigint") { - isSupportedType = true; - valueToCompare = other; + valueToCompare = BigInt(other.valueOf()); } + } else if (typeof other === "bigint") { + isSupportedType = true; + valueToCompare = other; } - if (!isSupportedType) { - return false; - } - if (typeof valueToCompare === "bigint") { - return this.bigIntValue() === valueToCompare; - } - return this.numberValue() == valueToCompare; } - }]); - return Integer; -}(Value_1.Value(Number, Ion_1.IonTypes.INT, _fromJsConstructor)); + if (!isSupportedType) { + return false; + } + if (typeof valueToCompare === "bigint") { + return this.bigIntValue() === valueToCompare; + } + return this.numberValue() == valueToCompare; + } +} exports.Integer = Integer; -},{"../Ion":5,"./FromJsConstructor":38,"./Value":50,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],40:[function(require,module,exports){ +},{"../Ion":5,"./FromJsConstructor":38,"./Value":50}],40:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); Object.defineProperty(exports, "__esModule", { value: true }); exports._ionValueFromJsValue = exports._domConstructorFor = exports._NativeJsString = exports._NativeJsBoolean = void 0; -var Ion_1 = require("../Ion"); -var IonTypes_1 = require("../IonTypes"); -var util_1 = require("../util"); +const Ion_1 = require("../Ion"); +const IonTypes_1 = require("../IonTypes"); +const util_1 = require("../util"); exports._NativeJsBoolean = Boolean; exports._NativeJsString = String; -var _domTypesByIonType = null; +let _domTypesByIonType = null; function _getDomTypesByIonTypeMap() { if (_domTypesByIonType === null) { _domTypesByIonType = new Map([[IonTypes_1.IonTypes.NULL, Ion_1.dom.Null], [IonTypes_1.IonTypes.BOOL, Ion_1.dom.Boolean], [IonTypes_1.IonTypes.INT, Ion_1.dom.Integer], [IonTypes_1.IonTypes.FLOAT, Ion_1.dom.Float], [IonTypes_1.IonTypes.DECIMAL, Ion_1.dom.Decimal], [IonTypes_1.IonTypes.TIMESTAMP, Ion_1.dom.Timestamp], [IonTypes_1.IonTypes.STRING, Ion_1.dom.String], [IonTypes_1.IonTypes.BLOB, Ion_1.dom.Blob], [IonTypes_1.IonTypes.LIST, Ion_1.dom.List], [IonTypes_1.IonTypes.STRUCT, Ion_1.dom.Struct]]); @@ -8813,9 +7492,9 @@ function _getDomTypesByIonTypeMap() { return _domTypesByIonType; } function _domConstructorFor(ionType) { - var domConstructor = _getDomTypesByIonTypeMap().get(ionType); + const domConstructor = _getDomTypesByIonTypeMap().get(ionType); if (!util_1._hasValue(domConstructor)) { - throw new Error("No dom type constructor was found for Ion type ".concat(ionType.name)); + throw new Error(`No dom type constructor was found for Ion type ${ionType.name}`); } return domConstructor; } @@ -8827,7 +7506,7 @@ function _inferType(value) { if (value === null) { return IonTypes_1.IonTypes.NULL; } - var valueType = (0, _typeof2["default"])(value); + const valueType = typeof value; switch (valueType) { case "string": return IonTypes_1.IonTypes.STRING; @@ -8840,7 +7519,7 @@ function _inferType(value) { case "bigint": return IonTypes_1.IonTypes.INT; default: - throw new Error("Value.from() does not support the JS primitive type ".concat(valueType, ".")); + throw new Error(`Value.from() does not support the JS primitive type ${valueType}.`); } if (value instanceof BigInt) { return IonTypes_1.IonTypes.INT; @@ -8869,978 +7548,661 @@ function _inferType(value) { return IonTypes_1.IonTypes.STRUCT; } function _ionValueFromJsValue(value) { - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - var ionType = _inferType(value); - var ionTypeConstructor = _domConstructorFor(ionType); + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + const ionType = _inferType(value); + const ionTypeConstructor = _domConstructorFor(ionType); return ionTypeConstructor._fromJsValue(value, annotations); } exports._ionValueFromJsValue = _ionValueFromJsValue; -},{"../Ion":5,"../IonTypes":29,"../util":55,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/typeof":82}],41:[function(require,module,exports){ +},{"../Ion":5,"../IonTypes":29,"../util":55}],41:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.List = void 0; -var Ion_1 = require("../Ion"); -var Sequence_1 = require("./Sequence"); -var List = /*#__PURE__*/function (_Sequence_1$Sequence) { - (0, _inherits2["default"])(List, _Sequence_1$Sequence); - var _super = _createSuper(List); - function List(children) { - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, List); - return _super.call(this, children, annotations); - } - return (0, _createClass2["default"])(List); -}(Sequence_1.Sequence(Ion_1.IonTypes.LIST)); +const Ion_1 = require("../Ion"); +const Sequence_1 = require("./Sequence"); +class List extends Sequence_1.Sequence(Ion_1.IonTypes.LIST) { + constructor(children) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + super(children, annotations); + } +} exports.List = List; -},{"../Ion":5,"./Sequence":45,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],42:[function(require,module,exports){ +},{"../Ion":5,"./Sequence":45}],42:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.Lob = void 0; -var Ion_1 = require("../Ion"); -var FromJsConstructor_1 = require("./FromJsConstructor"); -var Value_1 = require("./Value"); -var _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withClasses(Uint8Array).build(); +const Ion_1 = require("../Ion"); +const FromJsConstructor_1 = require("./FromJsConstructor"); +const Value_1 = require("./Value"); +const _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withClasses(Uint8Array).build(); function Lob(ionType) { - return /*#__PURE__*/function (_Value_1$Value) { - (0, _inherits2["default"])(_class, _Value_1$Value); - var _super = _createSuper(_class); - function _class(data) { - var _this; - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, _class); - _this = _super.call(this, data); - _this._setAnnotations(annotations); - return _this; - } - (0, _createClass2["default"])(_class, [{ - key: "uInt8ArrayValue", - value: function uInt8ArrayValue() { - return this; - } - }, { - key: "_valueEquals", - value: function _valueEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null, - ignoreAnnotations: false, - ignoreTimestampPrecision: false, - onlyCompareIon: true - }; - var isSupportedType = false; - var valueToCompare = null; - if (options.onlyCompareIon) { - if (other.getType() === Ion_1.IonTypes.CLOB || other.getType() === Ion_1.IonTypes.BLOB) { - isSupportedType = true; - valueToCompare = other.uInt8ArrayValue(); - } - } else { - if (other instanceof Uint8Array) { - isSupportedType = true; - valueToCompare = other.valueOf(); - } + return class extends Value_1.Value(Uint8Array, ionType, _fromJsConstructor) { + constructor(data) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + super(data); + this._setAnnotations(annotations); + } + uInt8ArrayValue() { + return this; + } + _valueEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null, + ignoreAnnotations: false, + ignoreTimestampPrecision: false, + onlyCompareIon: true + }; + let isSupportedType = false; + let valueToCompare = null; + if (options.onlyCompareIon) { + if (other.getType() === Ion_1.IonTypes.CLOB || other.getType() === Ion_1.IonTypes.BLOB) { + isSupportedType = true; + valueToCompare = other.uInt8ArrayValue(); } - if (!isSupportedType) { - return false; + } else { + if (other instanceof Uint8Array) { + isSupportedType = true; + valueToCompare = other.valueOf(); } - var current = this.uInt8ArrayValue(); - var expected = valueToCompare; - if (current.length !== expected.length) { + } + if (!isSupportedType) { + return false; + } + let current = this.uInt8ArrayValue(); + let expected = valueToCompare; + if (current.length !== expected.length) { + return false; + } + for (let i = 0; i < current.length; i++) { + if (current[i] !== expected[i]) { return false; } - for (var i = 0; i < current.length; i++) { - if (current[i] !== expected[i]) { - return false; - } - } - return true; } - }]); - return _class; - }(Value_1.Value(Uint8Array, ionType, _fromJsConstructor)); + return true; + } + }; } exports.Lob = Lob; -},{"../Ion":5,"./FromJsConstructor":38,"./Value":50,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],43:[function(require,module,exports){ +},{"../Ion":5,"./FromJsConstructor":38,"./Value":50}],43:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.Null = void 0; -var Ion_1 = require("../Ion"); -var FromJsConstructor_1 = require("./FromJsConstructor"); -var Value_1 = require("./Value"); -var Null = /*#__PURE__*/function (_Value_1$Value) { - (0, _inherits2["default"])(Null, _Value_1$Value); - var _super = _createSuper(Null); - function Null() { - var _this; - var ionType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Ion_1.IonTypes.NULL; - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, Null); - _this = _super.call(this); - _this._ionType = ionType; - _this._setAnnotations(annotations); - return _this; - } - (0, _createClass2["default"])(Null, [{ - key: "isNull", - value: function isNull() { - return true; - } - }, { - key: "_convertToJsNull", - value: function _convertToJsNull(operation) { - if (Null._operationIsSupported(this.getType(), operation)) { - return null; - } - throw new Error("".concat(operation, "() is not supported by Ion type ").concat(this.getType().name)); - } - }, { - key: "_unsupportedOperationOrNullDereference", - value: function _unsupportedOperationOrNullDereference(operation) { - if (Null._operationIsSupported(this.getType(), operation)) { - throw new Error("".concat(operation, "() called on a null ").concat(this.getType().name, ".")); - } - throw new Error("".concat(operation, "() is not supported by Ion type ").concat(this.getType().name)); - } - }, { - key: "booleanValue", - value: function booleanValue() { - return this._convertToJsNull("booleanValue"); - } - }, { - key: "numberValue", - value: function numberValue() { - return this._convertToJsNull("numberValue"); - } - }, { - key: "bigIntValue", - value: function bigIntValue() { - return this._convertToJsNull("bigIntValue"); - } - }, { - key: "decimalValue", - value: function decimalValue() { - return this._convertToJsNull("decimalValue"); - } - }, { - key: "stringValue", - value: function stringValue() { - return this._convertToJsNull("stringValue"); - } - }, { - key: "dateValue", - value: function dateValue() { - return this._convertToJsNull("dateValue"); - } - }, { - key: "uInt8ArrayValue", - value: function uInt8ArrayValue() { - return this._convertToJsNull("uInt8ArrayValue"); - } - }, { - key: "fieldNames", - value: function fieldNames() { - this._unsupportedOperationOrNullDereference("fieldNames"); - } - }, { - key: "fields", - value: function fields() { - this._unsupportedOperationOrNullDereference("fields"); - } - }, { - key: "elements", - value: function elements() { - this._unsupportedOperationOrNullDereference("elements"); - } - }, { - key: "get", - value: function get() { +const Ion_1 = require("../Ion"); +const FromJsConstructor_1 = require("./FromJsConstructor"); +const Value_1 = require("./Value"); +class Null extends Value_1.Value(Object, Ion_1.IonTypes.NULL, FromJsConstructor_1.FromJsConstructor.NONE) { + constructor() { + let ionType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Ion_1.IonTypes.NULL; + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + super(); + this._ionType = ionType; + this._setAnnotations(annotations); + } + static _operationIsSupported(ionType, operation) { + return Null._supportedIonTypesByOperation.get(operation).has(ionType); + } + isNull() { + return true; + } + _convertToJsNull(operation) { + if (Null._operationIsSupported(this.getType(), operation)) { return null; } - }, { - key: "toString", - value: function toString() { - if (this.getType() == Ion_1.IonTypes.NULL) { - return "null"; - } - return "null." + this._ionType.name; - } - }, { - key: "toJSON", - value: function toJSON() { - return null; + throw new Error(`${operation}() is not supported by Ion type ${this.getType().name}`); + } + _unsupportedOperationOrNullDereference(operation) { + if (Null._operationIsSupported(this.getType(), operation)) { + throw new Error(`${operation}() called on a null ${this.getType().name}.`); } - }, { - key: "writeTo", - value: function writeTo(writer) { - writer.setAnnotations(this.getAnnotations()); - writer.writeNull(this.getType()); + throw new Error(`${operation}() is not supported by Ion type ${this.getType().name}`); + } + booleanValue() { + return this._convertToJsNull("booleanValue"); + } + numberValue() { + return this._convertToJsNull("numberValue"); + } + bigIntValue() { + return this._convertToJsNull("bigIntValue"); + } + decimalValue() { + return this._convertToJsNull("decimalValue"); + } + stringValue() { + return this._convertToJsNull("stringValue"); + } + dateValue() { + return this._convertToJsNull("dateValue"); + } + uInt8ArrayValue() { + return this._convertToJsNull("uInt8ArrayValue"); + } + fieldNames() { + this._unsupportedOperationOrNullDereference("fieldNames"); + } + fields() { + this._unsupportedOperationOrNullDereference("fields"); + } + elements() { + this._unsupportedOperationOrNullDereference("elements"); + } + get() { + return null; + } + toString() { + if (this.getType() == Ion_1.IonTypes.NULL) { + return "null"; } - }, { - key: "_valueEquals", - value: function _valueEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null, - ignoreAnnotations: false, - ignoreTimestampPrecision: false, - onlyCompareIon: true - }; - var isSupportedType = false; - var valueToCompare = null; - if (other instanceof Null) { - isSupportedType = true; - valueToCompare = other; - } else if (!options.onlyCompareIon) { - if (other === null && this._ionType.name === "null") { - return true; - } - } - if (!isSupportedType) { - return false; + return "null." + this._ionType.name; + } + toJSON() { + return null; + } + writeTo(writer) { + writer.setAnnotations(this.getAnnotations()); + writer.writeNull(this.getType()); + } + _valueEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null, + ignoreAnnotations: false, + ignoreTimestampPrecision: false, + onlyCompareIon: true + }; + let isSupportedType = false; + let valueToCompare = null; + if (other instanceof Null) { + isSupportedType = true; + valueToCompare = other; + } else if (!options.onlyCompareIon) { + if (other === null && this._ionType.name === "null") { + return true; } - return this._ionType.name === valueToCompare._ionType.name; } - }], [{ - key: "_operationIsSupported", - value: function _operationIsSupported(ionType, operation) { - return Null._supportedIonTypesByOperation.get(operation).has(ionType); + if (!isSupportedType) { + return false; } - }]); - return Null; -}(Value_1.Value(Object, Ion_1.IonTypes.NULL, FromJsConstructor_1.FromJsConstructor.NONE)); + return this._ionType.name === valueToCompare._ionType.name; + } +} exports.Null = Null; Null._supportedIonTypesByOperation = new Map([["booleanValue", new Set([Ion_1.IonTypes.BOOL])], ["numberValue", new Set([Ion_1.IonTypes.INT, Ion_1.IonTypes.FLOAT, Ion_1.IonTypes.DECIMAL])], ["bigIntValue", new Set([Ion_1.IonTypes.INT])], ["decimalValue", new Set([Ion_1.IonTypes.DECIMAL])], ["stringValue", new Set([Ion_1.IonTypes.STRING, Ion_1.IonTypes.SYMBOL])], ["dateValue", new Set([Ion_1.IonTypes.TIMESTAMP])], ["timestampValue", new Set([Ion_1.IonTypes.TIMESTAMP])], ["uInt8ArrayValue", new Set([Ion_1.IonTypes.BLOB, Ion_1.IonTypes.CLOB])], ["fields", new Set([Ion_1.IonTypes.STRUCT])], ["fieldNames", new Set([Ion_1.IonTypes.STRUCT])], ["elements", new Set([Ion_1.IonTypes.LIST, Ion_1.IonTypes.SEXP, Ion_1.IonTypes.STRUCT])]]); -},{"../Ion":5,"./FromJsConstructor":38,"./Value":50,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],44:[function(require,module,exports){ +},{"../Ion":5,"./FromJsConstructor":38,"./Value":50}],44:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.SExpression = void 0; -var Ion_1 = require("../Ion"); -var Sequence_1 = require("./Sequence"); -var SExpression = /*#__PURE__*/function (_Sequence_1$Sequence) { - (0, _inherits2["default"])(SExpression, _Sequence_1$Sequence); - var _super = _createSuper(SExpression); - function SExpression(children) { - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, SExpression); - return _super.call(this, children, annotations); - } - (0, _createClass2["default"])(SExpression, [{ - key: "toString", - value: function toString() { - return "(" + this.join(" ") + ")"; - } - }]); - return SExpression; -}(Sequence_1.Sequence(Ion_1.IonTypes.SEXP)); +const Ion_1 = require("../Ion"); +const Sequence_1 = require("./Sequence"); +class SExpression extends Sequence_1.Sequence(Ion_1.IonTypes.SEXP) { + constructor(children) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + super(children, annotations); + } + toString() { + return "(" + this.join(" ") + ")"; + } +} exports.SExpression = SExpression; -},{"../Ion":5,"./Sequence":45,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],45:[function(require,module,exports){ +},{"../Ion":5,"./Sequence":45}],45:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); -var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.Sequence = void 0; -var Ion_1 = require("../Ion"); -var FromJsConstructor_1 = require("./FromJsConstructor"); -var Value_1 = require("./Value"); +const Ion_1 = require("../Ion"); +const FromJsConstructor_1 = require("./FromJsConstructor"); +const Value_1 = require("./Value"); function Sequence(ionType) { - return /*#__PURE__*/function (_Value_1$Value) { - (0, _inherits2["default"])(_class, _Value_1$Value); - var _super = _createSuper(_class); - function _class(children) { - var _this; - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, _class); - _this = _super.call(this); - var _iterator = _createForOfIteratorHelper(children), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var child = _step.value; - _this.push(child); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - _this._setAnnotations(annotations); - return (0, _possibleConstructorReturn2["default"])(_this, new Proxy((0, _assertThisInitialized2["default"])(_this), { - set: function set(target, index, value) { + return class extends Value_1.Value(Array, ionType, FromJsConstructor_1.FromJsConstructor.NONE) { + constructor(children) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + super(); + for (const child of children) { + this.push(child); + } + this._setAnnotations(annotations); + return new Proxy(this, { + set: function (target, index, value) { if (!(value instanceof Value_1.Value)) { value = Value_1.Value.from(value); } target[index] = value; return true; } - })); - } - (0, _createClass2["default"])(_class, [{ - key: "get", - value: function get() { - for (var _len = arguments.length, pathElements = new Array(_len), _key = 0; _key < _len; _key++) { - pathElements[_key] = arguments[_key]; - } - if (pathElements.length === 0) { - throw new Error("Value#get requires at least one parameter."); - } - var pathHead = pathElements[0], - pathTail = pathElements.slice(1); - if (typeof pathHead !== "number") { - throw new Error("Cannot index into a ".concat(this.getType().name, " with a ").concat((0, _typeof2["default"])(pathHead), ".")); - } - var children = this; - var maybeChild = children[pathHead]; - var child = maybeChild === undefined ? null : maybeChild; - if (pathTail.length === 0 || child === null) { - return child; - } - return child.get.apply(child, (0, _toConsumableArray2["default"])(pathTail)); - } - }, { - key: "elements", - value: function elements() { - return Object.values(this); - } - }, { - key: "toString", - value: function toString() { - return "[" + this.join(", ") + "]"; - } - }, { - key: "writeTo", - value: function writeTo(writer) { - writer.setAnnotations(this.getAnnotations()); - writer.stepIn(ionType); - var _iterator2 = _createForOfIteratorHelper(this), - _step2; - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var child = _step2.value; - child.writeTo(writer); - } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } - writer.stepOut(); - } - }, { - key: "_valueEquals", - value: function _valueEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null, - ignoreAnnotations: false, - ignoreTimestampPrecision: false, - onlyCompareIon: true - }; - var isSupportedType = false; - var valueToCompare = null; - if (options.onlyCompareIon) { - if (other.getType() === Ion_1.IonTypes.LIST || other.getType() === Ion_1.IonTypes.SEXP) { - isSupportedType = true; - valueToCompare = other.elements(); - } - } else { - if (other instanceof Array) { - isSupportedType = true; - valueToCompare = other; - } - } - if (!isSupportedType) { - return false; - } - var actualSequence = this.elements(); - var expectedSequence = valueToCompare; - if (actualSequence.length !== expectedSequence.length) { - return false; - } - for (var i = 0; i < actualSequence.length; i++) { - if (options.onlyCompareIon) { - if (!actualSequence[i].ionEquals(expectedSequence[i], options)) { - return false; - } - } else { - if (!actualSequence[i].equals(expectedSequence[i])) { - return false; - } - } - } - return true; + }); + } + get() { + for (var _len = arguments.length, pathElements = new Array(_len), _key = 0; _key < _len; _key++) { + pathElements[_key] = arguments[_key]; } - }], [{ - key: "_fromJsValue", - value: function _fromJsValue(jsValue, annotations) { - if (!(jsValue instanceof Array)) { - throw new Error("Cannot create a ".concat(this.name, " from: ").concat(jsValue.toString())); - } - var children = jsValue.map(function (child) { - return Value_1.Value.from(child); - }); - return new this(children, annotations); + if (pathElements.length === 0) { + throw new Error("Value#get requires at least one parameter."); } - }]); - return _class; - }(Value_1.Value(Array, ionType, FromJsConstructor_1.FromJsConstructor.NONE)); -} -exports.Sequence = Sequence; - -},{"../Ion":5,"./FromJsConstructor":38,"./Value":50,"@babel/runtime/helpers/assertThisInitialized":59,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75,"@babel/runtime/helpers/toConsumableArray":79,"@babel/runtime/helpers/typeof":82}],46:[function(require,module,exports){ -"use strict"; - -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.String = void 0; -var Ion_1 = require("../Ion"); -var FromJsConstructor_1 = require("./FromJsConstructor"); -var JsValueConversion_1 = require("./JsValueConversion"); -var Value_1 = require("./Value"); -var _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withPrimitives(FromJsConstructor_1.Primitives.String).withClassesToUnbox(JsValueConversion_1._NativeJsString).build(); -var String = /*#__PURE__*/function (_Value_1$Value) { - (0, _inherits2["default"])(String, _Value_1$Value); - var _super = _createSuper(String); - function String(text) { - var _this; - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, String); - _this = _super.call(this, text); - _this._setAnnotations(annotations); - return _this; - } - (0, _createClass2["default"])(String, [{ - key: "stringValue", - value: function stringValue() { - return this.toString(); - } - }, { - key: "writeTo", - value: function writeTo(writer) { + const [pathHead, ...pathTail] = pathElements; + if (typeof pathHead !== "number") { + throw new Error(`Cannot index into a ${this.getType().name} with a ${typeof pathHead}.`); + } + const children = this; + const maybeChild = children[pathHead]; + const child = maybeChild === undefined ? null : maybeChild; + if (pathTail.length === 0 || child === null) { + return child; + } + return child.get(...pathTail); + } + elements() { + return Object.values(this); + } + toString() { + return "[" + this.join(", ") + "]"; + } + static _fromJsValue(jsValue, annotations) { + if (!(jsValue instanceof Array)) { + throw new Error(`Cannot create a ${this.name} from: ${jsValue.toString()}`); + } + const children = jsValue.map(child => Value_1.Value.from(child)); + return new this(children, annotations); + } + writeTo(writer) { writer.setAnnotations(this.getAnnotations()); - writer.writeString(this.stringValue()); + writer.stepIn(ionType); + for (const child of this) { + child.writeTo(writer); + } + writer.stepOut(); } - }, { - key: "_valueEquals", - value: function _valueEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + _valueEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { epsilon: null, ignoreAnnotations: false, ignoreTimestampPrecision: false, onlyCompareIon: true }; - var isSupportedType = false; - var valueToCompare = null; - if (other instanceof String) { - isSupportedType = true; - valueToCompare = other.stringValue(); - } else if (!options.onlyCompareIon) { - if (typeof other === "string" || other instanceof JsValueConversion_1._NativeJsString) { + let isSupportedType = false; + let valueToCompare = null; + if (options.onlyCompareIon) { + if (other.getType() === Ion_1.IonTypes.LIST || other.getType() === Ion_1.IonTypes.SEXP) { isSupportedType = true; - valueToCompare = other.valueOf(); + valueToCompare = other.elements(); + } + } else { + if (other instanceof Array) { + isSupportedType = true; + valueToCompare = other; } } if (!isSupportedType) { return false; } - return this.compareValue(valueToCompare) === 0; + let actualSequence = this.elements(); + let expectedSequence = valueToCompare; + if (actualSequence.length !== expectedSequence.length) { + return false; + } + for (let i = 0; i < actualSequence.length; i++) { + if (options.onlyCompareIon) { + if (!actualSequence[i].ionEquals(expectedSequence[i], options)) { + return false; + } + } else { + if (!actualSequence[i].equals(expectedSequence[i])) { + return false; + } + } + } + return true; + } + }; +} +exports.Sequence = Sequence; + +},{"../Ion":5,"./FromJsConstructor":38,"./Value":50}],46:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.String = void 0; +const Ion_1 = require("../Ion"); +const FromJsConstructor_1 = require("./FromJsConstructor"); +const JsValueConversion_1 = require("./JsValueConversion"); +const Value_1 = require("./Value"); +const _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withPrimitives(FromJsConstructor_1.Primitives.String).withClassesToUnbox(JsValueConversion_1._NativeJsString).build(); +class String extends Value_1.Value(JsValueConversion_1._NativeJsString, Ion_1.IonTypes.STRING, _fromJsConstructor) { + constructor(text) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + super(text); + this._setAnnotations(annotations); + } + stringValue() { + return this.toString(); + } + writeTo(writer) { + writer.setAnnotations(this.getAnnotations()); + writer.writeString(this.stringValue()); + } + _valueEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null, + ignoreAnnotations: false, + ignoreTimestampPrecision: false, + onlyCompareIon: true + }; + let isSupportedType = false; + let valueToCompare = null; + if (other instanceof String) { + isSupportedType = true; + valueToCompare = other.stringValue(); + } else if (!options.onlyCompareIon) { + if (typeof other === "string" || other instanceof JsValueConversion_1._NativeJsString) { + isSupportedType = true; + valueToCompare = other.valueOf(); + } } - }, { - key: "compareValue", - value: function compareValue(expectedValue) { - return this.stringValue().localeCompare(expectedValue); + if (!isSupportedType) { + return false; } - }]); - return String; -}(Value_1.Value(JsValueConversion_1._NativeJsString, Ion_1.IonTypes.STRING, _fromJsConstructor)); + return this.compareValue(valueToCompare) === 0; + } + compareValue(expectedValue) { + return this.stringValue().localeCompare(expectedValue); + } +} exports.String = String; -},{"../Ion":5,"./FromJsConstructor":38,"./JsValueConversion":40,"./Value":50,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],47:[function(require,module,exports){ +},{"../Ion":5,"./FromJsConstructor":38,"./JsValueConversion":40,"./Value":50}],47:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); -var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); -var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.Struct = void 0; -var Ion_1 = require("../Ion"); -var FromJsConstructor_1 = require("./FromJsConstructor"); -var Value_1 = require("./Value"); -var Struct = /*#__PURE__*/function (_Value_1$Value, _Symbol$iterator) { - (0, _inherits2["default"])(Struct, _Value_1$Value); - var _super = _createSuper(Struct); - function Struct(fields) { - var _this; - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, Struct); - _this = _super.call(this); - _this._fields = Object.create(null); - var _iterator = _createForOfIteratorHelper(fields), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var _step$value = (0, _slicedToArray2["default"])(_step.value, 2), - fieldName = _step$value[0], - fieldValue = _step$value[1]; - _this._fields[fieldName] = fieldValue instanceof Value_1.Value ? [fieldValue] : fieldValue; - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - _this._setAnnotations(annotations); - return (0, _possibleConstructorReturn2["default"])(_this, new Proxy((0, _assertThisInitialized2["default"])(_this), { - set: function set(target, name, value) { +const Ion_1 = require("../Ion"); +const FromJsConstructor_1 = require("./FromJsConstructor"); +const Value_1 = require("./Value"); +class Struct extends Value_1.Value(Object, Ion_1.IonTypes.STRUCT, FromJsConstructor_1.FromJsConstructor.NONE) { + constructor(fields) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + super(); + this._fields = Object.create(null); + for (const [fieldName, fieldValue] of fields) { + this._fields[fieldName] = fieldValue instanceof Value_1.Value ? [fieldValue] : fieldValue; + } + this._setAnnotations(annotations); + return new Proxy(this, { + set: function (target, name, value) { if (!(value instanceof Value_1.Value)) { value = Value_1.Value.from(value); } target._fields[name] = [value]; return true; }, - get: function get(target, name) { + get: function (target, name) { if (name in target) { return target[name]; } - var length = target._fields[name] !== undefined ? target._fields[name].length : -1; + let length = target._fields[name] !== undefined ? target._fields[name].length : -1; if (length === -1) { return target._fields[name]; } return target._fields[name][length - 1]; }, - deleteProperty: function deleteProperty(target, name) { + deleteProperty: function (target, name) { if (name in target._fields) { delete target._fields[name]; } return true; } - })); + }); } - (0, _createClass2["default"])(Struct, [{ - key: "get", - value: function get() { - var _child; - for (var _len = arguments.length, pathElements = new Array(_len), _key = 0; _key < _len; _key++) { - pathElements[_key] = arguments[_key]; - } - if (pathElements.length === 0) { - throw new Error("Value#get requires at least one parameter."); - } - var pathHead = pathElements[0], - pathTail = pathElements.slice(1); - if (typeof pathHead !== "string") { - throw new Error("Cannot index into a struct with a ".concat((0, _typeof2["default"])(pathHead), ".")); - } - var child = this._fields[pathHead]; - if (child === undefined) { - return null; - } - if (pathTail.length === 0) { - return child[child.length - 1]; - } - return (_child = child[child.length - 1]).get.apply(_child, (0, _toConsumableArray2["default"])(pathTail)); + get() { + for (var _len = arguments.length, pathElements = new Array(_len), _key = 0; _key < _len; _key++) { + pathElements[_key] = arguments[_key]; } - }, { - key: "getAll", - value: function getAll() { - for (var _len2 = arguments.length, pathElements = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - pathElements[_key2] = arguments[_key2]; - } - if (pathElements.length === 0) { - throw new Error("Value#get requires at least one parameter."); - } - var pathHead = pathElements[0], - pathTail = pathElements.slice(1); - if (typeof pathHead !== "string") { - throw new Error("Cannot index into a struct with a ".concat((0, _typeof2["default"])(pathHead), ".")); - } - var child = this._fields[pathHead]; - if (child === undefined) { - return null; - } - if (pathTail.length === 0) { - return child; - } - var values = []; - child.forEach(function (value) { - return values.push.apply(values, (0, _toConsumableArray2["default"])(value.getAll.apply(value, (0, _toConsumableArray2["default"])(pathTail)))); - }); - return values; - } - }, { - key: "fieldNames", - value: function fieldNames() { - return Object.keys(this._fields); - } - }, { - key: "allFields", - value: function allFields() { - return Object.entries(this._fields); - } - }, { - key: "fields", - value: function fields() { - var singleValueFields = Object.create(null); - var _iterator2 = _createForOfIteratorHelper(this.allFields()), - _step2; - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var _step2$value = (0, _slicedToArray2["default"])(_step2.value, 2), - fieldName = _step2$value[0], - values = _step2$value[1]; - singleValueFields[fieldName] = values[values.length - 1]; - } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } - return Object.entries(singleValueFields); - } - }, { - key: "elements", - value: function elements() { - return Object.values(this._fields).flat(); - } - }, { - key: _Symbol$iterator, - value: function value() { - return this.fields()[Symbol.iterator](); - } - }, { - key: "toString", - value: function toString() { - return "{" + (0, _toConsumableArray2["default"])(this.allFields()).map(function (_ref) { - var _ref2 = (0, _slicedToArray2["default"])(_ref, 2), - name = _ref2[0], - value = _ref2[1]; - return name + ": " + value; - }).join(", ") + "}"; - } - }, { - key: "writeTo", - value: function writeTo(writer) { - writer.setAnnotations(this.getAnnotations()); - writer.stepIn(Ion_1.IonTypes.STRUCT); - var _iterator3 = _createForOfIteratorHelper(this.allFields()), - _step3; - try { - for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { - var _step3$value = (0, _slicedToArray2["default"])(_step3.value, 2), - fieldName = _step3$value[0], - values = _step3$value[1]; - var _iterator4 = _createForOfIteratorHelper(values), - _step4; - try { - for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { - var value = _step4.value; - writer.writeFieldName(fieldName); - value.writeTo(writer); - } - } catch (err) { - _iterator4.e(err); - } finally { - _iterator4.f(); - } - } - } catch (err) { - _iterator3.e(err); - } finally { - _iterator3.f(); - } - writer.stepOut(); + if (pathElements.length === 0) { + throw new Error("Value#get requires at least one parameter."); } - }, { - key: "deleteField", - value: function deleteField(name) { - if (name in this._fields) { - delete this._fields[name]; - return true; + const [pathHead, ...pathTail] = pathElements; + if (typeof pathHead !== "string") { + throw new Error(`Cannot index into a struct with a ${typeof pathHead}.`); + } + const child = this._fields[pathHead]; + if (child === undefined) { + return null; + } + if (pathTail.length === 0) { + return child[child.length - 1]; + } + return child[child.length - 1].get(...pathTail); + } + getAll() { + for (var _len2 = arguments.length, pathElements = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + pathElements[_key2] = arguments[_key2]; + } + if (pathElements.length === 0) { + throw new Error("Value#get requires at least one parameter."); + } + const [pathHead, ...pathTail] = pathElements; + if (typeof pathHead !== "string") { + throw new Error(`Cannot index into a struct with a ${typeof pathHead}.`); + } + const child = this._fields[pathHead]; + if (child === undefined) { + return null; + } + if (pathTail.length === 0) { + return child; + } + let values = []; + child.forEach(value => values.push(...value.getAll(...pathTail))); + return values; + } + fieldNames() { + return Object.keys(this._fields); + } + allFields() { + return Object.entries(this._fields); + } + fields() { + let singleValueFields = Object.create(null); + for (const [fieldName, values] of this.allFields()) { + singleValueFields[fieldName] = values[values.length - 1]; + } + return Object.entries(singleValueFields); + } + elements() { + return Object.values(this._fields).flat(); + } + [Symbol.iterator]() { + return this.fields()[Symbol.iterator](); + } + toString() { + return "{" + [...this.allFields()].map(_ref => { + let [name, value] = _ref; + return name + ": " + value; + }).join(", ") + "}"; + } + writeTo(writer) { + writer.setAnnotations(this.getAnnotations()); + writer.stepIn(Ion_1.IonTypes.STRUCT); + for (const [fieldName, values] of this.allFields()) { + for (let value of values) { + writer.writeFieldName(fieldName); + value.writeTo(writer); } - return false; } - }, { - key: "toJSON", - value: function toJSON() { - var normalizedFields = Object.create(Struct.prototype); - var _iterator5 = _createForOfIteratorHelper(this.fields()), - _step5; - try { - for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { - var _step5$value = (0, _slicedToArray2["default"])(_step5.value, 2), - key = _step5$value[0], - value = _step5$value[1]; - normalizedFields[key] = value; - } - } catch (err) { - _iterator5.e(err); - } finally { - _iterator5.f(); - } - return normalizedFields; - } - }, { - key: "_valueEquals", - value: function _valueEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null, - ignoreAnnotations: false, - ignoreTimestampPrecision: false, - onlyCompareIon: true - }; - var isSupportedType = false; - var valueToCompare = null; - if (other instanceof Struct) { + writer.stepOut(); + } + deleteField(name) { + if (name in this._fields) { + delete this._fields[name]; + return true; + } + return false; + } + toJSON() { + let normalizedFields = Object.create(Struct.prototype); + for (const [key, value] of this.fields()) { + normalizedFields[key] = value; + } + return normalizedFields; + } + static _fromJsValue(jsValue, annotations) { + if (!(jsValue instanceof Object)) { + throw new Error(`Cannot create a dom.Struct from: ${jsValue.toString()}`); + } + const fields = Object.entries(jsValue).map(_ref2 => { + let [key, value] = _ref2; + return [key, [Value_1.Value.from(value)]]; + }); + return new this(fields, annotations); + } + _valueEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null, + ignoreAnnotations: false, + ignoreTimestampPrecision: false, + onlyCompareIon: true + }; + let isSupportedType = false; + let valueToCompare = null; + if (other instanceof Struct) { + isSupportedType = true; + valueToCompare = other.allFields(); + } else if (!options.onlyCompareIon) { + if (typeof other === "object" || other instanceof Object) { isSupportedType = true; - valueToCompare = other.allFields(); - } else if (!options.onlyCompareIon) { - if ((0, _typeof2["default"])(other) === "object" || other instanceof Object) { - isSupportedType = true; - valueToCompare = Value_1.Value.from(other).allFields(); - } - } - if (!isSupportedType) { - return false; - } - if (this.allFields().length !== valueToCompare.length) { - return false; + valueToCompare = Value_1.Value.from(other).allFields(); } - var matchFound = true; - var paired = new Array(valueToCompare.length); - for (var i = 0; matchFound && i < this.allFields().length; i++) { - matchFound = false; - for (var j = 0; !matchFound && j < valueToCompare.length; j++) { - if (!paired[j]) { - var child = this.allFields()[i]; - var expectedChild = valueToCompare[j]; - matchFound = child[0] === expectedChild[0] && this._ionValueEquals(child[1].sort(), expectedChild[1].sort(), options); - if (matchFound) { - paired[j] = true; - } + } + if (!isSupportedType) { + return false; + } + if (this.allFields().length !== valueToCompare.length) { + return false; + } + let matchFound = true; + const paired = new Array(valueToCompare.length); + for (let i = 0; matchFound && i < this.allFields().length; i++) { + matchFound = false; + for (let j = 0; !matchFound && j < valueToCompare.length; j++) { + if (!paired[j]) { + const child = this.allFields()[i]; + const expectedChild = valueToCompare[j]; + matchFound = child[0] === expectedChild[0] && this._ionValueEquals(child[1].sort(), expectedChild[1].sort(), options); + if (matchFound) { + paired[j] = true; } } } - for (var _i = 0; _i < paired.length; _i++) { - if (!paired[_i]) { - matchFound = false; - break; - } - } - return matchFound; } - }, { - key: "_ionValueEquals", - value: function _ionValueEquals(child, expectedChild, options) { - if (child.length !== expectedChild.length) { - return false; + for (let i = 0; i < paired.length; i++) { + if (!paired[i]) { + matchFound = false; + break; } - for (var i = 0; i < child.length; i++) { - if (options.onlyCompareIon) { - if (!child[i].ionEquals(expectedChild[i], options)) { - return false; - } - } else { - if (!child[i].equals(expectedChild[i])) { - return false; - } + } + return matchFound; + } + _ionValueEquals(child, expectedChild, options) { + if (child.length !== expectedChild.length) { + return false; + } + for (let i = 0; i < child.length; i++) { + if (options.onlyCompareIon) { + if (!child[i].ionEquals(expectedChild[i], options)) { + return false; + } + } else { + if (!child[i].equals(expectedChild[i])) { + return false; } } - return true; - } - }], [{ - key: "_fromJsValue", - value: function _fromJsValue(jsValue, annotations) { - if (!(jsValue instanceof Object)) { - throw new Error("Cannot create a dom.Struct from: ".concat(jsValue.toString())); - } - var fields = Object.entries(jsValue).map(function (_ref3) { - var _ref4 = (0, _slicedToArray2["default"])(_ref3, 2), - key = _ref4[0], - value = _ref4[1]; - return [key, [Value_1.Value.from(value)]]; - }); - return new this(fields, annotations); } - }]); - return Struct; -}(Value_1.Value(Object, Ion_1.IonTypes.STRUCT, FromJsConstructor_1.FromJsConstructor.NONE), Symbol.iterator); + return true; + } +} exports.Struct = Struct; -},{"../Ion":5,"./FromJsConstructor":38,"./Value":50,"@babel/runtime/helpers/assertThisInitialized":59,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75,"@babel/runtime/helpers/slicedToArray":77,"@babel/runtime/helpers/toConsumableArray":79,"@babel/runtime/helpers/typeof":82}],48:[function(require,module,exports){ +},{"../Ion":5,"./FromJsConstructor":38,"./Value":50}],48:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.Symbol = void 0; -var Ion_1 = require("../Ion"); -var FromJsConstructor_1 = require("./FromJsConstructor"); -var Value_1 = require("./Value"); -var _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withPrimitives(FromJsConstructor_1.Primitives.String).withClassesToUnbox(String).build(); -var _Symbol = /*#__PURE__*/function (_Value_1$Value) { - (0, _inherits2["default"])(_Symbol, _Value_1$Value); - var _super = _createSuper(_Symbol); - function _Symbol(symbolText) { - var _this; - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, _Symbol); - _this = _super.call(this, symbolText); - _this._setAnnotations(annotations); - return _this; - } - (0, _createClass2["default"])(_Symbol, [{ - key: "stringValue", - value: function stringValue() { - return this.toString(); - } - }, { - key: "writeTo", - value: function writeTo(writer) { - writer.setAnnotations(this.getAnnotations()); - writer.writeSymbol(this.stringValue()); - } - }, { - key: "_valueEquals", - value: function _valueEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null, - ignoreAnnotations: false, - ignoreTimestampPrecision: false, - onlyCompareIon: true - }; - var isSupportedType = false; - var valueToCompare = null; - if (other instanceof _Symbol) { +const Ion_1 = require("../Ion"); +const FromJsConstructor_1 = require("./FromJsConstructor"); +const Value_1 = require("./Value"); +const _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withPrimitives(FromJsConstructor_1.Primitives.String).withClassesToUnbox(String).build(); +class Symbol extends Value_1.Value(String, Ion_1.IonTypes.SYMBOL, _fromJsConstructor) { + constructor(symbolText) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + super(symbolText); + this._setAnnotations(annotations); + } + stringValue() { + return this.toString(); + } + writeTo(writer) { + writer.setAnnotations(this.getAnnotations()); + writer.writeSymbol(this.stringValue()); + } + _valueEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null, + ignoreAnnotations: false, + ignoreTimestampPrecision: false, + onlyCompareIon: true + }; + let isSupportedType = false; + let valueToCompare = null; + if (other instanceof Symbol) { + isSupportedType = true; + valueToCompare = other.stringValue(); + } else if (!options.onlyCompareIon) { + if (typeof other === "string" || other instanceof String) { isSupportedType = true; - valueToCompare = other.stringValue(); - } else if (!options.onlyCompareIon) { - if (typeof other === "string" || other instanceof String) { - isSupportedType = true; - valueToCompare = other.valueOf(); - } - } - if (!isSupportedType) { - return false; + valueToCompare = other.valueOf(); } - return this.compareValue(valueToCompare) === 0; } - }, { - key: "compareValue", - value: function compareValue(expectedValue) { - return this.stringValue().localeCompare(expectedValue); + if (!isSupportedType) { + return false; } - }]); - return _Symbol; -}(Value_1.Value(String, Ion_1.IonTypes.SYMBOL, _fromJsConstructor)); -exports.Symbol = _Symbol; + return this.compareValue(valueToCompare) === 0; + } + compareValue(expectedValue) { + return this.stringValue().localeCompare(expectedValue); + } +} +exports.Symbol = Symbol; -},{"../Ion":5,"./FromJsConstructor":38,"./Value":50,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],49:[function(require,module,exports){ +},{"../Ion":5,"./FromJsConstructor":38,"./Value":50}],49:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, - get: function get() { + get: function () { return m[k]; } }); @@ -9867,20 +8229,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Timestamp = void 0; -var ion = __importStar(require("../Ion")); -var Ion_1 = require("../Ion"); -var FromJsConstructor_1 = require("./FromJsConstructor"); -var Value_1 = require("./Value"); -var _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withClasses(Date, ion.Timestamp).build(); -var Timestamp = /*#__PURE__*/function (_Value_1$Value) { - (0, _inherits2["default"])(Timestamp, _Value_1$Value); - var _super = _createSuper(Timestamp); - function Timestamp(dateOrTimestamp) { - var _this; - var annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - (0, _classCallCheck2["default"])(this, Timestamp); - var date; - var timestamp; +const ion = __importStar(require("../Ion")); +const Ion_1 = require("../Ion"); +const FromJsConstructor_1 = require("./FromJsConstructor"); +const Value_1 = require("./Value"); +const _fromJsConstructor = new FromJsConstructor_1.FromJsConstructorBuilder().withClasses(Date, ion.Timestamp).build(); +class Timestamp extends Value_1.Value(Date, Ion_1.IonTypes.TIMESTAMP, _fromJsConstructor) { + constructor(dateOrTimestamp) { + let annotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + let date; + let timestamp; if (dateOrTimestamp instanceof Date) { date = dateOrTimestamp; timestamp = Timestamp._timestampFromDate(date); @@ -9888,91 +8246,69 @@ var Timestamp = /*#__PURE__*/function (_Value_1$Value) { timestamp = dateOrTimestamp; date = timestamp.getDate(); } - _this = _super.call(this, date); - _this._date = date; - _this._timestamp = timestamp; - _this._setAnnotations(annotations); - return _this; - } - (0, _createClass2["default"])(Timestamp, [{ - key: "timestampValue", - value: function timestampValue() { - return this._timestamp; - } - }, { - key: "dateValue", - value: function dateValue() { - return this._date; - } - }, { - key: "writeTo", - value: function writeTo(writer) { - writer.setAnnotations(this.getAnnotations()); - writer.writeTimestamp(this.timestampValue()); - } - }, { - key: "_valueEquals", - value: function _valueEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null, - ignoreAnnotations: false, - ignoreTimestampPrecision: false, - onlyCompareIon: true - }; - var isSupportedType = false; - var valueToCompare = null; - if (other instanceof Timestamp) { + super(date); + this._date = date; + this._timestamp = timestamp; + this._setAnnotations(annotations); + } + static _timestampFromDate(date) { + const milliseconds = date.getUTCSeconds() * 1000 + date.getUTCMilliseconds(); + const fractionalSeconds = new Ion_1.Decimal(milliseconds, -3); + return new ion.Timestamp(0, date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), fractionalSeconds); + } + timestampValue() { + return this._timestamp; + } + dateValue() { + return this._date; + } + writeTo(writer) { + writer.setAnnotations(this.getAnnotations()); + writer.writeTimestamp(this.timestampValue()); + } + _valueEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null, + ignoreAnnotations: false, + ignoreTimestampPrecision: false, + onlyCompareIon: true + }; + let isSupportedType = false; + let valueToCompare = null; + if (other instanceof Timestamp) { + isSupportedType = true; + valueToCompare = other.timestampValue(); + } else if (!options.onlyCompareIon) { + if (other instanceof ion.Timestamp) { isSupportedType = true; - valueToCompare = other.timestampValue(); - } else if (!options.onlyCompareIon) { - if (other instanceof ion.Timestamp) { - isSupportedType = true; - valueToCompare = other; - } else if (other instanceof Date) { - if (this.dateValue().getTime() === other.getTime()) { - return true; - } else { - return false; - } + valueToCompare = other; + } else if (other instanceof Date) { + if (this.dateValue().getTime() === other.getTime()) { + return true; + } else { + return false; } } - if (!isSupportedType) { - return false; - } - if (options.ignoreTimestampPrecision) { - return this.timestampValue().compareTo(valueToCompare) === 0; - } - return this.timestampValue().equals(valueToCompare); } - }], [{ - key: "_timestampFromDate", - value: function _timestampFromDate(date) { - var milliseconds = date.getUTCSeconds() * 1000 + date.getUTCMilliseconds(); - var fractionalSeconds = new Ion_1.Decimal(milliseconds, -3); - return new ion.Timestamp(0, date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), fractionalSeconds); + if (!isSupportedType) { + return false; + } + if (options.ignoreTimestampPrecision) { + return this.timestampValue().compareTo(valueToCompare) === 0; } - }]); - return Timestamp; -}(Value_1.Value(Date, Ion_1.IonTypes.TIMESTAMP, _fromJsConstructor)); + return this.timestampValue().equals(valueToCompare); + } +} exports.Timestamp = Timestamp; -},{"../Ion":5,"./FromJsConstructor":38,"./Value":50,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],50:[function(require,module,exports){ +},{"../Ion":5,"./FromJsConstructor":38,"./Value":50}],50:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, - get: function get() { + get: function () { return m[k]; } }); @@ -9999,220 +8335,156 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Value = void 0; -var util_1 = require("../util"); -var JsValueConversion = __importStar(require("./JsValueConversion")); -var _DOM_VALUE_SIGNET = Symbol("ion.dom.Value"); +const util_1 = require("../util"); +const JsValueConversion = __importStar(require("./JsValueConversion")); +const _DOM_VALUE_SIGNET = Symbol("ion.dom.Value"); function Value(BaseClass, ionType, fromJsConstructor) { - var newClass = /*#__PURE__*/function (_BaseClass) { - (0, _inherits2["default"])(newClass, _BaseClass); - var _super = _createSuper(newClass); - function newClass() { - var _this; - (0, _classCallCheck2["default"])(this, newClass); - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - _this = _super.call.apply(_super, [this].concat(args)); - _this._ionType = ionType; - _this._ionAnnotations = []; - Object.defineProperty((0, _assertThisInitialized2["default"])(_this), "_ionType", { + const newClass = class extends BaseClass { + constructor() { + super(...arguments); + this._ionType = ionType; + this._ionAnnotations = []; + Object.defineProperty(this, "_ionType", { enumerable: false }); - Object.defineProperty((0, _assertThisInitialized2["default"])(_this), "_ionAnnotations", { + Object.defineProperty(this, "_ionAnnotations", { enumerable: false }); - return _this; - } - (0, _createClass2["default"])(newClass, [{ - key: "_unsupportedOperation", - value: function _unsupportedOperation(functionName) { - throw new Error("Value#".concat(functionName, "() is not supported by Ion type ").concat(this.getType().name)); - } - }, { - key: "getType", - value: function getType() { - return this._ionType; - } - }, { - key: "_setAnnotations", - value: function _setAnnotations(annotations) { - this._ionAnnotations = annotations; - } - }, { - key: "getAnnotations", - value: function getAnnotations() { - if (this._ionAnnotations === null) { - return []; - } - return this._ionAnnotations; - } - }, { - key: "isNull", - value: function isNull() { - return false; + } + _unsupportedOperation(functionName) { + throw new Error(`Value#${functionName}() is not supported by Ion type ${this.getType().name}`); + } + getType() { + return this._ionType; + } + _setAnnotations(annotations) { + this._ionAnnotations = annotations; + } + getAnnotations() { + if (this._ionAnnotations === null) { + return []; } - }, { - key: "booleanValue", - value: function booleanValue() { - this._unsupportedOperation("booleanValue"); - } - }, { - key: "numberValue", - value: function numberValue() { - this._unsupportedOperation("numberValue"); - } - }, { - key: "bigIntValue", - value: function bigIntValue() { - this._unsupportedOperation("bigIntValue"); - } - }, { - key: "decimalValue", - value: function decimalValue() { - this._unsupportedOperation("decimalValue"); - } - }, { - key: "stringValue", - value: function stringValue() { - this._unsupportedOperation("stringValue"); - } - }, { - key: "dateValue", - value: function dateValue() { - this._unsupportedOperation("dateValue"); - } - }, { - key: "timestampValue", - value: function timestampValue() { - this._unsupportedOperation("timestampValue"); - } - }, { - key: "uInt8ArrayValue", - value: function uInt8ArrayValue() { - this._unsupportedOperation("uInt8ArrayValue"); - } - }, { - key: "fieldNames", - value: function fieldNames() { - this._unsupportedOperation("fieldNames"); - } - }, { - key: "fields", - value: function fields() { - this._unsupportedOperation("fields"); - } - }, { - key: "allFields", - value: function allFields() { - this._unsupportedOperation("allFields"); - } - }, { - key: "elements", - value: function elements() { - this._unsupportedOperation("elements"); - } - }, { - key: "get", - value: function get() { - this._unsupportedOperation("get"); - } - }, { - key: "getAll", - value: function getAll() { - this._unsupportedOperation("getAll"); - } - }, { - key: "as", - value: function as(ionValueType) { - if (this instanceof ionValueType) { - return this; - } - throw new Error("".concat(this.constructor.name, " is not an instance of ").concat(ionValueType.name)); - } - }, { - key: "writeTo", - value: function writeTo(writer) { - this._unsupportedOperation("writeTo"); - } - }, { - key: "deleteField", - value: function deleteField(name) { - this._unsupportedOperation("deleteField"); - } - }, { - key: "_valueEquals", - value: function _valueEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null, - ignoreAnnotations: false, - ignoreTimestampPrecision: false, - onlyCompareIon: true, - coerceNumericType: false - }; - this._unsupportedOperation("_valueEquals"); - } - }, { - key: "equals", - value: function equals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null - }; - var onlyCompareIon = false; - if (other instanceof Value) { - onlyCompareIon = true; - } - return this._valueEquals(other, { - onlyCompareIon: onlyCompareIon, - ignoreTimestampPrecision: true, - ignoreAnnotations: true, - epsilon: options.epsilon, - coerceNumericType: true - }); - } - }, { - key: "ionEquals", - value: function ionEquals(other) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { - epsilon: null, - ignoreAnnotations: false, - ignoreTimestampPrecision: false - }; - if (!options.ignoreAnnotations) { - if (!(other instanceof Value)) { - return false; - } - var actualAnnotations = this.getAnnotations(); - var expectedAnnotations = other.getAnnotations(); - if (actualAnnotations.length !== expectedAnnotations.length) { + return this._ionAnnotations; + } + isNull() { + return false; + } + booleanValue() { + this._unsupportedOperation("booleanValue"); + } + numberValue() { + this._unsupportedOperation("numberValue"); + } + bigIntValue() { + this._unsupportedOperation("bigIntValue"); + } + decimalValue() { + this._unsupportedOperation("decimalValue"); + } + stringValue() { + this._unsupportedOperation("stringValue"); + } + dateValue() { + this._unsupportedOperation("dateValue"); + } + timestampValue() { + this._unsupportedOperation("timestampValue"); + } + uInt8ArrayValue() { + this._unsupportedOperation("uInt8ArrayValue"); + } + fieldNames() { + this._unsupportedOperation("fieldNames"); + } + fields() { + this._unsupportedOperation("fields"); + } + allFields() { + this._unsupportedOperation("allFields"); + } + elements() { + this._unsupportedOperation("elements"); + } + get() { + this._unsupportedOperation("get"); + } + getAll() { + this._unsupportedOperation("getAll"); + } + as(ionValueType) { + if (this instanceof ionValueType) { + return this; + } + throw new Error(`${this.constructor.name} is not an instance of ${ionValueType.name}`); + } + writeTo(writer) { + this._unsupportedOperation("writeTo"); + } + deleteField(name) { + this._unsupportedOperation("deleteField"); + } + _valueEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null, + ignoreAnnotations: false, + ignoreTimestampPrecision: false, + onlyCompareIon: true, + coerceNumericType: false + }; + this._unsupportedOperation("_valueEquals"); + } + equals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null + }; + let onlyCompareIon = false; + if (other instanceof Value) { + onlyCompareIon = true; + } + return this._valueEquals(other, { + onlyCompareIon: onlyCompareIon, + ignoreTimestampPrecision: true, + ignoreAnnotations: true, + epsilon: options.epsilon, + coerceNumericType: true + }); + } + ionEquals(other) { + let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + epsilon: null, + ignoreAnnotations: false, + ignoreTimestampPrecision: false + }; + if (!options.ignoreAnnotations) { + if (!(other instanceof Value)) { + return false; + } + let actualAnnotations = this.getAnnotations(); + let expectedAnnotations = other.getAnnotations(); + if (actualAnnotations.length !== expectedAnnotations.length) { + return false; + } + for (let i = 0; i < actualAnnotations.length; i++) { + if (actualAnnotations[i].localeCompare(expectedAnnotations[i]) !== 0) { return false; } - for (var i = 0; i < actualAnnotations.length; i++) { - if (actualAnnotations[i].localeCompare(expectedAnnotations[i]) !== 0) { - return false; - } - } } - var ion_options = { - onlyCompareIon: true, - ignoreTimestampPrecision: options.ignoreTimestampPrecision, - epsilon: options.epsilon, - coerceNumericType: false - }; - return this._valueEquals(other, ion_options); - } - }], [{ - key: "_getIonType", - value: function _getIonType() { - return ionType; - } - }, { - key: "_fromJsValue", - value: function _fromJsValue(jsValue, annotations) { - return fromJsConstructor.construct(this, jsValue, annotations); - } - }]); - return newClass; - }(BaseClass); + } + let ion_options = { + onlyCompareIon: true, + ignoreTimestampPrecision: options.ignoreTimestampPrecision, + epsilon: options.epsilon, + coerceNumericType: false + }; + return this._valueEquals(other, ion_options); + } + static _getIonType() { + return ionType; + } + static _fromJsValue(jsValue, annotations) { + return fromJsConstructor.construct(this, jsValue, annotations); + } + }; Object.defineProperty(newClass, _DOM_VALUE_SIGNET, { writable: false, enumerable: false, @@ -10234,21 +8506,19 @@ exports.Value = Value; Value.from = from; })(Value = exports.Value || (exports.Value = {})); Object.defineProperty(Value, Symbol.hasInstance, { - get: function get() { - return function (instance) { - return util_1._hasValue(instance) && util_1._hasValue(instance.constructor) && _DOM_VALUE_SIGNET in instance.constructor && instance.constructor[_DOM_VALUE_SIGNET] === _DOM_VALUE_SIGNET; - }; + get: () => instance => { + return util_1._hasValue(instance) && util_1._hasValue(instance.constructor) && _DOM_VALUE_SIGNET in instance.constructor && instance.constructor[_DOM_VALUE_SIGNET] === _DOM_VALUE_SIGNET; } }); -},{"../util":55,"./JsValueConversion":40,"@babel/runtime/helpers/assertThisInitialized":59,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],51:[function(require,module,exports){ +},{"../util":55,"./JsValueConversion":40}],51:[function(require,module,exports){ "use strict"; var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, - get: function get() { + get: function () { return m[k]; } }); @@ -10275,24 +8545,24 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.load = exports.loadAll = void 0; -var ion = __importStar(require("../Ion")); -var Ion_1 = require("../Ion"); -var IonBinaryReader_1 = require("../IonBinaryReader"); -var IonTextReader_1 = require("../IonTextReader"); -var Blob_1 = require("./Blob"); -var Clob_1 = require("./Clob"); -var Decimal_1 = require("./Decimal"); -var Float_1 = require("./Float"); -var Integer_1 = require("./Integer"); -var List_1 = require("./List"); -var Null_1 = require("./Null"); -var SExpression_1 = require("./SExpression"); -var Struct_1 = require("./Struct"); -var Symbol_1 = require("./Symbol"); -var Timestamp_1 = require("./Timestamp"); +const ion = __importStar(require("../Ion")); +const Ion_1 = require("../Ion"); +const IonBinaryReader_1 = require("../IonBinaryReader"); +const IonTextReader_1 = require("../IonTextReader"); +const Blob_1 = require("./Blob"); +const Clob_1 = require("./Clob"); +const Decimal_1 = require("./Decimal"); +const Float_1 = require("./Float"); +const Integer_1 = require("./Integer"); +const List_1 = require("./List"); +const Null_1 = require("./Null"); +const SExpression_1 = require("./SExpression"); +const Struct_1 = require("./Struct"); +const Symbol_1 = require("./Symbol"); +const Timestamp_1 = require("./Timestamp"); function loadAll(ionData) { - var reader = _createReader(ionData); - var ionValues = []; + const reader = _createReader(ionData); + const ionValues = []; while (reader.next()) { ionValues.push(_loadValue(reader)); } @@ -10300,7 +8570,7 @@ function loadAll(ionData) { } exports.loadAll = loadAll; function load(ionData) { - var reader = _createReader(ionData); + const reader = _createReader(ionData); if (reader.type() === null) { reader.next(); } @@ -10314,11 +8584,11 @@ function _createReader(ionData) { return Ion_1.makeReader(ionData); } function _loadValue(reader) { - var ionType = reader.type(); + const ionType = reader.type(); if (ionType === null) { throw new Error("loadValue() called when no further values were available to read."); } - var annotations = reader.annotations(); + const annotations = reader.annotations(); if (reader.isNull()) { return new Null_1.Null(reader.type(), annotations); } @@ -10350,12 +8620,12 @@ function _loadValue(reader) { case Ion_1.IonTypes.STRUCT: return _loadStruct(reader); default: - throw new Error("Unrecognized IonType '".concat(ionType, "' found.")); + throw new Error(`Unrecognized IonType '${ionType}' found.`); } } function _loadStruct(reader) { - var children = new Map(); - var annotations = reader.annotations(); + const children = new Map(); + const annotations = reader.annotations(); reader.stepIn(); while (reader.next()) { if (children.has(reader.fieldName())) { @@ -10368,15 +8638,15 @@ function _loadStruct(reader) { return new Struct_1.Struct(children.entries(), annotations); } function _loadList(reader) { - var annotations = reader.annotations(); + const annotations = reader.annotations(); return new List_1.List(_loadSequence(reader), annotations); } function _loadSExpression(reader) { - var annotations = reader.annotations(); + const annotations = reader.annotations(); return new SExpression_1.SExpression(_loadSequence(reader), annotations); } function _loadSequence(reader) { - var children = []; + const children = []; reader.stepIn(); while (reader.next()) { children.push(_loadValue(reader)); @@ -10387,98 +8657,98 @@ function _loadSequence(reader) { var Value_1 = require("./Value"); Object.defineProperty(exports, "Value", { enumerable: true, - get: function get() { + get: function () { return Value_1.Value; } }); var Null_2 = require("./Null"); Object.defineProperty(exports, "Null", { enumerable: true, - get: function get() { + get: function () { return Null_2.Null; } }); var Boolean_1 = require("./Boolean"); Object.defineProperty(exports, "Boolean", { enumerable: true, - get: function get() { + get: function () { return Boolean_1.Boolean; } }); var Integer_2 = require("./Integer"); Object.defineProperty(exports, "Integer", { enumerable: true, - get: function get() { + get: function () { return Integer_2.Integer; } }); var Float_2 = require("./Float"); Object.defineProperty(exports, "Float", { enumerable: true, - get: function get() { + get: function () { return Float_2.Float; } }); var Decimal_2 = require("./Decimal"); Object.defineProperty(exports, "Decimal", { enumerable: true, - get: function get() { + get: function () { return Decimal_2.Decimal; } }); var Timestamp_2 = require("./Timestamp"); Object.defineProperty(exports, "Timestamp", { enumerable: true, - get: function get() { + get: function () { return Timestamp_2.Timestamp; } }); var String_1 = require("./String"); Object.defineProperty(exports, "String", { enumerable: true, - get: function get() { + get: function () { return String_1.String; } }); var Symbol_2 = require("./Symbol"); Object.defineProperty(exports, "Symbol", { enumerable: true, - get: function get() { + get: function () { return Symbol_2.Symbol; } }); var Blob_2 = require("./Blob"); Object.defineProperty(exports, "Blob", { enumerable: true, - get: function get() { + get: function () { return Blob_2.Blob; } }); var Clob_2 = require("./Clob"); Object.defineProperty(exports, "Clob", { enumerable: true, - get: function get() { + get: function () { return Clob_2.Clob; } }); var Struct_2 = require("./Struct"); Object.defineProperty(exports, "Struct", { enumerable: true, - get: function get() { + get: function () { return Struct_2.Struct; } }); var List_2 = require("./List"); Object.defineProperty(exports, "List", { enumerable: true, - get: function get() { + get: function () { return List_2.List; } }); var SExpression_2 = require("./SExpression"); Object.defineProperty(exports, "SExpression", { enumerable: true, - get: function get() { + get: function () { return SExpression_2.SExpression; } }); @@ -10486,37 +8756,22 @@ Object.defineProperty(exports, "SExpression", { },{"../Ion":5,"../IonBinaryReader":7,"../IonTextReader":25,"./Blob":33,"./Boolean":34,"./Clob":35,"./Decimal":36,"./Float":37,"./Integer":39,"./List":41,"./Null":43,"./SExpression":44,"./String":46,"./Struct":47,"./Symbol":48,"./Timestamp":49,"./Value":50}],52:[function(require,module,exports){ "use strict"; -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.EventStreamError = void 0; -var EventStreamError = /*#__PURE__*/function (_Error) { - (0, _inherits2["default"])(EventStreamError, _Error); - var _super = _createSuper(EventStreamError); - function EventStreamError(type, message, index, eventstream) { - var _this; - (0, _classCallCheck2["default"])(this, EventStreamError); - _this = _super.call(this); - _this.type = type; - _this.index = index; - _this.message = message; - _this.eventstream = eventstream; - return _this; - } - return (0, _createClass2["default"])(EventStreamError); -}( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(Error)); +class EventStreamError extends Error { + constructor(type, message, index, eventstream) { + super(); + this.type = type; + this.index = index; + this.message = message; + this.eventstream = eventstream; + } +} exports.EventStreamError = EventStreamError; -},{"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75,"@babel/runtime/helpers/wrapNativeSuper":84}],53:[function(require,module,exports){ +},{}],53:[function(require,module,exports){ "use strict"; /*! @@ -10533,25 +8788,17 @@ exports.EventStreamError = EventStreamError; * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); -var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); -var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } Object.defineProperty(exports, "__esModule", { value: true }); exports.IonEventFactory = exports.IonEventType = void 0; -var ComparisonResult_1 = require("../ComparisonResult"); -var IonBinaryWriter_1 = require("../IonBinaryWriter"); -var IonLocalSymbolTable_1 = require("../IonLocalSymbolTable"); -var IonTextWriter_1 = require("../IonTextWriter"); -var IonTypes_1 = require("../IonTypes"); -var IonUnicode_1 = require("../IonUnicode"); -var IonWriteable_1 = require("../IonWriteable"); +const ComparisonResult_1 = require("../ComparisonResult"); +const IonBinaryWriter_1 = require("../IonBinaryWriter"); +const IonLocalSymbolTable_1 = require("../IonLocalSymbolTable"); +const IonTextWriter_1 = require("../IonTextWriter"); +const IonTypes_1 = require("../IonTypes"); +const IonUnicode_1 = require("../IonUnicode"); +const IonWriteable_1 = require("../IonWriteable"); var IonEventType; (function (IonEventType) { IonEventType[IonEventType["SCALAR"] = 0] = "SCALAR"; @@ -10560,9 +8807,8 @@ var IonEventType; IonEventType[IonEventType["SYMBOL_TABLE"] = 3] = "SYMBOL_TABLE"; IonEventType[IonEventType["STREAM_END"] = 4] = "STREAM_END"; })(IonEventType = exports.IonEventType || (exports.IonEventType = {})); -var AbstractIonEvent = /*#__PURE__*/function () { - function AbstractIonEvent(eventType, ionType, fieldName, annotations, depth, ionValue) { - (0, _classCallCheck2["default"])(this, AbstractIonEvent); +class AbstractIonEvent { + constructor(eventType, ionType, fieldName, annotations, depth, ionValue) { this.eventType = eventType; this.ionType = ionType; this.fieldName = fieldName; @@ -10570,1166 +8816,970 @@ var AbstractIonEvent = /*#__PURE__*/function () { this.depth = depth; this.ionValue = ionValue; } - (0, _createClass2["default"])(AbstractIonEvent, [{ - key: "write", - value: function write(writer) { + write(writer) { + writer.stepIn(IonTypes_1.IonTypes.STRUCT); + writer.writeFieldName("event_type"); + writer.writeSymbol(IonEventType[this.eventType]); + if (this.ionType !== null) { + writer.writeFieldName("ion_type"); + writer.writeSymbol(this.ionType.name.toUpperCase()); + } + if (this.fieldName !== null && this.fieldName !== undefined) { + writer.writeFieldName("field_name"); writer.stepIn(IonTypes_1.IonTypes.STRUCT); - writer.writeFieldName("event_type"); - writer.writeSymbol(IonEventType[this.eventType]); - if (this.ionType !== null) { - writer.writeFieldName("ion_type"); - writer.writeSymbol(this.ionType.name.toUpperCase()); - } - if (this.fieldName !== null && this.fieldName !== undefined) { - writer.writeFieldName("field_name"); - writer.stepIn(IonTypes_1.IonTypes.STRUCT); - writer.writeFieldName("text"); - writer.writeString(this.fieldName); - writer.stepOut(); - } - if (this.annotations !== null) { - writer.writeFieldName("annotations"); - this.writeAnnotations(writer); - } - if (this.eventType === IonEventType.SCALAR) { - this.writeValues(writer); - } - writer.writeFieldName("depth"); - writer.writeInt(this.depth); + writer.writeFieldName("text"); + writer.writeString(this.fieldName); writer.stepOut(); } - }, { - key: "writeAnnotations", - value: function writeAnnotations(writer) { - if (this.annotations === undefined) { - writer.writeNull(IonTypes_1.IonTypes.LIST); - return; - } - writer.stepIn(IonTypes_1.IonTypes.LIST); - for (var i = 0; i < this.annotations.length; i++) { - writer.stepIn(IonTypes_1.IonTypes.STRUCT); - writer.writeFieldName("text"); - writer.writeString(this.annotations[i]); - writer.stepOut(); - } - writer.stepOut(); + if (this.annotations !== null) { + writer.writeFieldName("annotations"); + this.writeAnnotations(writer); } - }, { - key: "writeSymbolToken", - value: function writeSymbolToken(writer, text) { - writer.writeSymbol(text); - } - }, { - key: "writeImportDescriptor", - value: function writeImportDescriptor(writer) { - writer.writeNull(IonTypes_1.IonTypes.STRUCT); - } - }, { - key: "writeValues", - value: function writeValues(writer) { - if (this.eventType === IonEventType.SCALAR) { - writer.writeFieldName("value_text"); - this.writeTextValue(writer); - writer.writeFieldName("value_binary"); - this.writeBinaryValue(writer); - } - } - }, { - key: "writeTextValue", - value: function writeTextValue(writer) { - var tempTextWriter = new IonTextWriter_1.TextWriter(new IonWriteable_1.Writeable()); - this.writeIonValue(tempTextWriter); - tempTextWriter.close(); - writer.writeString(IonUnicode_1.decodeUtf8(tempTextWriter.getBytes())); - } - }, { - key: "writeBinaryValue", - value: function writeBinaryValue(writer) { - var tempBinaryWriter = new IonBinaryWriter_1.BinaryWriter(IonLocalSymbolTable_1.defaultLocalSymbolTable(), new IonWriteable_1.Writeable()); - this.writeIonValue(tempBinaryWriter); - tempBinaryWriter.close(); - var binaryBuffer = tempBinaryWriter.getBytes(); - writer.stepIn(IonTypes_1.IonTypes.LIST); - for (var i = 0; i < binaryBuffer.length; i++) { - writer.writeInt(binaryBuffer[i]); - } + if (this.eventType === IonEventType.SCALAR) { + this.writeValues(writer); + } + writer.writeFieldName("depth"); + writer.writeInt(this.depth); + writer.stepOut(); + } + writeAnnotations(writer) { + if (this.annotations === undefined) { + writer.writeNull(IonTypes_1.IonTypes.LIST); + return; + } + writer.stepIn(IonTypes_1.IonTypes.LIST); + for (let i = 0; i < this.annotations.length; i++) { + writer.stepIn(IonTypes_1.IonTypes.STRUCT); + writer.writeFieldName("text"); + writer.writeString(this.annotations[i]); writer.stepOut(); } - }, { - key: "equals", - value: function equals(expected) { - return this.compare(expected).result == ComparisonResult_1.ComparisonResultType.EQUAL; + writer.stepOut(); + } + writeSymbolToken(writer, text) { + writer.writeSymbol(text); + } + writeImportDescriptor(writer) { + writer.writeNull(IonTypes_1.IonTypes.STRUCT); + } + writeValues(writer) { + if (this.eventType === IonEventType.SCALAR) { + writer.writeFieldName("value_text"); + this.writeTextValue(writer); + writer.writeFieldName("value_binary"); + this.writeBinaryValue(writer); } - }, { - key: "compare", - value: function compare(expected) { - if (this.eventType !== expected.eventType) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Event types don't match"); - } - if (this.ionType !== expected.ionType) { - var _this$ionType, _expected$ionType; - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Ion types don't match " + ((_this$ionType = this.ionType) === null || _this$ionType === void 0 ? void 0 : _this$ionType.name) + " vs. " + ((_expected$ionType = expected.ionType) === null || _expected$ionType === void 0 ? void 0 : _expected$ionType.name)); - } - if (this.fieldName !== expected.fieldName) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Field names don't match " + this.fieldName + " vs. " + expected.fieldName); - } - if (this.depth !== expected.depth) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Event depths don't match " + this.depth + " vs. " + expected.depth); - } - var annotationResult = this.annotationCompare(expected.annotations); - if (annotationResult.result === ComparisonResult_1.ComparisonResultType.NOT_EQUAL) { - return annotationResult; - } - var valueResult = this.valueCompare(expected); - if (valueResult.result === ComparisonResult_1.ComparisonResultType.NOT_EQUAL) { - return valueResult; - } - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); + } + writeTextValue(writer) { + const tempTextWriter = new IonTextWriter_1.TextWriter(new IonWriteable_1.Writeable()); + this.writeIonValue(tempTextWriter); + tempTextWriter.close(); + writer.writeString(IonUnicode_1.decodeUtf8(tempTextWriter.getBytes())); + } + writeBinaryValue(writer) { + const tempBinaryWriter = new IonBinaryWriter_1.BinaryWriter(IonLocalSymbolTable_1.defaultLocalSymbolTable(), new IonWriteable_1.Writeable()); + this.writeIonValue(tempBinaryWriter); + tempBinaryWriter.close(); + const binaryBuffer = tempBinaryWriter.getBytes(); + writer.stepIn(IonTypes_1.IonTypes.LIST); + for (let i = 0; i < binaryBuffer.length; i++) { + writer.writeInt(binaryBuffer[i]); } - }, { - key: "annotationCompare", - value: function annotationCompare(expectedAnnotations) { - if (this.annotations === expectedAnnotations) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); - } - if (this.annotations.length !== expectedAnnotations.length) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "annotations length don't match" + this.annotations.length + " vs. " + expectedAnnotations.length); - } - for (var i = 0; i < this.annotations.length; i++) { - if (this.annotations[i] !== expectedAnnotations[i]) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "annotation value doesn't match" + this.annotations[i] + " vs. " + expectedAnnotations[i]); - } - } - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); + writer.stepOut(); + } + equals(expected) { + return this.compare(expected).result == ComparisonResult_1.ComparisonResultType.EQUAL; + } + compare(expected) { + if (this.eventType !== expected.eventType) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Event types don't match"); } - }]); - return AbstractIonEvent; -}(); -var IonEventFactory = /*#__PURE__*/function () { - function IonEventFactory() { - (0, _classCallCheck2["default"])(this, IonEventFactory); - } - (0, _createClass2["default"])(IonEventFactory, [{ - key: "makeEvent", - value: function makeEvent(eventType, ionType, fieldName, depth, annotations, isNull, value) { - if (isNull) { - return new IonNullEvent(eventType, ionType, fieldName, annotations, depth); - } - switch (eventType) { - case IonEventType.SCALAR: - case IonEventType.CONTAINER_START: - switch (ionType) { - case IonTypes_1.IonTypes.BOOL: - { - return new IonBoolEvent(eventType, ionType, fieldName, annotations, depth, value); - } - case IonTypes_1.IonTypes.INT: - { - return new IonIntEvent(eventType, ionType, fieldName, annotations, depth, value); - } - case IonTypes_1.IonTypes.FLOAT: - { - return new IonFloatEvent(eventType, ionType, fieldName, annotations, depth, value); - } - case IonTypes_1.IonTypes.DECIMAL: - { - return new IonDecimalEvent(eventType, ionType, fieldName, annotations, depth, value); - } - case IonTypes_1.IonTypes.SYMBOL: - { - return new IonSymbolEvent(eventType, ionType, fieldName, annotations, depth, value); - } - case IonTypes_1.IonTypes.STRING: - { - return new IonStringEvent(eventType, ionType, fieldName, annotations, depth, value); - } - case IonTypes_1.IonTypes.TIMESTAMP: - { - return new IonTimestampEvent(eventType, ionType, fieldName, annotations, depth, value); - } - case IonTypes_1.IonTypes.BLOB: - { - return new IonBlobEvent(eventType, ionType, fieldName, annotations, depth, value); - } - case IonTypes_1.IonTypes.CLOB: - { - return new IonClobEvent(eventType, ionType, fieldName, annotations, depth, value); - } - case IonTypes_1.IonTypes.LIST: - { - return new IonListEvent(eventType, ionType, fieldName, annotations, depth); - } - case IonTypes_1.IonTypes.SEXP: - { - return new IonSexpEvent(eventType, ionType, fieldName, annotations, depth); - } - case IonTypes_1.IonTypes.STRUCT: - { - return new IonStructEvent(eventType, ionType, fieldName, annotations, depth); - } - default: - { - throw new Error("IonType " + ionType.name + " unexpected."); - } - } - case IonEventType.SYMBOL_TABLE: - throw new Error("symbol tables unsupported."); - case IonEventType.CONTAINER_END: - return new IonEndEvent(eventType, depth, ionType); - case IonEventType.STREAM_END: - return new IonEndEvent(eventType, depth, ionType); - } + if (this.ionType !== expected.ionType) { + var _this$ionType, _expected$ionType; + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Ion types don't match " + ((_this$ionType = this.ionType) === null || _this$ionType === void 0 ? void 0 : _this$ionType.name) + " vs. " + ((_expected$ionType = expected.ionType) === null || _expected$ionType === void 0 ? void 0 : _expected$ionType.name)); } - }]); - return IonEventFactory; -}(); -exports.IonEventFactory = IonEventFactory; -var IonNullEvent = /*#__PURE__*/function (_AbstractIonEvent) { - (0, _inherits2["default"])(IonNullEvent, _AbstractIonEvent); - var _super = _createSuper(IonNullEvent); - function IonNullEvent(eventType, ionType, fieldName, annotations, depth) { - (0, _classCallCheck2["default"])(this, IonNullEvent); - return _super.call(this, eventType, ionType, fieldName, annotations, depth, null); - } - (0, _createClass2["default"])(IonNullEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (expected instanceof IonNullEvent && this.ionValue === expected.ionValue) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); - } - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); + if (this.fieldName !== expected.fieldName) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Field names don't match " + this.fieldName + " vs. " + expected.fieldName); } - }, { - key: "writeIonValue", - value: function writeIonValue(writer) { - writer.writeNull(this.ionType !== null ? this.ionType : IonTypes_1.IonTypes.NULL); - } - }]); - return IonNullEvent; -}(AbstractIonEvent); -var IonIntEvent = /*#__PURE__*/function (_AbstractIonEvent2) { - (0, _inherits2["default"])(IonIntEvent, _AbstractIonEvent2); - var _super2 = _createSuper(IonIntEvent); - function IonIntEvent(eventType, ionType, fieldName, annotations, depth, ionValue) { - (0, _classCallCheck2["default"])(this, IonIntEvent); - return _super2.call(this, eventType, ionType, fieldName, annotations, depth, ionValue); - } - (0, _createClass2["default"])(IonIntEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (expected instanceof IonIntEvent) { - var actualValue = typeof this.ionValue === "bigint" ? this.ionValue : BigInt(this.ionValue); - var expectedValue = typeof expected.ionValue === "bigint" ? expected.ionValue : BigInt(expected.ionValue); - if (actualValue === expectedValue) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); - } - } - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "".concat(this.ionValue, " vs. ").concat(expected.ionValue)); - } - }, { - key: "writeIonValue", - value: function writeIonValue(writer) { - writer.writeInt(this.ionValue); - } - }]); - return IonIntEvent; -}(AbstractIonEvent); -var IonBoolEvent = /*#__PURE__*/function (_AbstractIonEvent3) { - (0, _inherits2["default"])(IonBoolEvent, _AbstractIonEvent3); - var _super3 = _createSuper(IonBoolEvent); - function IonBoolEvent(eventType, ionType, fieldName, annotations, depth, ionValue) { - (0, _classCallCheck2["default"])(this, IonBoolEvent); - return _super3.call(this, eventType, ionType, fieldName, annotations, depth, ionValue); - } - (0, _createClass2["default"])(IonBoolEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (expected instanceof IonBoolEvent && this.ionValue === expected.ionValue) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); - } - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); + if (this.depth !== expected.depth) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Event depths don't match " + this.depth + " vs. " + expected.depth); } - }, { - key: "writeIonValue", - value: function writeIonValue(writer) { - writer.writeBoolean(this.ionValue); - } - }]); - return IonBoolEvent; -}(AbstractIonEvent); -var IonFloatEvent = /*#__PURE__*/function (_AbstractIonEvent4) { - (0, _inherits2["default"])(IonFloatEvent, _AbstractIonEvent4); - var _super4 = _createSuper(IonFloatEvent); - function IonFloatEvent(eventType, ionType, fieldName, annotations, depth, ionValue) { - (0, _classCallCheck2["default"])(this, IonFloatEvent); - return _super4.call(this, eventType, ionType, fieldName, annotations, depth, ionValue); - } - (0, _createClass2["default"])(IonFloatEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (expected instanceof IonFloatEvent && Object.is(this.ionValue, expected.ionValue)) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); - } - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); + const annotationResult = this.annotationCompare(expected.annotations); + if (annotationResult.result === ComparisonResult_1.ComparisonResultType.NOT_EQUAL) { + return annotationResult; } - }, { - key: "writeIonValue", - value: function writeIonValue(writer) { - writer.writeFloat64(this.ionValue); - } - }]); - return IonFloatEvent; -}(AbstractIonEvent); -var IonDecimalEvent = /*#__PURE__*/function (_AbstractIonEvent5) { - (0, _inherits2["default"])(IonDecimalEvent, _AbstractIonEvent5); - var _super5 = _createSuper(IonDecimalEvent); - function IonDecimalEvent(eventType, ionType, fieldName, annotations, depth, ionValue) { - (0, _classCallCheck2["default"])(this, IonDecimalEvent); - return _super5.call(this, eventType, ionType, fieldName, annotations, depth, ionValue); - } - (0, _createClass2["default"])(IonDecimalEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (expected instanceof IonDecimalEvent && this.ionValue.equals(expected.ionValue)) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); - } - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); + const valueResult = this.valueCompare(expected); + if (valueResult.result === ComparisonResult_1.ComparisonResultType.NOT_EQUAL) { + return valueResult; } - }, { - key: "writeIonValue", - value: function writeIonValue(writer) { - writer.writeDecimal(this.ionValue); - } - }]); - return IonDecimalEvent; -}(AbstractIonEvent); -var IonSymbolEvent = /*#__PURE__*/function (_AbstractIonEvent6) { - (0, _inherits2["default"])(IonSymbolEvent, _AbstractIonEvent6); - var _super6 = _createSuper(IonSymbolEvent); - function IonSymbolEvent(eventType, ionType, fieldName, annotations, depth, ionValue) { - (0, _classCallCheck2["default"])(this, IonSymbolEvent); - return _super6.call(this, eventType, ionType, fieldName, annotations, depth, ionValue); - } - (0, _createClass2["default"])(IonSymbolEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (expected instanceof IonSymbolEvent && this.ionValue === expected.ionValue) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); - } - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); + } + annotationCompare(expectedAnnotations) { + if (this.annotations === expectedAnnotations) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); } - }, { - key: "writeIonValue", - value: function writeIonValue(writer) { - writer.writeSymbol(this.ionValue); - } - }]); - return IonSymbolEvent; -}(AbstractIonEvent); -var IonStringEvent = /*#__PURE__*/function (_AbstractIonEvent7) { - (0, _inherits2["default"])(IonStringEvent, _AbstractIonEvent7); - var _super7 = _createSuper(IonStringEvent); - function IonStringEvent(eventType, ionType, fieldName, annotations, depth, ionValue) { - (0, _classCallCheck2["default"])(this, IonStringEvent); - return _super7.call(this, eventType, ionType, fieldName, annotations, depth, ionValue); - } - (0, _createClass2["default"])(IonStringEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (expected instanceof IonStringEvent && this.ionValue === expected.ionValue) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); - } - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); + if (this.annotations.length !== expectedAnnotations.length) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "annotations length don't match" + this.annotations.length + " vs. " + expectedAnnotations.length); } - }, { - key: "writeIonValue", - value: function writeIonValue(writer) { - writer.writeString(this.ionValue); - } - }]); - return IonStringEvent; -}(AbstractIonEvent); -var IonTimestampEvent = /*#__PURE__*/function (_AbstractIonEvent8) { - (0, _inherits2["default"])(IonTimestampEvent, _AbstractIonEvent8); - var _super8 = _createSuper(IonTimestampEvent); - function IonTimestampEvent(eventType, ionType, fieldName, annotations, depth, ionValue) { - (0, _classCallCheck2["default"])(this, IonTimestampEvent); - return _super8.call(this, eventType, ionType, fieldName, annotations, depth, ionValue); - } - (0, _createClass2["default"])(IonTimestampEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (expected instanceof IonTimestampEvent && this.ionValue.equals(expected.ionValue)) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); + for (let i = 0; i < this.annotations.length; i++) { + if (this.annotations[i] !== expectedAnnotations[i]) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "annotation value doesn't match" + this.annotations[i] + " vs. " + expectedAnnotations[i]); } - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); - } - }, { - key: "writeIonValue", - value: function writeIonValue(writer) { - writer.writeTimestamp(this.ionValue); } - }]); - return IonTimestampEvent; -}(AbstractIonEvent); -var IonBlobEvent = /*#__PURE__*/function (_AbstractIonEvent9) { - (0, _inherits2["default"])(IonBlobEvent, _AbstractIonEvent9); - var _super9 = _createSuper(IonBlobEvent); - function IonBlobEvent(eventType, ionType, fieldName, annotations, depth, ionValue) { - (0, _classCallCheck2["default"])(this, IonBlobEvent); - return _super9.call(this, eventType, ionType, fieldName, annotations, depth, ionValue); + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); } - (0, _createClass2["default"])(IonBlobEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (!(expected instanceof IonBlobEvent)) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL); - } - if (this.ionValue.length !== expected.ionValue.length) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Blob length don't match"); - } - for (var i = 0; i < this.ionValue.length; i++) { - if (this.ionValue[i] !== expected.ionValue[i]) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue[i] + " vs. " + expected.ionValue[i]); +} +class IonEventFactory { + makeEvent(eventType, ionType, fieldName, depth, annotations, isNull, value) { + if (isNull) { + return new IonNullEvent(eventType, ionType, fieldName, annotations, depth); + } + switch (eventType) { + case IonEventType.SCALAR: + case IonEventType.CONTAINER_START: + switch (ionType) { + case IonTypes_1.IonTypes.BOOL: + { + return new IonBoolEvent(eventType, ionType, fieldName, annotations, depth, value); + } + case IonTypes_1.IonTypes.INT: + { + return new IonIntEvent(eventType, ionType, fieldName, annotations, depth, value); + } + case IonTypes_1.IonTypes.FLOAT: + { + return new IonFloatEvent(eventType, ionType, fieldName, annotations, depth, value); + } + case IonTypes_1.IonTypes.DECIMAL: + { + return new IonDecimalEvent(eventType, ionType, fieldName, annotations, depth, value); + } + case IonTypes_1.IonTypes.SYMBOL: + { + return new IonSymbolEvent(eventType, ionType, fieldName, annotations, depth, value); + } + case IonTypes_1.IonTypes.STRING: + { + return new IonStringEvent(eventType, ionType, fieldName, annotations, depth, value); + } + case IonTypes_1.IonTypes.TIMESTAMP: + { + return new IonTimestampEvent(eventType, ionType, fieldName, annotations, depth, value); + } + case IonTypes_1.IonTypes.BLOB: + { + return new IonBlobEvent(eventType, ionType, fieldName, annotations, depth, value); + } + case IonTypes_1.IonTypes.CLOB: + { + return new IonClobEvent(eventType, ionType, fieldName, annotations, depth, value); + } + case IonTypes_1.IonTypes.LIST: + { + return new IonListEvent(eventType, ionType, fieldName, annotations, depth); + } + case IonTypes_1.IonTypes.SEXP: + { + return new IonSexpEvent(eventType, ionType, fieldName, annotations, depth); + } + case IonTypes_1.IonTypes.STRUCT: + { + return new IonStructEvent(eventType, ionType, fieldName, annotations, depth); + } + default: + { + throw new Error("IonType " + ionType.name + " unexpected."); + } } - } - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); + case IonEventType.SYMBOL_TABLE: + throw new Error("symbol tables unsupported."); + case IonEventType.CONTAINER_END: + return new IonEndEvent(eventType, depth, ionType); + case IonEventType.STREAM_END: + return new IonEndEvent(eventType, depth, ionType); } - }, { - key: "writeIonValue", - value: function writeIonValue(writer) { - writer.writeBlob(this.ionValue); + } +} +exports.IonEventFactory = IonEventFactory; +class IonNullEvent extends AbstractIonEvent { + constructor(eventType, ionType, fieldName, annotations, depth) { + super(eventType, ionType, fieldName, annotations, depth, null); + } + valueCompare(expected) { + if (expected instanceof IonNullEvent && this.ionValue === expected.ionValue) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); } - }]); - return IonBlobEvent; -}(AbstractIonEvent); -var IonClobEvent = /*#__PURE__*/function (_AbstractIonEvent10) { - (0, _inherits2["default"])(IonClobEvent, _AbstractIonEvent10); - var _super10 = _createSuper(IonClobEvent); - function IonClobEvent(eventType, ionType, fieldName, annotations, depth, ionValue) { - (0, _classCallCheck2["default"])(this, IonClobEvent); - return _super10.call(this, eventType, ionType, fieldName, annotations, depth, ionValue); + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); } - (0, _createClass2["default"])(IonClobEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (!(expected instanceof IonClobEvent)) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL); - } - if (this.ionValue.length !== expected.ionValue.length) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); - } - for (var i = 0; i < this.ionValue.length; i++) { - if (this.ionValue[i] !== expected.ionValue[i]) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue[i] + " vs. " + expected.ionValue[i]); - } + writeIonValue(writer) { + writer.writeNull(this.ionType !== null ? this.ionType : IonTypes_1.IonTypes.NULL); + } +} +class IonIntEvent extends AbstractIonEvent { + constructor(eventType, ionType, fieldName, annotations, depth, ionValue) { + super(eventType, ionType, fieldName, annotations, depth, ionValue); + } + valueCompare(expected) { + if (expected instanceof IonIntEvent) { + let actualValue = typeof this.ionValue === "bigint" ? this.ionValue : BigInt(this.ionValue); + let expectedValue = typeof expected.ionValue === "bigint" ? expected.ionValue : BigInt(expected.ionValue); + if (actualValue === expectedValue) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); } + } + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, `${this.ionValue} vs. ${expected.ionValue}`); + } + writeIonValue(writer) { + writer.writeInt(this.ionValue); + } +} +class IonBoolEvent extends AbstractIonEvent { + constructor(eventType, ionType, fieldName, annotations, depth, ionValue) { + super(eventType, ionType, fieldName, annotations, depth, ionValue); + } + valueCompare(expected) { + if (expected instanceof IonBoolEvent && this.ionValue === expected.ionValue) { return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); } - }, { - key: "writeIonValue", - value: function writeIonValue(writer) { - writer.writeClob(this.ionValue); - } - }]); - return IonClobEvent; -}(AbstractIonEvent); -var AbsIonContainerEvent = /*#__PURE__*/function (_AbstractIonEvent11) { - (0, _inherits2["default"])(AbsIonContainerEvent, _AbstractIonEvent11); - var _super11 = _createSuper(AbsIonContainerEvent); - function AbsIonContainerEvent(eventType, ionType, fieldName, annotations, depth) { - (0, _classCallCheck2["default"])(this, AbsIonContainerEvent); - return _super11.call(this, eventType, ionType, fieldName, annotations, depth, null); - } - (0, _createClass2["default"])(AbsIonContainerEvent, [{ - key: "writeIonValue", - value: function writeIonValue(writer) {} - }]); - return AbsIonContainerEvent; -}(AbstractIonEvent); -var IonStructEvent = /*#__PURE__*/function (_AbsIonContainerEvent) { - (0, _inherits2["default"])(IonStructEvent, _AbsIonContainerEvent); - var _super12 = _createSuper(IonStructEvent); - function IonStructEvent(eventType, ionType, fieldName, annotations, depth) { - (0, _classCallCheck2["default"])(this, IonStructEvent); - return _super12.call(this, eventType, ionType, fieldName, annotations, depth); - } - (0, _createClass2["default"])(IonStructEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (!(expected instanceof IonStructEvent)) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Event types don't match"); - } - var container = this.ionValue == null ? [] : this.ionValue; - var expectedContainer = expected.ionValue == null ? [] : expected.ionValue; - if (container.length !== expectedContainer.length) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Struct length don't match"); - } - return this.structsCompare(container, expectedContainer); - } - }, { - key: "structsCompare", - value: function structsCompare(actualEvents, expectedEvents) { - var matchFound = new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); - var paired = new Array(expectedEvents.length); - for (var i = 0; matchFound && i < actualEvents.length; i++) { - matchFound.result = ComparisonResult_1.ComparisonResultType.NOT_EQUAL; - for (var j = 0; matchFound.result == ComparisonResult_1.ComparisonResultType.NOT_EQUAL && j < expectedEvents.length; j++) { - if (!paired[j]) { - var child = actualEvents[i]; - var expectedChild = expectedEvents[j]; - matchFound = child.compare(expectedChild); - if (matchFound.result == ComparisonResult_1.ComparisonResultType.EQUAL) { - paired[j] = true; - } - if (matchFound.result == ComparisonResult_1.ComparisonResultType.EQUAL && child.eventType === IonEventType.CONTAINER_START) { - for (var k = 0; k < expectedChild.ionValue.length; k++) { - paired[k + j + 1] = true; - } - i += child.ionValue.length; - } - } - } - } - for (var _i = 0; _i < paired.length; _i++) { - if (!paired[_i]) { - matchFound = new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Didn't find matching field for " + expectedEvents[_i].fieldName); - break; - } - } - return matchFound; + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); + } + writeIonValue(writer) { + writer.writeBoolean(this.ionValue); + } +} +class IonFloatEvent extends AbstractIonEvent { + constructor(eventType, ionType, fieldName, annotations, depth, ionValue) { + super(eventType, ionType, fieldName, annotations, depth, ionValue); + } + valueCompare(expected) { + if (expected instanceof IonFloatEvent && Object.is(this.ionValue, expected.ionValue)) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); } - }]); - return IonStructEvent; -}(AbsIonContainerEvent); -var IonListEvent = /*#__PURE__*/function (_AbsIonContainerEvent2) { - (0, _inherits2["default"])(IonListEvent, _AbsIonContainerEvent2); - var _super13 = _createSuper(IonListEvent); - function IonListEvent(eventType, ionType, fieldName, annotations, depth) { - (0, _classCallCheck2["default"])(this, IonListEvent); - return _super13.call(this, eventType, ionType, fieldName, annotations, depth); + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); } - (0, _createClass2["default"])(IonListEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (!(expected instanceof IonListEvent)) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Event types don't match"); - } - var container = this.ionValue == null ? [] : this.ionValue; - var expectedContainer = expected.ionValue == null ? [] : expected.ionValue; - if (container.length !== expectedContainer.length) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "List length don't match"); - } - for (var i = 0; i < container.length; i++) { - var child = container[i]; - if (child.compare(expectedContainer[i]).result == ComparisonResult_1.ComparisonResultType.NOT_EQUAL) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "".concat(child.ionValue, " vs. ").concat(expectedContainer[i].ionValue), i + 1, i + 1); - } else if (child.eventType === IonEventType.CONTAINER_START) { - i += child.ionValue.length; - } - } + writeIonValue(writer) { + writer.writeFloat64(this.ionValue); + } +} +class IonDecimalEvent extends AbstractIonEvent { + constructor(eventType, ionType, fieldName, annotations, depth, ionValue) { + super(eventType, ionType, fieldName, annotations, depth, ionValue); + } + valueCompare(expected) { + if (expected instanceof IonDecimalEvent && this.ionValue.equals(expected.ionValue)) { return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); } - }]); - return IonListEvent; -}(AbsIonContainerEvent); -var IonSexpEvent = /*#__PURE__*/function (_AbsIonContainerEvent3) { - (0, _inherits2["default"])(IonSexpEvent, _AbsIonContainerEvent3); - var _super14 = _createSuper(IonSexpEvent); - function IonSexpEvent(eventType, ionType, fieldName, annotations, depth) { - (0, _classCallCheck2["default"])(this, IonSexpEvent); - return _super14.call(this, eventType, ionType, fieldName, annotations, depth); - } - (0, _createClass2["default"])(IonSexpEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (!(expected instanceof IonSexpEvent)) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Event types don't match"); - } - var container = this.ionValue == null ? [] : this.ionValue; - var expectedContainer = expected.ionValue == null ? [] : expected.ionValue; - if (container.length !== expectedContainer.length) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "S-expression length don't match"); - } - for (var i = 0; i < container.length; i++) { - var child = container[i]; - var eventResult = child.compare(expectedContainer[i]); - if (eventResult.result == ComparisonResult_1.ComparisonResultType.NOT_EQUAL) { - return eventResult; - } else if (child.eventType === IonEventType.CONTAINER_START) { - i += child.ionValue.length; - } - } + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); + } + writeIonValue(writer) { + writer.writeDecimal(this.ionValue); + } +} +class IonSymbolEvent extends AbstractIonEvent { + constructor(eventType, ionType, fieldName, annotations, depth, ionValue) { + super(eventType, ionType, fieldName, annotations, depth, ionValue); + } + valueCompare(expected) { + if (expected instanceof IonSymbolEvent && this.ionValue === expected.ionValue) { return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); } - }]); - return IonSexpEvent; -}(AbsIonContainerEvent); -var IonEndEvent = /*#__PURE__*/function (_AbstractIonEvent12) { - (0, _inherits2["default"])(IonEndEvent, _AbstractIonEvent12); - var _super15 = _createSuper(IonEndEvent); - function IonEndEvent(eventType, depth, ionType) { - var _this; - (0, _classCallCheck2["default"])(this, IonEndEvent); - if (eventType === IonEventType.STREAM_END) { - _this = _super15.call(this, eventType, null, null, [], depth, undefined); - } else { - _this = _super15.call(this, eventType, ionType, null, [], depth, undefined); + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); + } + writeIonValue(writer) { + writer.writeSymbol(this.ionValue); + } +} +class IonStringEvent extends AbstractIonEvent { + constructor(eventType, ionType, fieldName, annotations, depth, ionValue) { + super(eventType, ionType, fieldName, annotations, depth, ionValue); + } + valueCompare(expected) { + if (expected instanceof IonStringEvent && this.ionValue === expected.ionValue) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); } - return (0, _possibleConstructorReturn2["default"])(_this); + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); } - (0, _createClass2["default"])(IonEndEvent, [{ - key: "valueCompare", - value: function valueCompare(expected) { - if (expected instanceof IonEndEvent && this.ionValue === expected.ionValue) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); + writeIonValue(writer) { + writer.writeString(this.ionValue); + } +} +class IonTimestampEvent extends AbstractIonEvent { + constructor(eventType, ionType, fieldName, annotations, depth, ionValue) { + super(eventType, ionType, fieldName, annotations, depth, ionValue); + } + valueCompare(expected) { + if (expected instanceof IonTimestampEvent && this.ionValue.equals(expected.ionValue)) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); + } + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); + } + writeIonValue(writer) { + writer.writeTimestamp(this.ionValue); + } +} +class IonBlobEvent extends AbstractIonEvent { + constructor(eventType, ionType, fieldName, annotations, depth, ionValue) { + super(eventType, ionType, fieldName, annotations, depth, ionValue); + } + valueCompare(expected) { + if (!(expected instanceof IonBlobEvent)) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL); + } + if (this.ionValue.length !== expected.ionValue.length) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Blob length don't match"); + } + for (let i = 0; i < this.ionValue.length; i++) { + if (this.ionValue[i] !== expected.ionValue[i]) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue[i] + " vs. " + expected.ionValue[i]); } + } + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); + } + writeIonValue(writer) { + writer.writeBlob(this.ionValue); + } +} +class IonClobEvent extends AbstractIonEvent { + constructor(eventType, ionType, fieldName, annotations, depth, ionValue) { + super(eventType, ionType, fieldName, annotations, depth, ionValue); + } + valueCompare(expected) { + if (!(expected instanceof IonClobEvent)) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL); + } + if (this.ionValue.length !== expected.ionValue.length) { return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); } - }, { - key: "writeIonValue", - value: function writeIonValue(writer) {} - }]); - return IonEndEvent; -}(AbstractIonEvent); - -},{"../ComparisonResult":3,"../IonBinaryWriter":8,"../IonLocalSymbolTable":13,"../IonTextWriter":26,"../IonTypes":29,"../IonUnicode":30,"../IonWriteable":31,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],54:[function(require,module,exports){ -"use strict"; - -/*! - * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.IonEventStream = void 0; -var ComparisonResult_1 = require("../ComparisonResult"); -var ComparisonResult_2 = require("../ComparisonResult"); -var Ion_1 = require("../Ion"); -var IonBinaryReader_1 = require("../IonBinaryReader"); -var IonSpan_1 = require("../IonSpan"); -var IonTypes_1 = require("../IonTypes"); -var EventStreamError_1 = require("./EventStreamError"); -var IonEvent_1 = require("./IonEvent"); -var READ = "READ"; -var WRITE = "WRITE"; -var IonEventStream = /*#__PURE__*/function () { - function IonEventStream(reader) { - (0, _classCallCheck2["default"])(this, IonEventStream); - this.events = []; - this.reader = reader; - this.eventFactory = new IonEvent_1.IonEventFactory(); - this.isEventStream = false; - this.generateStream(); + for (let i = 0; i < this.ionValue.length; i++) { + if (this.ionValue[i] !== expected.ionValue[i]) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue[i] + " vs. " + expected.ionValue[i]); + } + } + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); } - (0, _createClass2["default"])(IonEventStream, [{ - key: "writeEventStream", - value: function writeEventStream(writer) { - writer.writeSymbol("$ion_event_stream"); - for (var i = 0; i < this.events.length; i++) { - this.events[i].write(writer); - } - } - }, { - key: "writeIon", - value: function writeIon(writer) { - try { - var tempEvent; - var isEmbedded = false; - for (var indice = 0; indice < this.events.length; indice++) { - tempEvent = this.events[indice]; - if (tempEvent.fieldName !== null) { - writer.writeFieldName(tempEvent.fieldName); - } - if ((tempEvent.ionType == IonTypes_1.IonTypes.SEXP || tempEvent.ionType == IonTypes_1.IonTypes.LIST) && this.isEmbedded(tempEvent)) { - isEmbedded = true; + writeIonValue(writer) { + writer.writeClob(this.ionValue); + } +} +class AbsIonContainerEvent extends AbstractIonEvent { + constructor(eventType, ionType, fieldName, annotations, depth) { + super(eventType, ionType, fieldName, annotations, depth, null); + } + writeIonValue(writer) {} +} +class IonStructEvent extends AbsIonContainerEvent { + constructor(eventType, ionType, fieldName, annotations, depth) { + super(eventType, ionType, fieldName, annotations, depth); + } + valueCompare(expected) { + if (!(expected instanceof IonStructEvent)) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Event types don't match"); + } + const container = this.ionValue == null ? [] : this.ionValue; + const expectedContainer = expected.ionValue == null ? [] : expected.ionValue; + if (container.length !== expectedContainer.length) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Struct length don't match"); + } + return this.structsCompare(container, expectedContainer); + } + structsCompare(actualEvents, expectedEvents) { + let matchFound = new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); + const paired = new Array(expectedEvents.length); + for (let i = 0; matchFound && i < actualEvents.length; i++) { + matchFound.result = ComparisonResult_1.ComparisonResultType.NOT_EQUAL; + for (let j = 0; matchFound.result == ComparisonResult_1.ComparisonResultType.NOT_EQUAL && j < expectedEvents.length; j++) { + if (!paired[j]) { + const child = actualEvents[i]; + const expectedChild = expectedEvents[j]; + matchFound = child.compare(expectedChild); + if (matchFound.result == ComparisonResult_1.ComparisonResultType.EQUAL) { + paired[j] = true; } - writer.setAnnotations(tempEvent.annotations); - switch (tempEvent.eventType) { - case IonEvent_1.IonEventType.SCALAR: - if (tempEvent.ionValue == null) { - writer.writeNull(tempEvent.ionType); - return; - } - if (isEmbedded) { - writer.writeString(tempEvent.ionValue.toString()); - break; - } - switch (tempEvent.ionType) { - case IonTypes_1.IonTypes.BOOL: - writer.writeBoolean(tempEvent.ionValue); - break; - case IonTypes_1.IonTypes.STRING: - writer.writeString(tempEvent.ionValue); - break; - case IonTypes_1.IonTypes.SYMBOL: - writer.writeSymbol(tempEvent.ionValue); - break; - case IonTypes_1.IonTypes.INT: - writer.writeInt(tempEvent.ionValue); - break; - case IonTypes_1.IonTypes.DECIMAL: - writer.writeDecimal(tempEvent.ionValue); - break; - case IonTypes_1.IonTypes.FLOAT: - writer.writeFloat64(tempEvent.ionValue); - break; - case IonTypes_1.IonTypes.NULL: - writer.writeNull(tempEvent.ionType); - break; - case IonTypes_1.IonTypes.TIMESTAMP: - writer.writeTimestamp(tempEvent.ionValue); - break; - case IonTypes_1.IonTypes.CLOB: - writer.writeClob(tempEvent.ionValue); - break; - case IonTypes_1.IonTypes.BLOB: - writer.writeBlob(tempEvent.ionValue); - break; - default: - throw new Error("unexpected type: " + tempEvent.ionType.name); - } - break; - case IonEvent_1.IonEventType.CONTAINER_START: - writer.stepIn(tempEvent.ionType); - break; - case IonEvent_1.IonEventType.CONTAINER_END: - if (isEmbedded) { - isEmbedded = false; - } - writer.stepOut(); - break; - case IonEvent_1.IonEventType.STREAM_END: - break; - case IonEvent_1.IonEventType.SYMBOL_TABLE: - throw new Error("Symboltables unsupported."); - default: - throw new Error("Unexpected event type: " + tempEvent.eventType); + if (matchFound.result == ComparisonResult_1.ComparisonResultType.EQUAL && child.eventType === IonEventType.CONTAINER_START) { + for (let k = 0; k < expectedChild.ionValue.length; k++) { + paired[k + j + 1] = true; + } + i += child.ionValue.length; } } - writer.close(); - } catch (error) { - throw new EventStreamError_1.EventStreamError(WRITE, error.message, this.events.length, this.events); } } - }, { - key: "getEvents", - value: function getEvents() { - return this.events; + for (let i = 0; i < paired.length; i++) { + if (!paired[i]) { + matchFound = new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Didn't find matching field for " + expectedEvents[i].fieldName); + break; + } + } + return matchFound; + } +} +class IonListEvent extends AbsIonContainerEvent { + constructor(eventType, ionType, fieldName, annotations, depth) { + super(eventType, ionType, fieldName, annotations, depth); + } + valueCompare(expected) { + if (!(expected instanceof IonListEvent)) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Event types don't match"); } - }, { - key: "equals", - value: function equals(expected) { - return this.compare(expected).result == ComparisonResult_2.ComparisonResultType.EQUAL; + const container = this.ionValue == null ? [] : this.ionValue; + const expectedContainer = expected.ionValue == null ? [] : expected.ionValue; + if (container.length !== expectedContainer.length) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "List length don't match"); } - }, { - key: "compare", - value: function compare(expected) { - var actualIndex = 0; - var expectedIndex = 0; - if (this.events.length != expected.events.length) { - return new ComparisonResult_1.ComparisonResult(ComparisonResult_2.ComparisonResultType.NOT_EQUAL, "The event streams have different lengths"); + for (let i = 0; i < container.length; i++) { + const child = container[i]; + if (child.compare(expectedContainer[i]).result == ComparisonResult_1.ComparisonResultType.NOT_EQUAL) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, `${child.ionValue} vs. ${expectedContainer[i].ionValue}`, i + 1, i + 1); + } else if (child.eventType === IonEventType.CONTAINER_START) { + i += child.ionValue.length; } - while (actualIndex < this.events.length && expectedIndex < expected.events.length) { - var actualEvent = this.events[actualIndex]; - var expectedEvent = expected.events[expectedIndex]; - if (actualEvent.eventType === IonEvent_1.IonEventType.SYMBOL_TABLE) { - actualIndex++; - } - if (expectedEvent.eventType === IonEvent_1.IonEventType.SYMBOL_TABLE) { - expectedIndex++; - } - if (actualEvent.eventType === IonEvent_1.IonEventType.SYMBOL_TABLE || expectedEvent.eventType === IonEvent_1.IonEventType.SYMBOL_TABLE) { - continue; - } - switch (actualEvent.eventType) { - case IonEvent_1.IonEventType.SCALAR: - { - var eventResult = actualEvent.compare(expectedEvent); - if (eventResult.result == ComparisonResult_2.ComparisonResultType.NOT_EQUAL) { - eventResult.actualIndex = actualIndex; - eventResult.expectedIndex = expectedIndex; - return eventResult; - } - break; - } - case IonEvent_1.IonEventType.CONTAINER_START: - { - var _eventResult = actualEvent.compare(expectedEvent); - if (_eventResult.result == ComparisonResult_2.ComparisonResultType.NOT_EQUAL) { - actualIndex += _eventResult.actualIndex; - expectedIndex += _eventResult.expectedIndex; - _eventResult.actualIndex = actualIndex; - _eventResult.expectedIndex = expectedIndex; - return _eventResult; - } else { - if (actualEvent.ionValue !== null && expectedEvent.ionValue !== null) { - actualIndex = actualIndex + actualEvent.ionValue.length; - expectedIndex = expectedIndex + expectedEvent.ionValue.length; - } - } - break; - } - case IonEvent_1.IonEventType.CONTAINER_END: - case IonEvent_1.IonEventType.STREAM_END: - { - break; - } - default: - { - throw new Error("Unexpected event type: " + actualEvent.eventType); - } - } - actualIndex++; - expectedIndex++; - } - return new ComparisonResult_1.ComparisonResult(ComparisonResult_2.ComparisonResultType.EQUAL); } - }, { - key: "isEmbedded", - value: function isEmbedded(event) { - if (event.annotations[0] === "embedded_documents") { - return true; - } - return false; + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); + } +} +class IonSexpEvent extends AbsIonContainerEvent { + constructor(eventType, ionType, fieldName, annotations, depth) { + super(eventType, ionType, fieldName, annotations, depth); + } + valueCompare(expected) { + if (!(expected instanceof IonSexpEvent)) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "Event types don't match"); + } + const container = this.ionValue == null ? [] : this.ionValue; + const expectedContainer = expected.ionValue == null ? [] : expected.ionValue; + if (container.length !== expectedContainer.length) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, "S-expression length don't match"); } - }, { - key: "generateStream", - value: function generateStream() { - try { - var tid = this.reader.next(); - if (tid === IonTypes_1.IonTypes.SYMBOL && this.reader.stringValue() === "$ion_event_stream") { - this.marshalStream(); - this.isEventStream = true; - return; - } - var currentContainer = []; - var currentContainerIndex = []; - while (true) { - if (this.reader.isNull()) { - this.events.push(this.eventFactory.makeEvent(IonEvent_1.IonEventType.SCALAR, tid, this.reader.fieldName(), this.reader.depth(), this.reader.annotations(), true, this.reader.value())); - } else { - switch (tid) { - case IonTypes_1.IonTypes.LIST: - case IonTypes_1.IonTypes.SEXP: - case IonTypes_1.IonTypes.STRUCT: - { - var containerEvent = this.eventFactory.makeEvent(IonEvent_1.IonEventType.CONTAINER_START, tid, this.reader.fieldName(), this.reader.depth(), this.reader.annotations(), false, null); - this.events.push(containerEvent); - currentContainer.push(containerEvent); - currentContainerIndex.push(this.events.length); - this.reader.stepIn(); - break; - } - case null: - { - if (this.reader.depth() === 0) { - this.events.push(this.eventFactory.makeEvent(IonEvent_1.IonEventType.STREAM_END, IonTypes_1.IonTypes.NULL, null, this.reader.depth(), [], false, undefined)); - return; - } else { - this.reader.stepOut(); - this.endContainer(currentContainer.pop(), currentContainerIndex.pop()); - } - break; - } - default: - { - this.events.push(this.eventFactory.makeEvent(IonEvent_1.IonEventType.SCALAR, tid, this.reader.fieldName(), this.reader.depth(), this.reader.annotations(), false, this.reader.value())); - break; - } - } - } - tid = this.reader.next(); - } - } catch (error) { - throw new EventStreamError_1.EventStreamError(READ, error.message, this.events.length, this.events); - } - } - }, { - key: "endContainer", - value: function endContainer(thisContainer, thisContainerIndex) { - this.events.push(this.eventFactory.makeEvent(IonEvent_1.IonEventType.CONTAINER_END, thisContainer.ionType, null, thisContainer.depth, [], false, null)); - thisContainer.ionValue = this.events.slice(thisContainerIndex, this.events.length); - } - }, { - key: "marshalStream", - value: function marshalStream() { - this.events = []; - var currentContainer = []; - var currentContainerIndex = []; - for (var tid = this.reader.next(); tid === IonTypes_1.IonTypes.STRUCT; tid = this.reader.next()) { - this.reader.stepIn(); - var tempEvent = this.marshalEvent(); - if (tempEvent.eventType === IonEvent_1.IonEventType.CONTAINER_START) { - currentContainer.push(tempEvent); - this.events.push(tempEvent); - currentContainerIndex.push(this.events.length); - } else if (tempEvent.eventType === IonEvent_1.IonEventType.CONTAINER_END) { - this.endContainer(currentContainer.pop(), currentContainerIndex.pop()); - } else if (tempEvent.eventType === IonEvent_1.IonEventType.SCALAR || tempEvent.eventType === IonEvent_1.IonEventType.STREAM_END) { - this.events.push(tempEvent); - } else { - throw new Error("Unexpected eventType: " + tempEvent.eventType); - } - this.reader.stepOut(); + for (let i = 0; i < container.length; i++) { + const child = container[i]; + const eventResult = child.compare(expectedContainer[i]); + if (eventResult.result == ComparisonResult_1.ComparisonResultType.NOT_EQUAL) { + return eventResult; + } else if (child.eventType === IonEventType.CONTAINER_START) { + i += child.ionValue.length; } } - }, { - key: "marshalEvent", - value: function marshalEvent() { - var currentEvent = {}; - for (var tid; tid = this.reader.next();) { - var fieldName = this.reader.fieldName(); - if (fieldName && currentEvent[fieldName] !== undefined) { - throw new Error("Repeated event field: " + fieldName); - } - switch (fieldName) { - case "event_type": - { - currentEvent[fieldName] = this.reader.stringValue(); - break; - } - case "ion_type": - { - currentEvent[fieldName] = this.parseIonType(); - break; - } - case "field_name": - { - currentEvent[fieldName] = this.resolveFieldNameFromSerializedSymbolToken(); - break; - } - case "annotations": - { - currentEvent[fieldName] = this.parseAnnotations(); - break; - } - case "value_text": - { - var tempString = this.reader.stringValue(); - if (tempString.substr(0, 5) === "$ion_") { - tempString = "$ion_user_value::" + tempString; - } - var tempReader = Ion_1.makeReader(tempString); - tempReader.next(); - var tempValue = tempReader.value(); - currentEvent["isNull"] = tempReader.isNull(); - currentEvent[fieldName] = tempValue; - break; + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); + } +} +class IonEndEvent extends AbstractIonEvent { + constructor(eventType, depth, ionType) { + if (eventType === IonEventType.STREAM_END) { + super(eventType, null, null, [], depth, undefined); + } else { + super(eventType, ionType, null, [], depth, undefined); + } + } + valueCompare(expected) { + if (expected instanceof IonEndEvent && this.ionValue === expected.ionValue) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.EQUAL); + } + return new ComparisonResult_1.ComparisonResult(ComparisonResult_1.ComparisonResultType.NOT_EQUAL, this.ionValue + " vs. " + expected.ionValue); + } + writeIonValue(writer) {} +} + +},{"../ComparisonResult":3,"../IonBinaryWriter":8,"../IonLocalSymbolTable":13,"../IonTextWriter":26,"../IonTypes":29,"../IonUnicode":30,"../IonWriteable":31}],54:[function(require,module,exports){ +"use strict"; + +/*! + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.IonEventStream = void 0; +const ComparisonResult_1 = require("../ComparisonResult"); +const ComparisonResult_2 = require("../ComparisonResult"); +const Ion_1 = require("../Ion"); +const IonBinaryReader_1 = require("../IonBinaryReader"); +const IonSpan_1 = require("../IonSpan"); +const IonTypes_1 = require("../IonTypes"); +const EventStreamError_1 = require("./EventStreamError"); +const IonEvent_1 = require("./IonEvent"); +const READ = "READ"; +const WRITE = "WRITE"; +class IonEventStream { + constructor(reader) { + this.events = []; + this.reader = reader; + this.eventFactory = new IonEvent_1.IonEventFactory(); + this.isEventStream = false; + this.generateStream(); + } + writeEventStream(writer) { + writer.writeSymbol("$ion_event_stream"); + for (let i = 0; i < this.events.length; i++) { + this.events[i].write(writer); + } + } + writeIon(writer) { + try { + let tempEvent; + let isEmbedded = false; + for (let indice = 0; indice < this.events.length; indice++) { + tempEvent = this.events[indice]; + if (tempEvent.fieldName !== null) { + writer.writeFieldName(tempEvent.fieldName); + } + if ((tempEvent.ionType == IonTypes_1.IonTypes.SEXP || tempEvent.ionType == IonTypes_1.IonTypes.LIST) && this.isEmbedded(tempEvent)) { + isEmbedded = true; + } + writer.setAnnotations(tempEvent.annotations); + switch (tempEvent.eventType) { + case IonEvent_1.IonEventType.SCALAR: + if (tempEvent.ionValue == null) { + writer.writeNull(tempEvent.ionType); + return; } - case "value_binary": - { - currentEvent[fieldName] = this.parseBinaryValue(); + if (isEmbedded) { + writer.writeString(tempEvent.ionValue.toString()); break; } - case "imports": - { - currentEvent[fieldName] = this.parseImports(); - break; + switch (tempEvent.ionType) { + case IonTypes_1.IonTypes.BOOL: + writer.writeBoolean(tempEvent.ionValue); + break; + case IonTypes_1.IonTypes.STRING: + writer.writeString(tempEvent.ionValue); + break; + case IonTypes_1.IonTypes.SYMBOL: + writer.writeSymbol(tempEvent.ionValue); + break; + case IonTypes_1.IonTypes.INT: + writer.writeInt(tempEvent.ionValue); + break; + case IonTypes_1.IonTypes.DECIMAL: + writer.writeDecimal(tempEvent.ionValue); + break; + case IonTypes_1.IonTypes.FLOAT: + writer.writeFloat64(tempEvent.ionValue); + break; + case IonTypes_1.IonTypes.NULL: + writer.writeNull(tempEvent.ionType); + break; + case IonTypes_1.IonTypes.TIMESTAMP: + writer.writeTimestamp(tempEvent.ionValue); + break; + case IonTypes_1.IonTypes.CLOB: + writer.writeClob(tempEvent.ionValue); + break; + case IonTypes_1.IonTypes.BLOB: + writer.writeBlob(tempEvent.ionValue); + break; + default: + throw new Error("unexpected type: " + tempEvent.ionType.name); } - case "depth": - { - currentEvent[fieldName] = this.reader.numberValue(); - break; + break; + case IonEvent_1.IonEventType.CONTAINER_START: + writer.stepIn(tempEvent.ionType); + break; + case IonEvent_1.IonEventType.CONTAINER_END: + if (isEmbedded) { + isEmbedded = false; } + writer.stepOut(); + break; + case IonEvent_1.IonEventType.STREAM_END: + break; + case IonEvent_1.IonEventType.SYMBOL_TABLE: + throw new Error("Symboltables unsupported."); default: - throw new Error("Unexpected event field: " + fieldName); + throw new Error("Unexpected event type: " + tempEvent.eventType); } } - var eventType; - switch (currentEvent["event_type"]) { - case "CONTAINER_START": - eventType = IonEvent_1.IonEventType.CONTAINER_START; - break; - case "STREAM_END": - eventType = IonEvent_1.IonEventType.STREAM_END; - break; - case "CONTAINER_END": - eventType = IonEvent_1.IonEventType.CONTAINER_END; - break; - case "SCALAR": - eventType = IonEvent_1.IonEventType.SCALAR; - break; - case "SYMBOL_TABLE": - throw new Error("Symbol tables unsupported"); + writer.close(); + } catch (error) { + throw new EventStreamError_1.EventStreamError(WRITE, error.message, this.events.length, this.events); + } + } + getEvents() { + return this.events; + } + equals(expected) { + return this.compare(expected).result == ComparisonResult_2.ComparisonResultType.EQUAL; + } + compare(expected) { + let actualIndex = 0; + let expectedIndex = 0; + if (this.events.length != expected.events.length) { + return new ComparisonResult_1.ComparisonResult(ComparisonResult_2.ComparisonResultType.NOT_EQUAL, "The event streams have different lengths"); + } + while (actualIndex < this.events.length && expectedIndex < expected.events.length) { + const actualEvent = this.events[actualIndex]; + const expectedEvent = expected.events[expectedIndex]; + if (actualEvent.eventType === IonEvent_1.IonEventType.SYMBOL_TABLE) { + actualIndex++; } - var fieldname = currentEvent["field_name"] !== undefined ? currentEvent["field_name"] : null; - if (!currentEvent["annotations"]) { - currentEvent["annotations"] = []; + if (expectedEvent.eventType === IonEvent_1.IonEventType.SYMBOL_TABLE) { + expectedIndex++; } - var textEvent = this.eventFactory.makeEvent(eventType, currentEvent["ion_type"], fieldname, currentEvent["depth"], currentEvent["annotations"], currentEvent["isNull"], currentEvent["value_text"]); - if (eventType === IonEvent_1.IonEventType.SCALAR) { - var binaryEvent = this.eventFactory.makeEvent(eventType, currentEvent["ion_type"], fieldname, currentEvent["depth"], currentEvent["annotations"], currentEvent["isNull"], currentEvent["value_binary"]); - if (!textEvent.equals(binaryEvent)) { - throw new Error("Text event ".concat(currentEvent["value_text"], " does not equal binary event ").concat(currentEvent["value_binary"])); - } + if (actualEvent.eventType === IonEvent_1.IonEventType.SYMBOL_TABLE || expectedEvent.eventType === IonEvent_1.IonEventType.SYMBOL_TABLE) { + continue; } - return textEvent; - } - }, { - key: "parseIonType", - value: function parseIonType() { - var input = this.reader.stringValue().toLowerCase(); - switch (input) { - case "null": + switch (actualEvent.eventType) { + case IonEvent_1.IonEventType.SCALAR: { - return IonTypes_1.IonTypes.NULL; + const eventResult = actualEvent.compare(expectedEvent); + if (eventResult.result == ComparisonResult_2.ComparisonResultType.NOT_EQUAL) { + eventResult.actualIndex = actualIndex; + eventResult.expectedIndex = expectedIndex; + return eventResult; + } + break; } - case "bool": + case IonEvent_1.IonEventType.CONTAINER_START: { - return IonTypes_1.IonTypes.BOOL; + const eventResult = actualEvent.compare(expectedEvent); + if (eventResult.result == ComparisonResult_2.ComparisonResultType.NOT_EQUAL) { + actualIndex += eventResult.actualIndex; + expectedIndex += eventResult.expectedIndex; + eventResult.actualIndex = actualIndex; + eventResult.expectedIndex = expectedIndex; + return eventResult; + } else { + if (actualEvent.ionValue !== null && expectedEvent.ionValue !== null) { + actualIndex = actualIndex + actualEvent.ionValue.length; + expectedIndex = expectedIndex + expectedEvent.ionValue.length; + } + } + break; } - case "int": + case IonEvent_1.IonEventType.CONTAINER_END: + case IonEvent_1.IonEventType.STREAM_END: { - return IonTypes_1.IonTypes.INT; + break; } - case "float": + default: { - return IonTypes_1.IonTypes.FLOAT; + throw new Error("Unexpected event type: " + actualEvent.eventType); } - case "decimal": - { - return IonTypes_1.IonTypes.DECIMAL; + } + actualIndex++; + expectedIndex++; + } + return new ComparisonResult_1.ComparisonResult(ComparisonResult_2.ComparisonResultType.EQUAL); + } + isEmbedded(event) { + if (event.annotations[0] === "embedded_documents") { + return true; + } + return false; + } + generateStream() { + try { + let tid = this.reader.next(); + if (tid === IonTypes_1.IonTypes.SYMBOL && this.reader.stringValue() === "$ion_event_stream") { + this.marshalStream(); + this.isEventStream = true; + return; + } + const currentContainer = []; + const currentContainerIndex = []; + while (true) { + if (this.reader.isNull()) { + this.events.push(this.eventFactory.makeEvent(IonEvent_1.IonEventType.SCALAR, tid, this.reader.fieldName(), this.reader.depth(), this.reader.annotations(), true, this.reader.value())); + } else { + switch (tid) { + case IonTypes_1.IonTypes.LIST: + case IonTypes_1.IonTypes.SEXP: + case IonTypes_1.IonTypes.STRUCT: + { + const containerEvent = this.eventFactory.makeEvent(IonEvent_1.IonEventType.CONTAINER_START, tid, this.reader.fieldName(), this.reader.depth(), this.reader.annotations(), false, null); + this.events.push(containerEvent); + currentContainer.push(containerEvent); + currentContainerIndex.push(this.events.length); + this.reader.stepIn(); + break; + } + case null: + { + if (this.reader.depth() === 0) { + this.events.push(this.eventFactory.makeEvent(IonEvent_1.IonEventType.STREAM_END, IonTypes_1.IonTypes.NULL, null, this.reader.depth(), [], false, undefined)); + return; + } else { + this.reader.stepOut(); + this.endContainer(currentContainer.pop(), currentContainerIndex.pop()); + } + break; + } + default: + { + this.events.push(this.eventFactory.makeEvent(IonEvent_1.IonEventType.SCALAR, tid, this.reader.fieldName(), this.reader.depth(), this.reader.annotations(), false, this.reader.value())); + break; + } } - case "timestamp": + } + tid = this.reader.next(); + } + } catch (error) { + throw new EventStreamError_1.EventStreamError(READ, error.message, this.events.length, this.events); + } + } + endContainer(thisContainer, thisContainerIndex) { + this.events.push(this.eventFactory.makeEvent(IonEvent_1.IonEventType.CONTAINER_END, thisContainer.ionType, null, thisContainer.depth, [], false, null)); + thisContainer.ionValue = this.events.slice(thisContainerIndex, this.events.length); + } + marshalStream() { + this.events = []; + const currentContainer = []; + const currentContainerIndex = []; + for (let tid = this.reader.next(); tid === IonTypes_1.IonTypes.STRUCT; tid = this.reader.next()) { + this.reader.stepIn(); + const tempEvent = this.marshalEvent(); + if (tempEvent.eventType === IonEvent_1.IonEventType.CONTAINER_START) { + currentContainer.push(tempEvent); + this.events.push(tempEvent); + currentContainerIndex.push(this.events.length); + } else if (tempEvent.eventType === IonEvent_1.IonEventType.CONTAINER_END) { + this.endContainer(currentContainer.pop(), currentContainerIndex.pop()); + } else if (tempEvent.eventType === IonEvent_1.IonEventType.SCALAR || tempEvent.eventType === IonEvent_1.IonEventType.STREAM_END) { + this.events.push(tempEvent); + } else { + throw new Error("Unexpected eventType: " + tempEvent.eventType); + } + this.reader.stepOut(); + } + } + marshalEvent() { + const currentEvent = {}; + for (let tid; tid = this.reader.next();) { + const fieldName = this.reader.fieldName(); + if (fieldName && currentEvent[fieldName] !== undefined) { + throw new Error("Repeated event field: " + fieldName); + } + switch (fieldName) { + case "event_type": { - return IonTypes_1.IonTypes.TIMESTAMP; + currentEvent[fieldName] = this.reader.stringValue(); + break; } - case "symbol": + case "ion_type": { - return IonTypes_1.IonTypes.SYMBOL; + currentEvent[fieldName] = this.parseIonType(); + break; } - case "string": + case "field_name": { - return IonTypes_1.IonTypes.STRING; + currentEvent[fieldName] = this.resolveFieldNameFromSerializedSymbolToken(); + break; } - case "clob": + case "annotations": { - return IonTypes_1.IonTypes.CLOB; + currentEvent[fieldName] = this.parseAnnotations(); + break; } - case "blob": + case "value_text": { - return IonTypes_1.IonTypes.BLOB; + let tempString = this.reader.stringValue(); + if (tempString.substr(0, 5) === "$ion_") { + tempString = "$ion_user_value::" + tempString; + } + const tempReader = Ion_1.makeReader(tempString); + tempReader.next(); + const tempValue = tempReader.value(); + currentEvent["isNull"] = tempReader.isNull(); + currentEvent[fieldName] = tempValue; + break; } - case "list": + case "value_binary": { - return IonTypes_1.IonTypes.LIST; + currentEvent[fieldName] = this.parseBinaryValue(); + break; } - case "sexp": + case "imports": { - return IonTypes_1.IonTypes.SEXP; + currentEvent[fieldName] = this.parseImports(); + break; } - case "struct": + case "depth": { - return IonTypes_1.IonTypes.STRUCT; + currentEvent[fieldName] = this.reader.numberValue(); + break; } default: - { - throw new Error("i: " + input); - } + throw new Error("Unexpected event field: " + fieldName); } } - }, { - key: "parseAnnotations", - value: function parseAnnotations() { - var annotations = []; - if (this.reader.isNull()) { - return annotations; - } else { - this.reader.stepIn(); - for (var tid; tid = this.reader.next();) { - if (tid == IonTypes_1.IonTypes.STRUCT) { - this.reader.stepIn(); - var type = this.reader.next(); - if (this.reader.fieldName() == "text" && type == IonTypes_1.IonTypes.STRING) { - var text = this.reader.stringValue(); - if (text !== null) { - annotations.push(text); - } - } else if (this.reader.fieldName() == "importLocation" && type == IonTypes_1.IonTypes.INT) { - var symtab = Ion_1.defaultLocalSymbolTable(); - var symbol = symtab.getSymbolText(this.reader.numberValue()); - if (symbol === undefined || symbol === null) { - throw new Error("Unresolvable symbol ID, symboltokens unsupported."); - } - annotations.push(symbol); + let eventType; + switch (currentEvent["event_type"]) { + case "CONTAINER_START": + eventType = IonEvent_1.IonEventType.CONTAINER_START; + break; + case "STREAM_END": + eventType = IonEvent_1.IonEventType.STREAM_END; + break; + case "CONTAINER_END": + eventType = IonEvent_1.IonEventType.CONTAINER_END; + break; + case "SCALAR": + eventType = IonEvent_1.IonEventType.SCALAR; + break; + case "SYMBOL_TABLE": + throw new Error("Symbol tables unsupported"); + } + const fieldname = currentEvent["field_name"] !== undefined ? currentEvent["field_name"] : null; + if (!currentEvent["annotations"]) { + currentEvent["annotations"] = []; + } + const textEvent = this.eventFactory.makeEvent(eventType, currentEvent["ion_type"], fieldname, currentEvent["depth"], currentEvent["annotations"], currentEvent["isNull"], currentEvent["value_text"]); + if (eventType === IonEvent_1.IonEventType.SCALAR) { + const binaryEvent = this.eventFactory.makeEvent(eventType, currentEvent["ion_type"], fieldname, currentEvent["depth"], currentEvent["annotations"], currentEvent["isNull"], currentEvent["value_binary"]); + if (!textEvent.equals(binaryEvent)) { + throw new Error(`Text event ${currentEvent["value_text"]} does not equal binary event ${currentEvent["value_binary"]}`); + } + } + return textEvent; + } + parseIonType() { + const input = this.reader.stringValue().toLowerCase(); + switch (input) { + case "null": + { + return IonTypes_1.IonTypes.NULL; + } + case "bool": + { + return IonTypes_1.IonTypes.BOOL; + } + case "int": + { + return IonTypes_1.IonTypes.INT; + } + case "float": + { + return IonTypes_1.IonTypes.FLOAT; + } + case "decimal": + { + return IonTypes_1.IonTypes.DECIMAL; + } + case "timestamp": + { + return IonTypes_1.IonTypes.TIMESTAMP; + } + case "symbol": + { + return IonTypes_1.IonTypes.SYMBOL; + } + case "string": + { + return IonTypes_1.IonTypes.STRING; + } + case "clob": + { + return IonTypes_1.IonTypes.CLOB; + } + case "blob": + { + return IonTypes_1.IonTypes.BLOB; + } + case "list": + { + return IonTypes_1.IonTypes.LIST; + } + case "sexp": + { + return IonTypes_1.IonTypes.SEXP; + } + case "struct": + { + return IonTypes_1.IonTypes.STRUCT; + } + default: + { + throw new Error("i: " + input); + } + } + } + parseAnnotations() { + const annotations = []; + if (this.reader.isNull()) { + return annotations; + } else { + this.reader.stepIn(); + for (let tid; tid = this.reader.next();) { + if (tid == IonTypes_1.IonTypes.STRUCT) { + this.reader.stepIn(); + const type = this.reader.next(); + if (this.reader.fieldName() == "text" && type == IonTypes_1.IonTypes.STRING) { + const text = this.reader.stringValue(); + if (text !== null) { + annotations.push(text); + } + } else if (this.reader.fieldName() == "importLocation" && type == IonTypes_1.IonTypes.INT) { + const symtab = Ion_1.defaultLocalSymbolTable(); + const symbol = symtab.getSymbolText(this.reader.numberValue()); + if (symbol === undefined || symbol === null) { + throw new Error("Unresolvable symbol ID, symboltokens unsupported."); } - this.reader.stepOut(); + annotations.push(symbol); } + this.reader.stepOut(); } - this.reader.stepOut(); - return annotations; } + this.reader.stepOut(); + return annotations; } - }, { - key: "parseBinaryValue", - value: function parseBinaryValue() { - if (this.reader.isNull()) { - return null; + } + parseBinaryValue() { + if (this.reader.isNull()) { + return null; + } + const numBuffer = []; + this.reader.stepIn(); + let tid = this.reader.next(); + while (tid) { + numBuffer.push(this.reader.numberValue()); + tid = this.reader.next(); + } + this.reader.stepOut(); + const bufArray = new Uint8Array(numBuffer); + const tempReader = new IonBinaryReader_1.BinaryReader(new IonSpan_1.BinarySpan(bufArray)); + tempReader.next(); + return tempReader.value(); + } + parseImports() { + return this.reader.value(); + } + resolveFieldNameFromSerializedSymbolToken() { + if (this.reader.isNull()) { + return null; + } + this.reader.stepIn(); + const type = this.reader.next(); + if (this.reader.fieldName() == "text" && type == IonTypes_1.IonTypes.STRING) { + const text = this.reader.stringValue(); + if (text !== null) { + this.reader.stepOut(); + return text; } - var numBuffer = []; - this.reader.stepIn(); - var tid = this.reader.next(); - while (tid) { - numBuffer.push(this.reader.numberValue()); - tid = this.reader.next(); + } else if (this.reader.fieldName() == "importLocation" && type == IonTypes_1.IonTypes.INT) { + const symtab = Ion_1.defaultLocalSymbolTable(); + const symbol = symtab.getSymbolText(this.reader.numberValue()); + if (symbol === undefined || symbol === null) { + throw new Error("Unresolvable symbol ID, symboltokens unsupported."); } this.reader.stepOut(); - var bufArray = new Uint8Array(numBuffer); - var tempReader = new IonBinaryReader_1.BinaryReader(new IonSpan_1.BinarySpan(bufArray)); - tempReader.next(); - return tempReader.value(); - } - }, { - key: "parseImports", - value: function parseImports() { - return this.reader.value(); - } - }, { - key: "resolveFieldNameFromSerializedSymbolToken", - value: function resolveFieldNameFromSerializedSymbolToken() { - if (this.reader.isNull()) { - return null; - } - this.reader.stepIn(); - var type = this.reader.next(); - if (this.reader.fieldName() == "text" && type == IonTypes_1.IonTypes.STRING) { - var text = this.reader.stringValue(); - if (text !== null) { - this.reader.stepOut(); - return text; - } - } else if (this.reader.fieldName() == "importLocation" && type == IonTypes_1.IonTypes.INT) { - var symtab = Ion_1.defaultLocalSymbolTable(); - var symbol = symtab.getSymbolText(this.reader.numberValue()); - if (symbol === undefined || symbol === null) { - throw new Error("Unresolvable symbol ID, symboltokens unsupported."); - } - this.reader.stepOut(); - return symbol; - } - return null; + return symbol; } - }]); - return IonEventStream; -}(); + return null; + } +} exports.IonEventStream = IonEventStream; -},{"../ComparisonResult":3,"../Ion":5,"../IonBinaryReader":7,"../IonSpan":19,"../IonTypes":29,"./EventStreamError":52,"./IonEvent":53,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],55:[function(require,module,exports){ +},{"../ComparisonResult":3,"../Ion":5,"../IonBinaryReader":7,"../IonSpan":19,"../IonTypes":29,"./EventStreamError":52,"./IonEvent":53}],55:[function(require,module,exports){ "use strict"; /*! @@ -11770,95 +9820,6 @@ function isSafeInteger(value) { exports.isSafeInteger = isSafeInteger; },{}],56:[function(require,module,exports){ -function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - return arr2; -} -module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],57:[function(require,module,exports){ -function _arrayWithHoles(arr) { - if (Array.isArray(arr)) return arr; -} -module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],58:[function(require,module,exports){ -var arrayLikeToArray = require("./arrayLikeToArray.js"); -function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) return arrayLikeToArray(arr); -} -module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./arrayLikeToArray.js":56}],59:[function(require,module,exports){ -function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - return self; -} -module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],60:[function(require,module,exports){ -function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -} -module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],61:[function(require,module,exports){ -var setPrototypeOf = require("./setPrototypeOf.js"); -var isNativeReflectConstruct = require("./isNativeReflectConstruct.js"); -function _construct(Parent, args, Class) { - if (isNativeReflectConstruct()) { - module.exports = _construct = Reflect.construct.bind(), module.exports.__esModule = true, module.exports["default"] = module.exports; - } else { - module.exports = _construct = function _construct(Parent, args, Class) { - var a = [null]; - a.push.apply(a, args); - var Constructor = Function.bind.apply(Parent, a); - var instance = new Constructor(); - if (Class) setPrototypeOf(instance, Class.prototype); - return instance; - }, module.exports.__esModule = true, module.exports["default"] = module.exports; - } - return _construct.apply(null, arguments); -} -module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./isNativeReflectConstruct.js":70,"./setPrototypeOf.js":76}],62:[function(require,module,exports){ -var toPropertyKey = require("./toPropertyKey.js"); -function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor); - } -} -function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - Object.defineProperty(Constructor, "prototype", { - writable: false - }); - return Constructor; -} -module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./toPropertyKey.js":81}],63:[function(require,module,exports){ -var toPropertyKey = require("./toPropertyKey.js"); -function _defineProperty(obj, key, value) { - key = toPropertyKey(key); - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; -} -module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./toPropertyKey.js":81}],64:[function(require,module,exports){ function _extends() { module.exports = _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { @@ -11874,244 +9835,12 @@ function _extends() { return _extends.apply(this, arguments); } module.exports = _extends, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],65:[function(require,module,exports){ -var superPropBase = require("./superPropBase.js"); -function _get() { - if (typeof Reflect !== "undefined" && Reflect.get) { - module.exports = _get = Reflect.get.bind(), module.exports.__esModule = true, module.exports["default"] = module.exports; - } else { - module.exports = _get = function _get(target, property, receiver) { - var base = superPropBase(target, property); - if (!base) return; - var desc = Object.getOwnPropertyDescriptor(base, property); - if (desc.get) { - return desc.get.call(arguments.length < 3 ? target : receiver); - } - return desc.value; - }, module.exports.__esModule = true, module.exports["default"] = module.exports; - } - return _get.apply(this, arguments); -} -module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./superPropBase.js":78}],66:[function(require,module,exports){ -function _getPrototypeOf(o) { - module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }, module.exports.__esModule = true, module.exports["default"] = module.exports; - return _getPrototypeOf(o); -} -module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],67:[function(require,module,exports){ -var setPrototypeOf = require("./setPrototypeOf.js"); -function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - Object.defineProperty(subClass, "prototype", { - writable: false - }); - if (superClass) setPrototypeOf(subClass, superClass); -} -module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./setPrototypeOf.js":76}],68:[function(require,module,exports){ +},{}],57:[function(require,module,exports){ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],69:[function(require,module,exports){ -function _isNativeFunction(fn) { - return Function.toString.call(fn).indexOf("[native code]") !== -1; -} -module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],70:[function(require,module,exports){ -function _isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - try { - Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); - return true; - } catch (e) { - return false; - } -} -module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],71:[function(require,module,exports){ -function _iterableToArray(iter) { - if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); -} -module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],72:[function(require,module,exports){ -function _iterableToArrayLimit(r, l) { - var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; - if (null != t) { - var e, - n, - i, - u, - a = [], - f = !0, - o = !1; - try { - if (i = (t = t.call(r)).next, 0 === l) { - if (Object(t) !== t) return; - f = !1; - } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); - } catch (r) { - o = !0, n = r; - } finally { - try { - if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; - } finally { - if (o) throw n; - } - } - return a; - } -} -module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],73:[function(require,module,exports){ -function _nonIterableRest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} -module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],74:[function(require,module,exports){ -function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} -module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],75:[function(require,module,exports){ -var _typeof = require("./typeof.js")["default"]; -var assertThisInitialized = require("./assertThisInitialized.js"); -function _possibleConstructorReturn(self, call) { - if (call && (_typeof(call) === "object" || typeof call === "function")) { - return call; - } else if (call !== void 0) { - throw new TypeError("Derived constructors may only return object or undefined"); - } - return assertThisInitialized(self); -} -module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./assertThisInitialized.js":59,"./typeof.js":82}],76:[function(require,module,exports){ -function _setPrototypeOf(o, p) { - module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }, module.exports.__esModule = true, module.exports["default"] = module.exports; - return _setPrototypeOf(o, p); -} -module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],77:[function(require,module,exports){ -var arrayWithHoles = require("./arrayWithHoles.js"); -var iterableToArrayLimit = require("./iterableToArrayLimit.js"); -var unsupportedIterableToArray = require("./unsupportedIterableToArray.js"); -var nonIterableRest = require("./nonIterableRest.js"); -function _slicedToArray(arr, i) { - return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest(); -} -module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./arrayWithHoles.js":57,"./iterableToArrayLimit.js":72,"./nonIterableRest.js":73,"./unsupportedIterableToArray.js":83}],78:[function(require,module,exports){ -var getPrototypeOf = require("./getPrototypeOf.js"); -function _superPropBase(object, property) { - while (!Object.prototype.hasOwnProperty.call(object, property)) { - object = getPrototypeOf(object); - if (object === null) break; - } - return object; -} -module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./getPrototypeOf.js":66}],79:[function(require,module,exports){ -var arrayWithoutHoles = require("./arrayWithoutHoles.js"); -var iterableToArray = require("./iterableToArray.js"); -var unsupportedIterableToArray = require("./unsupportedIterableToArray.js"); -var nonIterableSpread = require("./nonIterableSpread.js"); -function _toConsumableArray(arr) { - return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread(); -} -module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./arrayWithoutHoles.js":58,"./iterableToArray.js":71,"./nonIterableSpread.js":74,"./unsupportedIterableToArray.js":83}],80:[function(require,module,exports){ -var _typeof = require("./typeof.js")["default"]; -function _toPrimitive(input, hint) { - if (_typeof(input) !== "object" || input === null) return input; - var prim = input[Symbol.toPrimitive]; - if (prim !== undefined) { - var res = prim.call(input, hint || "default"); - if (_typeof(res) !== "object") return res; - throw new TypeError("@@toPrimitive must return a primitive value."); - } - return (hint === "string" ? String : Number)(input); -} -module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./typeof.js":82}],81:[function(require,module,exports){ -var _typeof = require("./typeof.js")["default"]; -var toPrimitive = require("./toPrimitive.js"); -function _toPropertyKey(arg) { - var key = toPrimitive(arg, "string"); - return _typeof(key) === "symbol" ? key : String(key); -} -module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./toPrimitive.js":80,"./typeof.js":82}],82:[function(require,module,exports){ -function _typeof(o) { - "@babel/helpers - typeof"; - - return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { - return typeof o; - } : function (o) { - return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; - }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); -} -module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{}],83:[function(require,module,exports){ -var arrayLikeToArray = require("./arrayLikeToArray.js"); -function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen); -} -module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./arrayLikeToArray.js":56}],84:[function(require,module,exports){ -var getPrototypeOf = require("./getPrototypeOf.js"); -var setPrototypeOf = require("./setPrototypeOf.js"); -var isNativeFunction = require("./isNativeFunction.js"); -var construct = require("./construct.js"); -function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !isNativeFunction(Class)) return Class; - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); - } - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - _cache.set(Class, Wrapper); - } - function Wrapper() { - return construct(Class, arguments, getPrototypeOf(this).constructor); - } - Wrapper.prototype = Object.create(Class.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }); - return setPrototypeOf(Wrapper, Class); - }, module.exports.__esModule = true, module.exports["default"] = module.exports; - return _wrapNativeSuper(Class); -} -module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports; -},{"./construct.js":61,"./getPrototypeOf.js":66,"./isNativeFunction.js":69,"./setPrototypeOf.js":76}]},{},[5])(5) +},{}]},{},[5])(5) }); diff --git a/browser/scripts/ion-bundle.min.js b/browser/scripts/ion-bundle.min.js index 5144513f..9b4e3d12 100644 --- a/browser/scripts/ion-bundle.min.js +++ b/browser/scripts/ion-bundle.min.js @@ -1 +1,3 @@ -!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ion=e()}(function(){return function r(i,a,s){function o(t,e){if(!a[t]){if(!i[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(l)return l(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}n=a[t]={exports:{}},i[t][0].call(n.exports,function(e){return o(i[t][1][e]||e)},n,n.exports,r,i,a,s)}return a[t].exports}for(var l="function"==typeof require&&require,e=0;e>=this.BITS_PER_BYTE,n[r]=i}return n}},{key:"getUnsignedIntSizeInBytes",value:function(e){for(var t=0;t=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=b.TimestampPrecision.MONTH&&t.writeVariableLengthUnsignedInt(n.getUTCMonth()+1),e.getPrecision()>=b.TimestampPrecision.DAY&&t.writeVariableLengthUnsignedInt(n.getUTCDate()),e.getPrecision()>=b.TimestampPrecision.HOUR_AND_MINUTE&&(t.writeVariableLengthUnsignedInt(n.getUTCHours()),t.writeVariableLengthUnsignedInt(n.getUTCMinutes())),e.getPrecision()>=b.TimestampPrecision.SECONDS&&(t.writeVariableLengthUnsignedInt(e.getSecondsInt()),0!==(n=e._getFractionalSeconds()).getExponent())&&(t.writeVariableLengthSignedInt(n.getExponent()),0n!==n.getCoefficient())&&t.writeBytes(d.BigIntSerde.toSignedIntBytes(n.getCoefficient(),n.isNegative())),this.addNode(new N(this.writer,this.getCurrentContainer(),m.IonTypes.TIMESTAMP,this.encodeAnnotations(this._annotations),t.getBytes())))}},{key:"stepIn",value:function(e){switch(this.checkWriteValue(),e){case m.IonTypes.LIST:case m.IonTypes.SEXP:this.addNode(new S(this.writer,this.getCurrentContainer(),e,this.encodeAnnotations(this._annotations)));break;case m.IonTypes.STRUCT:this.addNode(new E(this.writer,this.getCurrentContainer(),this.encodeAnnotations(this._annotations))),this.state=a.STRUCT_FIELD;break;default:throw new Error("Unrecognized container type")}}},{key:"stepOut",value:function(){if(0===this.depth())throw new Error("Not currently in a container");if(this.state===a.STRUCT_VALUE)throw new Error("Cannot exit a struct with a partially written field");this.containers.pop(),0a.length&&(a+="0".repeat(i-s));n=BigInt(r),e=BigInt(a);return e=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nthis.maxId)throw new Error("Symbol $"+e.toString()+" greater than maxID.");var t=this.import.getSymbolText(e);return void 0!==t?t:(t=e-this.offset,this.symbols[t])}},{key:"numberOfSymbols",value:function(){return this._symbols.length}}]),a}();n.LocalSymbolTable=a,n.defaultLocalSymbolTable=function(){return new a(u.getSystemSymbolTableImport())}},{"./IonSystemSymbolTable":23,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],14:[function(e,t,n){"use strict";var r=e("@babel/runtime/helpers/interopRequireDefault"),i=r(e("@babel/runtime/helpers/classCallCheck")),s=r(e("@babel/runtime/helpers/createClass")),o=(Object.defineProperty(n,"__esModule",{value:!0}),n.LowLevelBinaryWriter=void 0,e("./BigIntSerde")),r=function(){function a(e){(0,i.default)(this,a),this.writeable=e}return(0,s.default)(a,[{key:"writeSignedInt",value:function(e){for(var t=a.getSignedIntSize(e),n=Math.abs(e),r=new Uint8Array(t),i=r.length;128<=n;)r[--i]=255&n,n>>>=8;r[--i]=255&n,1/e<0&&(r[0]|=128),this.writeable.writeBytes(r)}},{key:"writeUnsignedInt",value:function(e){if("bigint"==typeof e)t=o.BigIntSerde.toUnsignedIntBytes(e),this.writeable.writeBytes(t);else{for(var t=a.getUnsignedIntSize(e),n=new Uint8Array(t),r=e,i=n.length;0>>=7;t[r]=n,1/e<0&&(t[r]|=64),t[t.length-1]|=128,this.writeable.writeBytes(t)}},{key:"writeVariableLengthUnsignedInt",value:function(e){var t=new Uint8Array(a.getVariableLengthUnsignedIntSize(e)),n=e,r=t.length;for(t[--r]=127&n|128,n>>>=7;0>>=7;this.writeable.writeBytes(t)}},{key:"writeByte",value:function(e){this.writeable.writeByte(e)}},{key:"writeBytes",value:function(e){this.writeable.writeBytes(e)}},{key:"getBytes",value:function(){return this.writeable.getBytes()}}],[{key:"getSignedIntSize",value:function(e){return 0===e?1:(e=Math.abs(e),e=Math.ceil(Math.log2(e+1)),Math.ceil((e+1)/8))}},{key:"getUnsignedIntSize",value:function(e){return"bigint"==typeof e?o.BigIntSerde.getUnsignedIntSizeInBytes(e):0===e?1:(e=Math.floor(Math.log2(e))+1,Math.ceil(e/8))}},{key:"getVariableLengthSignedIntSize",value:function(e){var t,e=Math.abs(e);return 0===e?1:(e=Math.floor(Math.log2(e))+1,t=Math.floor(e/7),Math.ceil((e+t+1+1)/8))}},{key:"getVariableLengthUnsignedIntSize",value:function(e){var t;return 0===e?1:(e=Math.floor(Math.log2(e))+1,t=Math.ceil(e/7),Math.ceil((e+t)/8))}}]),a}();n.LowLevelBinaryWriter=r},{"./BigIntSerde":2,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/interopRequireDefault":68}],15:[function(e,t,n){"use strict";var r=e("@babel/runtime/helpers/interopRequireDefault"),_=r(e("@babel/runtime/helpers/slicedToArray")),i=r(e("@babel/runtime/helpers/createClass")),a=r(e("@babel/runtime/helpers/classCallCheck")),s=Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){e[r=void 0===r?n:r]=t[n]},o=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},r=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&s(t,e,n);return o(t,e),t},l=function(e){return e&&e.__esModule?e:{default:e}},u=(Object.defineProperty(n,"__esModule",{value:!0}),n.ParserBinaryRaw=void 0,e("./BigIntSerde")),c=r(e("./IonBinary")),r=e("./IonConstants"),d=e("./IonDecimal"),y=e("./IonTimestamp"),h=e("./IonTypes"),f=e("./IonUnicode"),b=l(e("./SignAndMagnitudeInt"));function m(e){return e>>c.TYPE_SHIFT&c.NIBBLE_MASK}var v=[],T=r.IVM.sid,g=(r.IVM.binary[0],r.IVM.binary[1]),w=r.IVM.binary[2],I=r.IVM.binary[3],C=(0,i.default)(function e(t,n){(0,a.default)(this,e),this.type=t,this.length=n}),l=function(){function p(e){(0,a.default)(this,p),this._raw_type=-1,this._len=-1,this._curr=void 0,this._null=!1,this._fid=null,this._as=-1,this._ae=-1,this._a=[],this._ts=[new C(20,0)],this._in_struct=!1,this._in=e}return(0,i.default)(p,[{key:"source",value:function(){return this._in}},{key:"next",value:function(){return void 0===this._curr&&0=c)throw new Error("Timestamps with an hour must include a minute.");s=this.readVarUnsignedInt(),u=y.TimestampPrecision.HOUR_AND_MINUTE}this._in.position()?@^`|~",this._read_value_helper_operator),i[43]=this._read_value_helper_plus,i[45]=this._read_value_helper_minus,this._read_value_helper_helpers=i}return(0,i.default)(n,[{key:"fieldName",value:function(){return this._fieldname}},{key:"fieldNameType",value:function(){return this._fieldnameType}},{key:"source",value:function(){return this._in}},{key:"annotations",value:function(){return this._ann}},{key:"clearFieldName",value:function(){this._fieldname=null,this._fieldnameType=null}},{key:"isNull",value:function(){return this._curr_null}},{key:"bigIntValue",value:function(){if(this.isNull())return null;var e=this.get_value_as_string(this._curr).toLowerCase();switch(this._curr){case 3:case 4:return e.startsWith("-")?-BigInt(e.slice(1)):BigInt(e);default:throw new Error("intValue() was called when the current value was not an integer.")}}},{key:"numberValue",value:function(){if(this.isNull())return null;var e=this.get_value_as_string(this._curr);switch(this._curr){case 3:case 4:return Number(BigInt(e));case 5:return Number(e);case 6:if("+inf"==e)return Number.POSITIVE_INFINITY;if("-inf"==e)return Number.NEGATIVE_INFINITY;if("nan"==e)return Number.NaN;default:throw new Error("can't convert to number")}}},{key:"booleanValue",value:function(){if(this.isNull())return null;var e=this.get_value_as_string(2);if("true"===e)return!0;if("false"===e)return!1;throw new Error("Unrecognized Boolean value '"+e+"'")}},{key:"get_value_as_string",value:function(e){var t,n="";switch(e){case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:for(t=this._start;t=this._limit}},{key:"next",value:function(){var e;if(this.is_empty()){if(1073741824this._limit&&(this._pos=this._limit)}},{key:"valueAt",value:function(e){return e=this._limit?c.EOF:this._src.charCodeAt(e)}},{key:"chunk",value:function(e){var t=this._src.substr(this._pos,e);return this._pos+=e,t}},{key:"getCodePoint",value:function(e){return this._src.codePointAt(e)}},{key:"line_number",value:function(){return this._line}},{key:"offset",value:function(){return this._pos-this._line_start}},{key:"clone",value:function(e){return new r(this._src.substr(this._pos))}}]),r}()),e=(n.StringSpan=r,function(){(0,i.default)(r,h);var n=u(r);function r(e){var t;return(0,o.default)(this,r),(t=n.call(this,1))._src=e,t._limit=e.length,t._start=0,t._pos=0,t}return(0,l.default)(r,[{key:"position",value:function(){return this._pos-this._start}},{key:"getRemaining",value:function(){return this._limit-this._pos}},{key:"setRemaining",value:function(e){this._limit=e+this._pos}},{key:"is_empty",value:function(){return this._pos>=this._limit}},{key:"next",value:function(){return this.is_empty()?c.EOF:this._src[this._pos++]}},{key:"view",value:function(e){if(this._pos+e>this._limit)throw new Error("Unable to read "+e+" bytes (position: "+this.position()+", limit: "+this._limit+")");return this._src.subarray(this._pos,this._pos+=e)}},{key:"chunk",value:function(e){return new Uint8Array(this.view(e))}},{key:"unread",value:function(e){this._pos<=this._start&&h.error(),this._pos--,e==c.EOF&&0==this.is_empty()&&h.error(),e!=this.peek()&&h.error()}},{key:"peek",value:function(){return this.is_empty()?c.EOF:this._src[this._pos]}},{key:"skip",value:function(e){if(this._pos+=e,this._pos>this._limit)throw new Error("Skipped over end of source.")}},{key:"valueAt",value:function(e){return e=this._limit?c.EOF:this._src[e]}},{key:"clone",value:function(e,t){return new r(this._src.subarray(this._pos))}}]),r}());n.BinarySpan=e},{"./IonConstants":10,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],20:[function(e,t,n){"use strict";var r=e("@babel/runtime/helpers/interopRequireDefault"),i=r(e("@babel/runtime/helpers/classCallCheck")),a=r(e("@babel/runtime/helpers/createClass")),s=r(e("@babel/runtime/helpers/inherits")),o=r(e("@babel/runtime/helpers/possibleConstructorReturn")),l=r(e("@babel/runtime/helpers/getPrototypeOf"));function u(n){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t=(0,l.default)(n);return e=r?(e=(0,l.default)(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments),(0,o.default)(this,e)}}Object.defineProperty(n,"__esModule",{value:!0}),n.SubstituteSymbolTable=void 0;r=function(e){(0,s.default)(r,e);var n=u(r);function r(e){var t;if((0,i.default)(this,r),e<0)throw new Error("Cannot instantiate a SubstituteSymbolTable with a negative length. ("+e+")");return(t=n.call(this,"_substitute",-1,[]))._numberOfSymbols=e,t}return(0,a.default)(r,[{key:"getSymbolText",value:function(e){if(e<0)throw new Error("Index ".concat(e," is out of bounds for the SharedSymbolTable name=").concat(this.name,", version=").concat(this.version))}},{key:"getSymbolId",value:function(e){}}]),r}(e("./IonSharedSymbolTable").SharedSymbolTable);n.SubstituteSymbolTable=r},{"./IonSharedSymbolTable":18,"@babel/runtime/helpers/classCallCheck":60,"@babel/runtime/helpers/createClass":62,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":75}],21:[function(e,t,n){"use strict";var r=e("@babel/runtime/helpers/interopRequireDefault"),i=r(e("@babel/runtime/helpers/classCallCheck")),a=r(e("@babel/runtime/helpers/createClass")),r=(Object.defineProperty(n,"__esModule",{value:!0}),n.SymbolToken=void 0,function(){function n(e){var t=1?@^`|~"),_=o(" \t\r\n\v\f"),d=o("_$0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");function y(e){return!(e<48||57>>4,i+2>>2,i+3>>2],t[4*n/3+1]=I[r<<4&63|(i||0)>>>4],!(n+1>>6],!(n+2t;)null===(e=this.next())?this.stepOut():e.isContainer&&!this.isNull()&&this.stepIn()}},{key:"isIVM",value:function(e,t,n){if(0=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nc.MONTH){l=new Date(this._year,this._month,0);if(l.setUTCFullYear(this._year),this._day>l.getDate())throw new Error("Month ".concat(this._month," has less than ").concat(this._day," days"));if(2===this._month&&29===this._day&&!this._isLeapYear(this._year))throw new Error("Given February 29th but year ".concat(this._year," is not a leap year"))}e=this.getDate().getUTCFullYear();this._checkFieldRange("Year",e,u._MIN_YEAR,u._MAX_YEAR)}return(0,a.default)(u,[{key:"getLocalOffset",value:function(){return this._localOffset}},{key:"getPrecision",value:function(){return this._precision}},{key:"getDate",value:function(){var e=0,e=(this._precision===c.SECONDS&&(e=Math.round(1e3*(this._secondsDecimal.numberValue()-this.getSecondsInt()))),Date.UTC(this._year,this._precision===c.YEAR?0:this._month-1,this._day,this._hour,this._minutes,this.getSecondsInt(),e)),e=u._adjustMsSinceEpochIfNeeded(this._year,e),t=60*this._localOffset*1e3;return new Date(e-t)}},{key:"getSecondsInt",value:function(){return this._secondsDecimal.intValue()}},{key:"getSecondsDecimal",value:function(){return this._secondsDecimal}},{key:"_getFractionalSeconds",value:function(){var e=u._splitSecondsDecimal(this._secondsDecimal),e=(0,s.default)(e,2),e=(e[0],e[1]);return""===e?m.Decimal.ZERO:m.Decimal.parse(e+"d-"+e.length)}},{key:"equals",value:function(e){return this.getPrecision()===e.getPrecision()&&this.getLocalOffset()===e.getLocalOffset()&&l._sign(this.getLocalOffset())===l._sign(e.getLocalOffset())&&0===this.compareTo(e)&&this._secondsDecimal.equals(e._secondsDecimal)}},{key:"compareTo",value:function(e){var t=this.getDate().getTime(),n=e.getDate().getTime();return t===n?this.getSecondsDecimal().compareTo(e.getSecondsDecimal()):tc.DAY&&(0===r&&1===l._sign(r)?e+="Z":e+=(-1===l._sign(r)?"-":"+")+this._lpadZeros(Math.floor(Math.abs(r)/60),2)+":"+this._lpadZeros(Math.abs(r)%60,2)),e}},{key:"toJSON",value:function(){return this.getDate().toISOString()}},{key:"_checkRequiredField",value:function(e,t,n,r){if(!l._hasValue(t))throw new Error("".concat(e," cannot be ").concat(t));this._checkFieldRange(e,t,n,r)}},{key:"_checkOptionalField",value:function(e,t,n,r,i,a){return l._hasValue(t)?(this._checkFieldRange(e,t,n,r),this._precision=a,t):i}},{key:"_checkFieldRange",value:function(e,t,n,r){if(t instanceof m.Decimal){if(l._hasValue(t)&&(t.compareTo(n)<0||0<=t.compareTo(r)))throw new Error("".concat(e," ").concat(t," must be between ").concat(n," inclusive, and ").concat(r," exclusive"))}else{if(!Number.isInteger(t))throw new Error("".concat(e," ").concat(t," must be an integer"));if(t>6|192;else{if(55295=e.length)throw new Error("UTF-8 encode: incomplete surrogate pair");var a=e.charCodeAt(i);if(a<56320||57343>18|240,r[n++]=t>>12&63|128}else r[n++]=t>>12|224;r[n++]=t>>6&63|128}r[n++]=63&t|128}return r.subarray(0,n)},n.decodeUtf8=function(e){if(512=e.length)throw new Error("UTF-8 decode: incomplete 2-byte sequence");t=(31&t)<<6|63&e[n++]}else if(223=e.length)throw new Error("UTF-8 decode: incomplete 3-byte sequence");t=(15&t)<<12|(63&e[n++])<<6|63&e[n++]}else{if(!(239=e.length)throw new Error("UTF-8 decode: incomplete 4-byte sequence");t=(7&t)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++]}if(t<=65535)r+=String.fromCharCode(t);else{if(!(t<=1114111))throw new Error("UTF-8 decode: code point 0x"+t.toString(16)+" exceeds UTF-16 reach");t-=65536,r=(r+=String.fromCharCode(t>>10|55296))+String.fromCharCode(1023&t|56320)}}return r}},{}],31:[function(e,t,n){"use strict";var r=e("@babel/runtime/helpers/interopRequireDefault"),i=r(e("@babel/runtime/helpers/classCallCheck")),a=r(e("@babel/runtime/helpers/createClass")),r=(Object.defineProperty(n,"__esModule",{value:!0}),n.Writeable=void 0,function(){function t(e){(0,i.default)(this,t),this.bufferSize=e||4096,this.buffers=[new Uint8Array(this.bufferSize)],this.index=0,this.clean=!1}return(0,a.default)(t,[{key:"currentBuffer",get:function(){return this.buffers[this.buffers.length-1]}},{key:"totalSize",get:function(){for(var e=0,t=0;t=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=Number.MIN_SAFE_INTEGER&&e<=Number.MAX_SAFE_INTEGER}},{}],56:[function(e,t,n){t.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n>=this.BITS_PER_BYTE,n[e]=i}return n}static getUnsignedIntSizeInBytes(t){for(let e=0;er;)e++,r=this.calculateSizeThreshold(e);return e}static calculateSizeThresholds(){var t=[];for(let e=1;e<=this.SERIALIZED_BIGINT_SIZES_TO_PRECOMPUTE;e++)t.push(this.calculateSizeThreshold(e));return t}static calculateSizeThreshold(e){return 2n**(BigInt(e)*this.BITS_PER_BYTE)-1n}}(r.BigIntSerde=n).SERIALIZED_BIGINT_SIZES_TO_PRECOMPUTE=64,n.BITS_PER_BYTE=8n,n.BYTE_MAX_VALUE=BigInt(255),n.SIZE_THRESHOLDS=n.calculateSizeThresholds()},{}],3:[function(e,t,r){"use strict";var i,n;Object.defineProperty(r,"__esModule",{value:!0}),r.ComparisonResult=r.ComparisonResultType=void 0,(n=i=r.ComparisonResultType||(r.ComparisonResultType={})).EQUAL="EQUAL",n.NOT_EQUAL="NOT_EQUAL",n.ERROR="ERROR";r.ComparisonResult=class{constructor(){var e=0{this._annotations.push(this.getSymbolString(e))}))}getSymbolString(e){let t=null;if(null===e)return null;if(0=l.TimestampPrecision.MONTH&&t.writeVariableLengthUnsignedInt(r.getUTCMonth()+1),e.getPrecision()>=l.TimestampPrecision.DAY&&t.writeVariableLengthUnsignedInt(r.getUTCDate()),e.getPrecision()>=l.TimestampPrecision.HOUR_AND_MINUTE&&(t.writeVariableLengthUnsignedInt(r.getUTCHours()),t.writeVariableLengthUnsignedInt(r.getUTCMinutes())),e.getPrecision()>=l.TimestampPrecision.SECONDS&&(t.writeVariableLengthUnsignedInt(e.getSecondsInt()),0!==(r=e._getFractionalSeconds()).getExponent())&&(t.writeVariableLengthSignedInt(r.getExponent()),0n!==r.getCoefficient())&&t.writeBytes(a.BigIntSerde.toSignedIntBytes(r.getCoefficient(),r.isNegative())),this.addNode(new b(this.writer,this.getCurrentContainer(),u.IonTypes.TIMESTAMP,this.encodeAnnotations(this._annotations),t.getBytes())))}stepIn(e){switch(this.checkWriteValue(),e){case u.IonTypes.LIST:case u.IonTypes.SEXP:this.addNode(new m(this.writer,this.getCurrentContainer(),e,this.encodeAnnotations(this._annotations)));break;case u.IonTypes.STRUCT:this.addNode(new y(this.writer,this.getCurrentContainer(),this.encodeAnnotations(this._annotations))),this.state=n.STRUCT_FIELD;break;default:throw new Error("Unrecognized container type")}}stepOut(){if(0===this.depth())throw new Error("Not currently in a container");if(this.state===n.STRUCT_VALUE)throw new Error("Cannot exit a struct with a partially written field");this.containers.pop(),0s.length&&(s+="0".repeat(n-a));var e=BigInt(r),l=BigInt(s);return lthis.maxId)throw new Error("Symbol $"+e.toString()+" greater than maxID.");var t=this.import.getSymbolText(e);return void 0!==t?t:(t=e-this.offset,this.symbols[t])}numberOfSymbols(){return this._symbols.length}}r.LocalSymbolTable=i,r.defaultLocalSymbolTable=function(){return new i(n.getSystemSymbolTableImport())}},{"./IonSystemSymbolTable":23}],14:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.LowLevelBinaryWriter=void 0;const s=e("./BigIntSerde");class a{constructor(e){this.writeable=e}static getSignedIntSize(e){return 0===e?1:(e=Math.abs(e),e=Math.ceil(Math.log2(e+1)),Math.ceil((e+1)/8))}static getUnsignedIntSize(e){return"bigint"==typeof e?s.BigIntSerde.getUnsignedIntSizeInBytes(e):0===e?1:(e=Math.floor(Math.log2(e))+1,Math.ceil(e/8))}static getVariableLengthSignedIntSize(e){var t,e=Math.abs(e);return 0===e?1:(e=Math.floor(Math.log2(e))+1,t=Math.floor(e/7),Math.ceil((e+t+1+1)/8))}static getVariableLengthUnsignedIntSize(e){var t;return 0===e?1:(e=Math.floor(Math.log2(e))+1,t=Math.ceil(e/7),Math.ceil((e+t)/8))}writeSignedInt(e){var t=a.getSignedIntSize(e);let r=Math.abs(e);var n=new Uint8Array(t);let i=n.length;for(;128<=r;)n[--i]=255&r,r>>>=8;n[--i]=255&r,1/e<0&&(n[0]|=128),this.writeable.writeBytes(n)}writeUnsignedInt(r){if("bigint"==typeof r)n=s.BigIntSerde.toUnsignedIntBytes(r),this.writeable.writeBytes(n);else{var n=a.getUnsignedIntSize(r),i=new Uint8Array(n);let e=r,t=i.length;for(;0>>=7;t[n]=r,1/e<0&&(t[n]|=64),t[t.length-1]|=128,this.writeable.writeBytes(t)}writeVariableLengthUnsignedInt(e){var t=new Uint8Array(a.getVariableLengthUnsignedIntSize(e));let r=e,n=t.length;for(t[--n]=127&r|128,r>>>=7;0>>=7;this.writeable.writeBytes(t)}writeByte(e){this.writeable.writeByte(e)}writeBytes(e){this.writeable.writeBytes(e)}getBytes(){return this.writeable.getBytes()}}r.LowLevelBinaryWriter=a},{"./BigIntSerde":2}],15:[function(e,t,r){"use strict";var n=Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){e[n=void 0===n?r:n]=t[r]},i=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.ParserBinaryRaw=void 0;const o=e("./BigIntSerde"),l=s(e("./IonBinary"));s=e("./IonConstants");const _=e("./IonDecimal"),c=e("./IonTimestamp"),u=e("./IonTypes"),h=e("./IonUnicode"),p=a(e("./SignAndMagnitudeInt"));function d(e){return e>>l.TYPE_SHIFT&l.NIBBLE_MASK}const T=[],f=s.IVM.sid;s.IVM.binary[0];const m=s.IVM.binary[1],y=s.IVM.binary[2],g=s.IVM.binary[3];class I{constructor(e,t){this.type=e,this.length=t}}class w{constructor(e){this._raw_type=-1,this._len=-1,this._curr=void 0,this._null=!1,this._fid=null,this._as=-1,this._ae=-1,this._a=[],this._ts=[new I(20,0)],this._in_struct=!1,this._in=e}static _readFloatFrom(e,t){let r;switch(t){case 0:return 0;case 4:return(r=new DataView(e.chunk(4).buffer)).getFloat32(0,!1);case 8:return(r=new DataView(e.chunk(8).buffer)).getFloat64(0,!1);case 15:return null;default:throw new Error("Illegal float length: "+t)}}static _readVarUnsignedIntFrom(e){let t=0;var r;let n=0;for(;;)if(r=e.next(),n=n<<7|127&r,t+=7,128&r)break;if(31=l)throw new Error("Timestamps with an hour must include a minute.");i=this.readVarUnsignedInt(),o=c.TimestampPrecision.HOUR_AND_MINUTE}if(this._in.position()?@^`|~",this._read_value_helper_operator),i[43]=this._read_value_helper_plus,i[45]=this._read_value_helper_minus,this._read_value_helper_helpers=i}fieldName(){return this._fieldname}fieldNameType(){return this._fieldnameType}source(){return this._in}annotations(){return this._ann}clearFieldName(){this._fieldname=null,this._fieldnameType=null}isNull(){return this._curr_null}bigIntValue(){if(this.isNull())return null;var e=this.get_value_as_string(this._curr).toLowerCase();switch(this._curr){case 3:case 4:return e.startsWith("-")?-BigInt(e.slice(1)):BigInt(e);default:throw new Error("intValue() was called when the current value was not an integer.")}}numberValue(){if(this.isNull())return null;var e=this.get_value_as_string(this._curr);switch(this._curr){case 3:case 4:return Number(BigInt(e));case 5:return Number(e);case 6:if("+inf"==e)return Number.POSITIVE_INFINITY;if("-inf"==e)return Number.NEGATIVE_INFINITY;if("nan"==e)return Number.NaN;default:throw new Error("can't convert to number")}}booleanValue(){if(this.isNull())return null;var e=this.get_value_as_string(2);if("true"===e)return!0;if("false"===e)return!1;throw new Error("Unrecognized Boolean value '"+e+"'")}get_value_as_string(t){let r,n,i="";switch(t){case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:for(r=this._start;r=this.numberOfSymbols))return this._symbols[e]}getSymbolId(e){return this._idsByText.get(e)}}},{}],19:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.BinarySpan=r.StringSpan=r.Span=void 0;const n=e("./IonConstants");class i{constructor(e){this._type=e}static error(){throw new Error("span error")}write(e){throw new Error("not implemented")}}class s extends(r.Span=i){constructor(e){super(0),this._line=1,this._src=e,this._limit=e.length,this._start=0,this._pos=0,this._line_start=0,this._old_line_start=0}viewSource(){return this._src}position(){return this._pos-this._start}getRemaining(){return this._limit-this._pos}setRemaining(e){this._limit=e+this._pos}is_empty(){return this._pos>=this._limit}next(){var e;if(this.is_empty()){if(1073741824this._limit&&(this._pos=this._limit)}valueAt(e){return e=this._limit?n.EOF:this._src.charCodeAt(e)}chunk(e){var t=this._src.substr(this._pos,e);return this._pos+=e,t}getCodePoint(e){return this._src.codePointAt(e)}line_number(){return this._line}offset(){return this._pos-this._line_start}clone(e){return new s(this._src.substr(this._pos))}}r.StringSpan=s;class a extends i{constructor(e){super(1),this._src=e,this._limit=e.length,this._start=0,this._pos=0}position(){return this._pos-this._start}getRemaining(){return this._limit-this._pos}setRemaining(e){this._limit=e+this._pos}is_empty(){return this._pos>=this._limit}next(){return this.is_empty()?n.EOF:this._src[this._pos++]}view(e){if(this._pos+e>this._limit)throw new Error("Unable to read "+e+" bytes (position: "+this.position()+", limit: "+this._limit+")");return this._src.subarray(this._pos,this._pos+=e)}chunk(e){return new Uint8Array(this.view(e))}unread(e){this._pos<=this._start&&i.error(),this._pos--,e==n.EOF&&0==this.is_empty()&&i.error(),e!=this.peek()&&i.error()}peek(){return this.is_empty()?n.EOF:this._src[this._pos]}skip(e){if(this._pos+=e,this._pos>this._limit)throw new Error("Skipped over end of source.")}valueAt(e){return e=this._limit?n.EOF:this._src[e]}clone(e,t){return new a(this._src.subarray(this._pos))}}r.BinarySpan=a},{"./IonConstants":10}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.SubstituteSymbolTable=void 0;class n extends e("./IonSharedSymbolTable").SharedSymbolTable{constructor(e){if(e<0)throw new Error("Cannot instantiate a SubstituteSymbolTable with a negative length. ("+e+")");super("_substitute",-1,[]),this._numberOfSymbols=e}getSymbolText(e){if(e<0)throw new Error(`Index ${e} is out of bounds for the SharedSymbolTable name=${this.name}, version=`+this.version)}getSymbolId(e){}}r.SubstituteSymbolTable=n},{"./IonSharedSymbolTable":18}],21:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.SymbolToken=void 0;class n{constructor(e){var t=1?@^`|~"),T=l(" \t\r\n\v\f"),f=l("_$0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");function m(e){return!(e<48||57>>4,e+2>>2,e+3>>2],r[4*e/3+1]=v[n<<4&63|(i||0)>>>4],!(e+1>>6],!(e+2t;)null===(e=this.next())?this.stepOut():e.isContainer&&!this.isNull()&&this.stepIn()}isIVM(e,t,r){if(0{var t=e.getText();if(null!==t)return t;t=this._symtab.getSymbolText(e.getSid());if(null==t)throw new Error("Unresolvable symbol ID, symboltokens unsupported.");return t})}isNull(){return this._type===c.IonTypes.NULL||this._parser.isNull()}_stringRepresentation(){return this.load_raw(),this.isNull()?this._type===c.IonTypes.NULL?"null":"null."+this._type.name:this._raw}booleanValue(){switch(this._type){case c.IonTypes.NULL:return null;case c.IonTypes.BOOL:return this._parser.booleanValue()}throw new Error("Current value is not a Boolean.")}uInt8ArrayValue(){switch(this.load_raw(),this._type){case c.IonTypes.NULL:return null;case c.IonTypes.BLOB:return this.isNull()?null:h.fromBase64(this._raw);case c.IonTypes.CLOB:return this.isNull()?null:this._raw}throw new Error("Current value is not a blob or clob.")}decimalValue(){switch(this._type){case c.IonTypes.NULL:return null;case c.IonTypes.DECIMAL:return a.Decimal.parse(this._stringRepresentation())}throw new Error("Current value is not a decimal.")}bigIntValue(){switch(this._type){case c.IonTypes.NULL:return null;case c.IonTypes.INT:return this._parser.bigIntValue()}throw new Error("bigIntValue() was called when the current value was a(n) "+this._type.name)}intSize(){return p.isSafeInteger(this.bigIntValue())?i.default.Number:i.default.BigInt}numberValue(){switch(this._type){case c.IonTypes.NULL:return null;case c.IonTypes.FLOAT:case c.IonTypes.INT:return this._parser.numberValue()}throw new Error("Current value is not a float or int.")}stringValue(){switch(this.load_raw(),this._type){case c.IonTypes.NULL:return null;case c.IonTypes.STRING:return this._parser.isNull()?null:this._raw;case c.IonTypes.SYMBOL:if(this._parser.isNull())return null;if(9===this._raw_type&&1{h._serializeFloat(this,e)},this.containerContext=[new u(null)]}get isTopLevel(){return 0===this.depth()}get currentContainer(){return this.containerContext[this.depth()]}static _serializeFloat(e,t){let r;t===Number.POSITIVE_INFINITY?r="+inf":t===Number.NEGATIVE_INFINITY?r="-inf":Object.is(t,Number.NaN)?r="nan":Object.is(t,-0)?r="-0e0":-1<(t=(r=t.toExponential()).lastIndexOf("+"))&&(r=r.slice(0,t)+r.slice(t+1)),e.writeUtf8(r)}getBytes(){return this.writeable.getBytes()}writeBlob(e){l._assertDefined(e),this._serializeValue(a.IonTypes.BLOB,e,e=>{this.writeable.writeBytes(o.encodeUtf8("{{"+s.toBase64(e)+"}}"))})}writeBoolean(e){l._assertDefined(e),this._serializeValue(a.IonTypes.BOOL,e,e=>{this.writeUtf8(e?"true":"false")})}writeClob(e){l._assertDefined(e),this._serializeValue(a.IonTypes.CLOB,e,t=>{let r;this.writeUtf8('{{"');for(let e=0;e{let t="",r=e.getCoefficient();r<0n&&(r=-r),e.isNegative()&&(t+="-");var n,i,s,e=e.getExponent(),a=-e;0==e?t+=r.toString()+".":e<0?(i=(n=r.toString().length)-1-a,t=0<=i?(s=n-a,(t=t+r.toString().substring(0,s)+".")+r.toString().substring(s,n)):-6<=i?(t=(t+="0.")+"00000".substring(0,a-n))+r.toString():(t=t+r.toString()+"d-")+a.toString()):t+=r.toString()+"d"+e,this.writeUtf8(t)})}_isInStruct(){return this.currentContainer.containerType===a.IonTypes.STRUCT}writeFieldName(e){if(l._assertDefined(e),this.currentContainer.containerType!==a.IonTypes.STRUCT)throw new Error("Cannot write field name outside of a struct");if(this.currentContainer.state!==n.STRUCT_FIELD)throw new Error("Expecting a struct value");this.currentContainer.clean||this.writeable.writeByte(s.CharCodes.COMMA),this.writeSymbolToken(e),this.writeable.writeByte(s.CharCodes.COLON),this.currentContainer.state=n.VALUE}writeFloat32(e){l._assertDefined(e),this._writeFloat(e)}writeFloat64(e){l._assertDefined(e),this._writeFloat(e)}writeInt(e){l._assertDefined(e),this._serializeValue(a.IonTypes.INT,e,e=>{this.writeUtf8(e.toString(10))})}_writeNull(e){e===a.IonTypes.NULL?this.writeUtf8("null"):this.writeUtf8("null."+e.name)}writeNull(e){null==e&&(e=a.IonTypes.NULL),this.handleSeparator(),this.writeAnnotations(),this._writeNull(e),this.currentContainer.containerType===a.IonTypes.STRUCT&&(this.currentContainer.state=n.STRUCT_FIELD)}writeString(e){l._assertDefined(e),this._serializeValue(a.IonTypes.STRING,e,e=>{this.writeable.writeBytes(o.encodeUtf8('"'+s.escape(e,s.StringEscapes)+'"'))})}writeSymbol(e){l._assertDefined(e),this._serializeValue(a.IonTypes.SYMBOL,e,e=>{this.writeSymbolToken(e)})}writeTimestamp(e){l._assertDefined(e),this._serializeValue(a.IonTypes.TIMESTAMP,e,e=>{this.writeUtf8(e.toString())})}stepIn(e){if(this.currentContainer.state===n.STRUCT_FIELD)throw new Error(`Started writing a ${this.currentContainer.containerType.name} inside a struct" + + " without writing the field name first. Call writeFieldName(string) with the desired name" + + " before calling stepIn(${this.currentContainer.containerType.name}).`);switch(e){case a.IonTypes.LIST:this.writeContainer(e,s.CharCodes.LEFT_BRACKET);break;case a.IonTypes.SEXP:this.writeContainer(e,s.CharCodes.LEFT_PARENTHESIS);break;case a.IonTypes.STRUCT:if(void 0!==this._annotations&&"$ion_symbol_table"===this._annotations[0]&&0===this.depth())throw new Error("Unable to alter symbol table context, it allows invalid ion to be written.");this.writeContainer(e,s.CharCodes.LEFT_BRACE);break;default:throw new Error("Unrecognized container type")}}stepOut(){var e=this.containerContext.pop();if(!e||!e.containerType)throw new Error("Can't step out when not in a container");if(e.containerType===a.IonTypes.STRUCT&&e.state===n.VALUE)throw new Error("Expecting a struct value");switch(e.containerType){case a.IonTypes.LIST:this.writeable.writeByte(s.CharCodes.RIGHT_BRACKET);break;case a.IonTypes.SEXP:this.writeable.writeByte(s.CharCodes.RIGHT_PARENTHESIS);break;case a.IonTypes.STRUCT:this.writeable.writeByte(s.CharCodes.RIGHT_BRACE);break;default:throw new Error("Unexpected container TypeCode")}}close(){if(0l.MONTH){e=new Date(this._year,this._month,0);if(e.setUTCFullYear(this._year),this._day>e.getDate())throw new Error(`Month ${this._month} has less than ${this._day} days`);if(2===this._month&&29===this._day&&!this._isLeapYear(this._year))throw new Error(`Given February 29th but year ${this._year} is not a leap year`)}o=this.getDate().getUTCFullYear();this._checkFieldRange("Year",o,y._MIN_YEAR,y._MAX_YEAR)}static parse(e){return g._parse(e)}static _adjustMsSinceEpochIfNeeded(e,t){return 100<=e?t:((t=new Date(t)).setUTCFullYear(e),t.getTime())}static _splitSecondsDecimal(e){var t,r=e.getCoefficient().toString(),n=e.getExponent();let i="",s="";return n<0?(t=Math.max(r.length+n,0),i=r.substring(0,t),s=r.substring(t),0<-e.getExponent()-r.length&&(s="0".repeat(-n-r.length)+s)):i=0l.DAY&&(0===n&&1===a._sign(n)?e+="Z":e+=(-1===a._sign(n)?"-":"+")+this._lpadZeros(Math.floor(Math.abs(n)/60),2)+":"+this._lpadZeros(Math.abs(n)%60,2)),e}toJSON(){return this.getDate().toISOString()}_checkRequiredField(e,t,r,n){if(!a._hasValue(t))throw new Error(e+" cannot be "+t);this._checkFieldRange(e,t,r,n)}_checkOptionalField(e,t,r,n,i,s){return a._hasValue(t)?(this._checkFieldRange(e,t,r,n),this._precision=s,t):i}_checkFieldRange(e,t,r,n){if(t instanceof f.Decimal){if(a._hasValue(t)&&(t.compareTo(r)<0||0<=t.compareTo(n)))throw new Error(e+` ${t} must be between ${r} inclusive, and ${n} exclusive`)}else{if(!Number.isInteger(t))throw new Error(e+` ${t} must be an integer`);if(t=c)break;if(null!==_.t){d=String.fromCharCode(e.charCodeAt(h));if(void 0===(_=g._timeParserStates[_.t[d]]))throw new Error("State was not set pos:"+h);_.f===m.OFFSET_ZULU&&(t=1,r=0)}h++}if(null===r){if(null!==o)throw new Error('invalid timestamp, missing local offset: "'+e+'"');r=-0}else r=t*r;let T;return(void 0!==l&&null!==l||u)&&(T=f.Decimal.parse(l+"."+(u||""))),new y(r,n,i,s,a,o,T)}static _readUnknownDigits(e,t){let r=t;for(;r>6|192;else{if(55295=t.length)throw new Error("UTF-8 encode: incomplete surrogate pair");var s=t.charCodeAt(e);if(s<56320||57343>18|240,i[r++]=n>>12&63|128}else i[r++]=n>>12|224;i[r++]=n>>6&63|128}i[r++]=63&n|128}return i.subarray(0,r)},r.decodeUtf8=function(e){if(512=e.length)throw new Error("UTF-8 decode: incomplete 2-byte sequence");n=(31&n)<<6|63&e[t++]}else if(223=e.length)throw new Error("UTF-8 decode: incomplete 3-byte sequence");n=(15&n)<<12|(63&e[t++])<<6|63&e[t++]}else{if(!(239=e.length)throw new Error("UTF-8 decode: incomplete 4-byte sequence");n=(7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++]}if(n<=65535)r+=String.fromCharCode(n);else{if(!(n<=1114111))throw new Error("UTF-8 decode: code point 0x"+n.toString(16)+" exceeds UTF-16 reach");n-=65536,r=(r+=String.fromCharCode(n>>10|55296))+String.fromCharCode(1023&n|56320)}}return r}},{}],31:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Writeable=void 0;r.Writeable=class{constructor(e){this.bufferSize=e||4096,this.buffers=[new Uint8Array(this.bufferSize)],this.index=0,this.clean=!1}get currentBuffer(){return this.buffers[this.buffers.length-1]}get totalSize(){let t=0;for(let e=0;ei.Value.from(e)),t);throw new Error(`Cannot create a ${this.name} from: `+e.toString())}writeTo(e){e.setAnnotations(this.getAnnotations()),e.stepIn(r);for(const t of this)t.writeTo(e);e.stepOut()}_valueEquals(e){var t=1a.push(...e.getAll(...i))),a}fieldNames(){return Object.keys(this._fields)}allFields(){return Object.entries(this._fields)}fields(){var e,t,r=Object.create(null);for([e,t]of this.allFields())r[e]=t[t.length-1];return Object.entries(r)}elements(){return Object.values(this._fields).flat()}[Symbol.iterator](){return this.fields()[Symbol.iterator]()}toString(){return"{"+[...this.allFields()].map(e=>{var[e,t]=e;return e+": "+t}).join(", ")+"}"}writeTo(e){e.setAnnotations(this.getAnnotations()),e.stepIn(i.IonTypes.STRUCT);for(var[t,r]of this.allFields())for(var n of r)e.writeFieldName(t),n.writeTo(e);e.stepOut()}deleteField(e){return e in this._fields&&(delete this._fields[e],!0)}toJSON(){var e,t,r=Object.create(u.prototype);for([e,t]of this.fields())r[e]=t;return r}static _fromJsValue(e,t){if(e instanceof Object)return new this(Object.entries(e).map(e=>{var[e,t]=e;return[e,[l.Value.from(t)]]}),t);throw new Error("Cannot create a dom.Struct from: "+e.toString())}_valueEquals(e){var r=1e=>o._hasValue(e)&&o._hasValue(e.constructor)&&u in e.constructor&&e.constructor[u]===u})},{"../util":55,"./JsValueConversion":40}],51:[function(e,x,t){"use strict";var n=Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){e[n=void 0===n?r:n]=t[r]},i=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},r=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.load=t.loadAll=void 0;const l=r(e("../Ion")),u=e("../Ion"),s=e("../IonBinaryReader"),a=e("../IonTextReader"),h=e("./Blob"),_=e("./Clob"),c=e("./Decimal"),p=e("./Float"),d=e("./Integer"),T=e("./List"),f=e("./Null"),m=e("./SExpression"),y=e("./Struct"),g=e("./Symbol"),I=e("./Timestamp");function o(e){return e instanceof a.TextReader||e instanceof s.BinaryReader?e:u.makeReader(e)}function w(e){var t=e.type();if(null===t)throw new Error("loadValue() called when no further values were available to read.");var r,n,i=e.annotations();if(e.isNull())return new f.Null(e.type(),i);switch(t){case u.IonTypes.NULL:return new f.Null(u.IonTypes.NULL,i);case u.IonTypes.BOOL:return new l.dom.Boolean(e.booleanValue(),i);case u.IonTypes.INT:return e.intSize()==u.IntSize.Number?new d.Integer(e.numberValue(),i):new d.Integer(e.bigIntValue(),i);case u.IonTypes.FLOAT:return new p.Float(e.numberValue(),i);case u.IonTypes.DECIMAL:return new c.Decimal(e.decimalValue(),i);case u.IonTypes.TIMESTAMP:return new I.Timestamp(e.timestampValue(),i);case u.IonTypes.SYMBOL:return new g.Symbol(e.stringValue(),i);case u.IonTypes.STRING:return new l.dom.String(e.stringValue(),i);case u.IonTypes.CLOB:return new _.Clob(e.uInt8ArrayValue(),i);case u.IonTypes.BLOB:return new h.Blob(e.uInt8ArrayValue(),i);case u.IonTypes.LIST:return n=(r=e).annotations(),new T.List(b(r),n);case u.IonTypes.SEXP:return n=(r=e).annotations(),new m.SExpression(b(r),n);case u.IonTypes.STRUCT:var s=e,a=new Map,o=s.annotations();for(s.stepIn();s.next();)a.has(s.fieldName())?a.get(s.fieldName()).push(w(s)):a.set(s.fieldName(),[w(s)]);return s.stepOut(),new y.Struct(a.entries(),o);default:throw new Error(`Unrecognized IonType '${t}' found.`)}}function b(e){var t=[];for(e.stepIn();e.next();)t.push(w(e));return e.stepOut(),t}t.loadAll=function(e){for(var t=o(e),r=[];t.next();)r.push(w(t));return r},t.load=function(e){return null===(e=o(e)).type()&&e.next(),null===e.type()?null:w(e)};var v=e("./Value"),S=(Object.defineProperty(t,"Value",{enumerable:!0,get:function(){return v.Value}}),e("./Null")),E=(Object.defineProperty(t,"Null",{enumerable:!0,get:function(){return S.Null}}),e("./Boolean")),C=(Object.defineProperty(t,"Boolean",{enumerable:!0,get:function(){return E.Boolean}}),e("./Integer")),N=(Object.defineProperty(t,"Integer",{enumerable:!0,get:function(){return C.Integer}}),e("./Float")),A=(Object.defineProperty(t,"Float",{enumerable:!0,get:function(){return N.Float}}),e("./Decimal")),O=(Object.defineProperty(t,"Decimal",{enumerable:!0,get:function(){return A.Decimal}}),e("./Timestamp")),L=(Object.defineProperty(t,"Timestamp",{enumerable:!0,get:function(){return O.Timestamp}}),e("./String")),V=(Object.defineProperty(t,"String",{enumerable:!0,get:function(){return L.String}}),e("./Symbol")),B=(Object.defineProperty(t,"Symbol",{enumerable:!0,get:function(){return V.Symbol}}),e("./Blob")),U=(Object.defineProperty(t,"Blob",{enumerable:!0,get:function(){return B.Blob}}),e("./Clob")),R=(Object.defineProperty(t,"Clob",{enumerable:!0,get:function(){return U.Clob}}),e("./Struct")),M=(Object.defineProperty(t,"Struct",{enumerable:!0,get:function(){return R.Struct}}),e("./List")),F=(Object.defineProperty(t,"List",{enumerable:!0,get:function(){return M.List}}),e("./SExpression"));Object.defineProperty(t,"SExpression",{enumerable:!0,get:function(){return F.SExpression}})},{"../Ion":5,"../IonBinaryReader":7,"../IonTextReader":25,"./Blob":33,"./Boolean":34,"./Clob":35,"./Decimal":36,"./Float":37,"./Integer":39,"./List":41,"./Null":43,"./SExpression":44,"./String":46,"./Struct":47,"./Symbol":48,"./Timestamp":49,"./Value":50}],52:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.EventStreamError=void 0;class n extends Error{constructor(e,t,r,n){super(),this.type=e,this.index=r,this.message=t,this.eventstream=n}}r.EventStreamError=n},{}],53:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IonEventFactory=r.IonEventType=void 0;const l=e("../ComparisonResult"),n=e("../IonBinaryWriter"),i=e("../IonLocalSymbolTable"),s=e("../IonTextWriter"),o=e("../IonTypes"),a=e("../IonUnicode"),u=e("../IonWriteable");var h;(e=h=r.IonEventType||(r.IonEventType={}))[e.SCALAR=0]="SCALAR",e[e.CONTAINER_START=1]="CONTAINER_START",e[e.CONTAINER_END=2]="CONTAINER_END",e[e.SYMBOL_TABLE=3]="SYMBOL_TABLE",e[e.STREAM_END=4]="STREAM_END";class _{constructor(e,t,r,n,i,s){this.eventType=e,this.ionType=t,this.fieldName=r,this.annotations=n,this.depth=i,this.ionValue=s}write(e){e.stepIn(o.IonTypes.STRUCT),e.writeFieldName("event_type"),e.writeSymbol(h[this.eventType]),null!==this.ionType&&(e.writeFieldName("ion_type"),e.writeSymbol(this.ionType.name.toUpperCase())),null!==this.fieldName&&void 0!==this.fieldName&&(e.writeFieldName("field_name"),e.stepIn(o.IonTypes.STRUCT),e.writeFieldName("text"),e.writeString(this.fieldName),e.stepOut()),null!==this.annotations&&(e.writeFieldName("annotations"),this.writeAnnotations(e)),this.eventType===h.SCALAR&&this.writeValues(e),e.writeFieldName("depth"),e.writeInt(this.depth),e.stepOut()}writeAnnotations(t){if(void 0===this.annotations)t.writeNull(o.IonTypes.LIST);else{t.stepIn(o.IonTypes.LIST);for(let e=0;e=Number.MIN_SAFE_INTEGER&&e<=Number.MAX_SAFE_INTEGER}},{}],56:[function(e,t,r){function n(){return t.exports=n=Object.assign?Object.assign.bind():function(e){for(var t=1;t