Releases: amazon-ion/ion-js
v4.0.1
Tweaks:
- #605:
PrettyTextWriterwrites a space after struct field name/colon pairs - #607: Text decimal values are written in scientific notation less often
- #614: Updates dependency versions in
package.json
Bug Fixes:
- #603:
- Fixed an issue that prevented very large containers from being instantiated
- Allowed
instanceof dom.Valueto work forObjectinstances that don't have aconstructor(like those produced byObject.create(null))
- #608: Added peer dependency instructions to the installation instructions
- #609: Fixed a link to the contributor documentation in
README.md - #611: Prevented
IonTextReader.annotations()from returning special strings in single quotes - #614: Fixed an issue in
FromJsConstructorthat became an error in more recent versions ofTypescript
Thanks to @oscarrodar and @bradley-curran for their contributions!
The complete list of commits included in v4.0.1 can be found here.
v4.0.0
API Changes
- This release adds a DOM-style API for easily working with Ion values in memory.
- Read Ion values from a stream using:
let ionValue = ion.load(dataSource);
- Ion values extend native JS types, so they are often interchangeable for the corresponding JS type.
let person = ion.load('{name: "Michelle", age: 46}'); console.log("Hello, " + person.name);
- Ion values implement the strongly-typed
dom.Valueinterface, making them straightforward to work with in TypeScript.let name: string = ion.load('{name: "Michelle", age: 46}').get('name').stringValue();
- Convert an existing JS value to an Ion value using:
let ionValue = ion.dom.Value.from(jsValue);
- Write Ion values to an existing Ion
Writerusing:ionValue.writeTo(writer);
- Write Ion values to a
Uint8Arrayorstringusing:let ionBytes = ion.dumpBinary(ionValue); let ionText = ion.dumpText(ionValue); let neatlySpacedIonText = ion.dumpPrettyText(ionValue);
- Down-convert Ion to a JSON string using:
let jsonText = JSON.stringify(ionValue);
- The DOM API leverages JS runtime features introduced in ES6, which is supported in all current versions of NodeJS (v10+) and all modern browsers. It is not supported in older runtimes.
- Read Ion values from a stream using:
IonWriter#writeValues(reader: Reader)will now work when theReaderandWriterare positioned at depths greater than zero.- Calling
stepOut()when theReaderis at the top level will nowthrow. - Downconversions from
JSBItoNumbernow gracefully lose precision rather than clamping values to the safely representableNumberrange. Reader.value()is deprecated in favor of more strongly typed variants (stringValue(),decimalValue(), etc)jsbiis now a peer dependency; in addition to depending onion-js, consumers are now required to declare a dependency on this package.
Bug Fixes
- #165: When reading Unicode escape sequences, the parser would sometimes treat code points as character codes.
- #478: Text symbol ID
$0should have thrown when encountered inReader.annotations()but didn't. - #513: Text symbol IDs (e.g.
$3) would be read literally ($3) rather than resolved ($ion_symbol_table). - #514: In some circumstances,
Readerstate was not correctly reset after skipping values. - #515:
\r\nescape sequence handling now adheres to the spec.
Work for this release was tracked in Milestone 4. The complete list of commits included in v4.0.0 can be found here.
v3.1.2
v3.1.1
v3.1.0
In addition to numerous bug fixes, this release adds support for arbitrary precision integers, decimals, and timestamps. It does not include support for:
- ints denoted in binary
- underscore characters in ints, decimals, or floats
- shared symbol tables
- symboltokens
- SID0 ($0)
Note: this release targets Node environments only and has not been verified to work in any browsers.
Associated milestone: M3.1
Full list of changes: v3.0.0..v3.1.0
API Changes
The following identifies API changes since v3.0.0. Additional information can be found in the API documentation. Anything not present in the API documentation is internal and subject to change in the future.
General
- added
IntSizeenum
Decimal
- added
constructor(decimalText: string) - added
constructor(coefficient: JSBI, exponent: number, isNegative?: boolean) - added
getCoefficient(): JSBI - added
getExponent(): number
Reader
- added
bigIntValue(): JSBI - added
intSize(): IntSize
Writer
- added
depth(): number - modified
writeInt(value: number | JSBI | null): voidsovaluemay be of typeJSBI
v3.0.0
This release includes many changes to the ion-js API. The following identifies API changes since 3.0.0-beta.3. Additional information can be found in the API documentation. Anything not present in the API documentation is internal and subject to change in the future.
The following are known limitations:
- int values are restricted to 32 bits: [-2147483648, 2147483647]
- character escape sequences are not fully supported in strings, symbols, and clobs
- no support for:
- ints denoted in binary
- underscore characters in ints, decimals, or floats
- shared symbol tables
- symboltokens
- SID0 (
$0)
Note: this release targets Node environments only and has not been verified to work in any browsers.
Associated milestone: Release V3.0
Full list of changes: v3.0.0-beta.3..v3.0.0
API Changes
General
- The API has been narrowed to the following modules:
- Ion
- Decimal
- Reader
- Timestamp
- Type
- Types
- Writer
- Callers using IonEventStream to transfer the contents of a reader to a writer should use the new
Writer.writeValue()orWriter.writeValues()methods instead
Ion
- removed:
asSpan()get_buf_type()isSourceType()makeBinaryReader(): usemakeReader()insteadmakeTextReader(): usemakeReader()instead
Decimal
- added:
ONEcompareTo()intValue()numberValue()
- modified:
- constructor now expects a coefficient and exponent, both numbers
toString()now returns a string using scientific notation if an exponent is needed
- removed:
NULLgetDigits()getExponent()getNumber(): usenumberValue()insteadisNegativeZero()isNull()isZero()isZeroZero()stringValue()
IonType
- renamed:
bidtobinaryTypeIdcontainertoisContainerlobtoisLobnumtoisNumericscalartoisScalar
IonTypes
- removed:
BOC,DATAGRAM
Reader
*Value()methods now return null instead of undefined.- added:
type()
- modified:
next()returns null when not positioned on a valuevalue()now throws for container typesbooleanValue()throws if the reader is not pointed at a BOOLEAN valuebyteValue()throws if the reader is not pointed at a CLOB or BLOB valuedecimalValue()throws if the reader is not pointed at a DECIMAL valuenumberValue()throws if the reader is not pointed at a INT or FLOAT valuestringValue()throws if the reader is not pointed at a STRING and SYMBOL valuetimestampValue()throws if the reader is not pointed at a TIMESTAMP value
Timestamp
- added:
compareTo()getDate()getSecondsDecimal()getSecondsInt()
- renamed:
getOffset()togetLocalOffset()
- modified:
- constructor signature has changed (removed precision; offset and year are now required; other parameters are optional; and seconds, if specified, must be a number or Decimal)
- removed:
checkValid()dataModelEquals(): usecompareTo()insteadgetEpochMilliseconds(): usegetDate().getTime()insteadgetZuluDay(): usegetDate().getUTCDate()insteadgetZuluHour(): usegetDate().getUTCHours()insteadgetZuluMinute(): usegetDate().getUTCMinutes()insteadgetZuluMonth(): usegetDate().getUTCMonth()insteadgetZuluSeconds(): usegetDate().getUTCSeconds()insteadgetZuluYear(): usegetDate().getUTCFullYear()insteadisNull()numberValue(): usegetDate().getTime()insteadstringValue(): usetoString()instead
TimestampPrecision (was Precision)
- removed:
EMPTY,NULL
Writer
- containers must now be explicitly closed (auto-close has been removed to avoid masking programming errors)
- annotations is no longer a parameter of individual
write*()methods; instead, calladdAnnotation()orsetAnnotations()prior to one of thewrite*()methods - null container values (
null.list,null.sexp,null.struct) are no longer written bywriteList([], true),writeSexp([], true), orwriteStruct([], true); these values are now written viawriteNull(IonTypes.LIST),writeNull(IonTypes.SEXP), andwriteNull(IonTypes.STRUCT) TypeCodeshas been removed in favor ofIonType/IonTypes- added:
writeValue()writeValues()
- modified:
writeNull(TypeCode)is nowwriteNull(IonType)
- renamed:
endContainer()tostepOut()writeList()tostepIn(IonTypes.LIST)writeSexp()tostepIn(IonTypes.SEXP)writeStruct()tostepIn(IonTypes.STRUCT)