• Stars
    star
    323
  • Rank 129,306 (Top 3 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created almost 8 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A JavaScript implementation of Amazon Ion.

Amazon Ion JavaScript

An implementation of Amazon Ion for JavaScript written in TypeScript.

NPM Version License Documentation

This package is tested with Node JS major versions 14, 16, and 18. While this library should be usable within browsers that support ES5+, please note that it is not currently being tested in any browser environments.

Getting Started

You can use this library either as a Node.js module or inside an HTML page.

NPM

  1. Add ion-js to your dependencies using npm

    npm install --save ion-js
    
  2. Use the library to read/write Ion data. Here is an example that reads Ion data from a JavaScript string:

    let ion = require("ion-js");
    
    // Reading
    let ionData = '{ greeting: "Hello", name: "Ion" }';
    let value = ion.load(ionData);
    console.log(value.greeting + ", " + value.name + "!");
    
    // Writing
    let ionText = ion.dumpText(value);
    console.log("Serialized Ion: " + ionText);

    For more examples, see the Ion DOM README.

Try it yourself.

Note: if your package's public interface exposes part of this library, this library should be specified as a peer dependency in your package's package.json file. Otherwise, packages that depend on your package and this library may experience unexpected behavior, as two installations of this library (even if the same version) are not designed or tested to behave correctly.

Web Browser

You can include the Ion-js bundle (ES5 compatible) using the URLs

These will create and initialize window.ion which has the same exact API as our npm package. Here is an example

<html>
<head>
  <meta charset="UTF-8"/>
  <script src="scripts/ion-bundle.min.js"></script>

  <!-- more HTML/JS code that can now use `window.ion` to create/write Ion -->
</head>
</html>

API

TypeDoc generated documentation can be found at here. Please note that anything not documented in the the API documentation is not supported for public use and is subject to change in any version.

Git Setup

This repository contains a git submodule called ion-tests, which holds test data used by ion-js's unit tests.

The easiest way to clone the ion-js repository and initialize its ion-tests submodule is to run the following command.

$ git clone --recursive https://github.com/amazon-ion/ion-js.git ion-js

Alternatively, the submodule may be initialized independently from the clone by running the following commands.

$ git submodule init
$ git submodule update

Development

Use npm to setup the dependencies. In the project directory you can run the following:

$ npm install

Building the package can be done with the release script (which runs the tests).

$ npm run release

Tests can be run using npm as well

$ npm test

This package uses Grunt for its build tasks. For convenience, you may want to install this globally:

$ npm -g install grunt-cli
$ grunt release

Or you could use the locally installed Grunt:

$ ./node_modules/.bin/grunt release

Build Output

The build above will compile the library into the dist directory. This directory has subdirectories of the form <module type>/<target ES version>. In general, we target ES6 and rely on polyfills to support earlier versions.

  • dist/es6/es6 - Targets the ES6 module system and ES6
  • dist/commonjs/es6 - Targets the CommonJS module system and ES6
  • dist/amd/es6 - Targets the AMD module system and ES6

A distribution using browserify and babelify creates a browser friendly polyfilled distribution targeting ES5: at dist/browser/js/ion-bundle.js.

Ion Specification Support

Types IonText IonBinary Limitations
null yes yes none
bool yes yes none
int yes yes underscores, binary digits
float yes yes underscores
decimal yes yes none
timestamp yes yes none
string yes yes none
symbol yes yes $0, symbol tokens
blob yes yes none
clob yes yes none
struct yes yes none
list yes yes none
sexp yes yes none
annotations yes yes none
local symbol tables yes yes none
shared symbol tables no yes none

Notes:

  • test/iontests.ts defines multiple skipList variables referencing test vectors that are not expected to work at this time.

  • ion-js supports shared symbol table for Ion Binary. Below is an example of how shared symbol table can be used here:

// Create a SharedSymbolTable with the desired strings
let sharedSymbolTable = new SharedSymbolTable('foo', 1, ['id', 'name']);
// Define an import chain
// The system symbol table does not import any other tables (`null` below)
let systemSymbolTableImport = new Import(null, getSystemSymbolTable());
// The shared symbol table imports the system symbol table
let sharedSymbolTableImport = new Import(systemSymbolTableImport, sharedSymbolTable);
// Create a local symbol table that imports the shared symbol table
let localSymbolTable = new LocalSymbolTable(sharedSymbolTableImport);
// Create a writer that uses our new local symbol table
let writer = new BinaryWriter(localSymbolTable, new Writeable());

// Write id and name fields in a struct
writer.stepIn(IonTypes.STRUCT);
writer.writeFieldName("id");
writer.writeInt(5);
writer.writeFieldName("name");
writer.writeString("Max");
writer.stepOut();
writer.close();

// Create a catalog with shared symbol table
let catalog = new Catalog();
catalog.add(sharedSymbolTable);

// Create a reader with catalog
let bytes = writer.getBytes();
let reader = new BinaryReader(new BinarySpan(bytes), catalog);

Contributing

See CONTRIBUTING.md

License

This library is licensed under Apache License version 2.0

Links

For more information about Ion or its other implementation, please see:

More Repositories

1

style-dictionary

A build system for creating cross-platform styles.
JavaScript
3,855
star
2

computer-vision-basics-in-microsoft-excel

Computer Vision Basics in Microsoft Excel (using just formulas)
2,391
star
3

selling-partner-api-docs

This repository contains documentation for developers to use to call Selling Partner APIs.
1,541
star
4

smoke-framework

A light-weight server-side service framework written in the Swift programming language.
Swift
1,430
star
5

alexa-skills-kit-js

SDK and example code for building voice-enabled skills for the Amazon Echo.
1,134
star
6

ion-java

Java streaming parser/serializer for Ion.
Java
840
star
7

sketch-constructor

Read/write/manipulate Sketch files in Node without Sketch plugins!
JavaScript
538
star
8

selling-partner-api-models

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.
Mustache
532
star
9

pecos

PECOS - Prediction for Enormous and Correlated Spaces
Python
501
star
10

amzn-drivers

Official AWS drivers repository for Elastic Network Adapter (ENA) and Elastic Fabric Adapter (EFA)
C
444
star
11

convolutional-handwriting-gan

ScrabbleGAN: Semi-Supervised Varying Length Handwritten Text Generation (CVPR20)
Python
260
star
12

xfer

Transfer Learning library for Deep Neural Networks.
Python
250
star
13

awsssmchaosrunner

Amazon's light-weight library for chaos engineering on AWS. It can be used for EC2 and ECS (with EC2 launch type).
Kotlin
247
star
14

ion-python

A Python implementation of Amazon Ion.
Python
210
star
15

amazon-pay-sdk-php

Amazon Pay PHP SDK
PHP
209
star
16

fire-app-builder

Fire App Builder is a framework for building java media apps for Fire TV, allowing you to add your feed of media content to a configuration file and build an app to browse and play it quickly.
Java
178
star
17

exoplayer-amazon-port

Official port of ExoPlayer for Amazon devices
Java
168
star
18

oss-dashboard

A dashboard for viewing many GitHub organizations at once.
Ruby
158
star
19

ion-c

A C implementation of Amazon Ion.
C
149
star
20

metalearn-leap

Original PyTorch implementation of the Leap meta-learner (https://arxiv.org/abs/1812.01054) along with code for running the Omniglot experiment presented in the paper.
Python
147
star
21

ion-go

A Go implementation of Amazon Ion.
Go
146
star
22

distance-assistant

Pedestrian monitor that provides visual feedback to help ensure proper social distancing guidelines are being observed
Python
135
star
23

auction-gym

AuctionGym is a simulation environment that enables reproducible evaluation of bandit and reinforcement learning methods for online advertising auctions.
Jupyter Notebook
135
star
24

hawktracer

HawkTracer is a highly portable, low-overhead, configurable profiling tool built in Amazon Video for getting performance metrics from low-end devices.
C++
131
star
25

trans-encoder

Trans-Encoder: Unsupervised sentence-pair modelling through self- and mutual-distillations
Python
131
star
26

smoke-aws

AWS services integration for the Smoke Framework
Swift
109
star
27

amazon-payments-magento-2-plugin

Extension to enable Amazon Pay on Magento 2
PHP
105
star
28

MXFusion

Modular Probabilistic Programming on MXNet
Python
102
star
29

amazon-weak-ner-needle

Named Entity Recognition with Small Strongly Labeled and Large Weakly Labeled Data
Python
99
star
30

amazon-advertising-api-php-sdk

⛔️ DEPRECATED - Amazon Advertising API PHP Client Library
PHP
93
star
31

ion-rust

Rust implementation of Amazon Ion
Rust
86
star
32

ads-advanced-tools-docs

Code samples and supplements for the Amazon Ads advanced tools center
Jupyter Notebook
83
star
33

image-to-recipe-transformers

Code for CVPR 2021 paper: Revamping Cross-Modal Recipe Retrieval with Hierarchical Transformers and Self-supervised Learning
Python
82
star
34

oss-attribution-builder

The OSS Attribution Builder is a website that helps teams create attribution documents (notices, "open source screens", credits, etc) commonly found in software products.
TypeScript
79
star
35

smoke-http

Specialised HTTP Client for service operations abstracted from the HTTP protocol.
Swift
69
star
36

amazon-ray

Staging area for ongoing enhancements to Ray focused on improving integration with AWS and other Amazon technologies.
Python
66
star
37

alexa-coho

Sample code for building skill adapters for Alexa Connected Home using the Lighting API
JavaScript
62
star
38

amazon-pay-sdk-ruby

Amazon Pay Ruby SDK
Ruby
58
star
39

amazon-pay-sdk-java

Amazon Pay Java SDK
Java
53
star
40

amazon-pay-sdk-python

Amazon Pay Python SDK
Python
53
star
41

zero-shot-rlhr

Python
51
star
42

supply-chain-simulation-environment

Python
49
star
43

amazon-pay-sdk-csharp

Amazon Pay C# SDK
C#
47
star
44

ion-dotnet

A .NET implementation of Amazon Ion.
C#
47
star
45

multiconer-baseline

Python
47
star
46

amazon-pay-api-sdk-php

Amazon Pay API SDK (PHP)
PHP
47
star
47

zeek-plugin-enip

Zeek network security monitor plugin that enables parsing of the Ethernet/IP and Common Industrial Protocol standards
Zeek
45
star
48

amazon-pay-sdk-samples

Amazon Pay SDK Sample Code
PHP
43
star
49

oss-contribution-tracker

Track contributions made to external projects and manage CLAs
TypeScript
40
star
50

amazon-s3-gst-plugin

A collection of Amazon S3 GStreamer elements.
C
40
star
51

fashion-attribute-disentanglement

Python
39
star
52

zeek-plugin-s7comm

Zeek network security monitor plugin that enables parsing of the S7 protocol
Zeek
39
star
53

milan

Milan is a Scala API and runtime infrastructure for building data-oriented systems, built on top of Apache Flink.
Scala
39
star
54

selling-partner-api-samples

Sample code for Amazon Selling Partner API use cases
Python
37
star
55

orthogonal-additive-gaussian-processes

Light-weighted code for Orthogonal Additive Gaussian Processes
Python
37
star
56

jekyll-doc-project

This repository contains an open-source Jekyll theme for authoring and publishing technical documentation. This theme is used by Appstore/Alexa tech writers and other community members. Most of the theme's files are stored in a Ruby Gem (called jekyll-doc-project).
HTML
36
star
57

smoke-dynamodb

SmokeDynamoDB is a library to make it easy to use DynamoDB from Swift-based applications, with a particular focus on usage with polymorphic database tables (tables that do not have a single schema for all rows).
Swift
34
star
58

amazon-pay-api-sdk-nodejs

Amazon Pay API SDK (Node.js)
JavaScript
34
star
59

zeek-plugin-bacnet

Zeek network security monitor plugin that enables parsing of the BACnet standard building controls protocol
Zeek
30
star
60

ss-aga-kgc

Python
30
star
61

chalet-charging-location-for-electric-trucks

Optimization tool to identify charging locations for electric trucks
Python
30
star
62

amazon-pay-api-sdk-java

Amazon Pay API SDK (Java)
Java
29
star
63

credence-to-causal-estimation

A framework for generating complex and realistic datasets for use in evaluating causal inference methods.
Python
29
star
64

sparse-vqvae

Experimental implementation for a sparse-dictionary based version of the VQ-VAE2 paper
Python
28
star
65

zeek-plugin-profinet

Zeek network security monitor plugin that enables parsing of the Profinet protocol
Zeek
28
star
66

ion-tests

Test vectors for testing compliant Ion implementations.
25
star
67

differential-privacy-bayesian-optimization

This repo contains the underlying code for all the experiments from the paper: "Automatic Discovery of Privacy-Utility Pareto Fronts"
Python
25
star
68

buy-with-prime-cdk-constructs

This package extends common CDK constructs with opinionated defaults to help create an organization strategy around infrastructure as code.
TypeScript
25
star
69

basis-point-sets

Python
24
star
70

ion-hive-serde

A Apache Hive SerDe (short for serializer/deserializer) for the Ion file format.
Java
24
star
71

zeek-plugin-tds

Zeek network security monitor plugin that enables parsing of the Tabular Data Stream (TDS) protocol
Zeek
24
star
72

ion-intellij-plugin

Support for Ion in Intellij IDEA.
Kotlin
23
star
73

ion-schema-kotlin

A Kotlin reference implementation of the Ion Schema Specification.
Kotlin
23
star
74

smoke-framework-application-generate

Code generator to generate SmokeFramework-based applications from service models.
Swift
23
star
75

emukit-playground

A web page explaining concepts of statistical emulation and making decisions under uncertainty in an interactive way.
JavaScript
22
star
76

ftv-livetv-sample-tv-app

Java
22
star
77

smoke-framework-examples

Sample applications showing the usage of the SmokeFramework and related libraries.
Swift
22
star
78

ion-hash-go

A Go implementation of Amazon Ion Hash.
Go
22
star
79

pretraining-or-self-training

Codebase for the paper "Rethinking Semi-supervised Learning with Language Models"
Python
22
star
80

tiny-attribution-generator

A small tool and library to create attribution notices from various formats
TypeScript
20
star
81

confident-sinkhorn-allocation

Pseudo-labeling for tabular data
Jupyter Notebook
20
star
82

ion-docs

Source for the GitHub Pages for Ion.
Java
19
star
83

autotrail

AutoTrail is a highly modular, partial automation workflow engine providing run time execution control
Python
19
star
84

git-commit-template

Set commit templates for git
JavaScript
19
star
85

smoke-aws-generate

Code generator to generate the SmokeAWS library from service models.
Swift
18
star
86

amazon-codeguru-profiler-for-spark

A Spark plugin for CPU and memory profiling
Java
17
star
87

smoke-aws-credentials

A library to obtain and assume automatically rotating AWS IAM roles written in the Swift programming language.
Swift
17
star
88

service-model-swift-code-generate

Modular code generator to generate Swift applications from service models.
Swift
17
star
89

amazon-pay-api-sdk-dotnet

Amazon Pay API SDK (.NET)
C#
17
star
90

sample-fire-tv-app-video-skill

This sample Fire TV app shows how to integrate an Alexa video skill in a simple, basic way.
Java
16
star
91

amazon-template-library

A collection of general purpose C++ utilities that play well with the Standard Library and Boost.
C++
16
star
92

ion-cli

Rust
15
star
93

refuel-open-domain-qa

Python
15
star
94

rheoceros

Cloud-based AI / ML workflow and data application development framework
Python
15
star
95

amazon-instant-access-sdk-php

PHP SDK to aid in 3p integration with Instant Access
PHP
14
star
96

amazon-mcf-plugin-for-magento-1

Plugin code to enable Amazon MCF in Magento 1.
PHP
14
star
97

login-with-amazon-wordpress

A pre-integrated plugin that can be installed into a Wordpress powered website to integrate with Login with Amazon.
PHP
14
star
98

amzn-ec2-ena-utilities

Python
14
star
99

firetv-sample-touch-app

This sample Android project demonstrates how to build the main UI of a Fire TV application in order to support both Touch interactions and Remote D-Pad controls.
Java
13
star
100

eslint-plugin-no-date-parsing

Disallow string parsing with new Date and Date.parse.
TypeScript
13
star