github amazon-ion/ion-js v4.0.0

latest releases: v5.2.1, v5.2.0, v5.1.0...
4 years ago

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.Value interface, 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 Writer using:
      ionValue.writeTo(writer);
    • Write Ion values to a Uint8Array or string using:
      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.
  • IonWriter#writeValues(reader: Reader) will now work when the Reader and Writer are positioned at depths greater than zero.
  • Calling stepOut() when the Reader is at the top level will now throw.
  • Downconversions from JSBI to Number now gracefully lose precision rather than clamping values to the safely representable Number range.
  • Reader.value() is deprecated in favor of more strongly typed variants (stringValue(), decimalValue(), etc)
  • jsbi is now a peer dependency; in addition to depending on ion-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 $0 should have thrown when encountered in Reader.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, Reader state was not correctly reset after skipping values.
  • #515: \r\n escape 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.

Don't miss a new ion-js release

NewReleases is sending notifications on new releases.