Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ion-js

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ion-js

A JavaScript implementation of the Ion data interchange format

  • 3.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
increased by6.13%
Maintainers
1
Weekly downloads
 
Created
Source

Amazon Ion JavaScript

An implementation of Amazon Ion for JavaScript written in TypeScript.

NPM Version License Travis CI Status Documentation Semantic Releases

This package is designed with work with Node JS major versions 8, 10, and 12. Browser compatibility should be anything that supports ES5+.

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
    var ionJs = require("ion-js")
    
    var ionData = "{ hello: \"Ion\" }";
    var ionReader = ionJs.makeReader(ionData);
    ionReader.next();
    ionReader.stepIn();
    ionReader.next();
    var hello = ionReader.fieldName();
    var ion = ionReader.stringValue();
    ionReader.stepOut();
    console.log(ion.concat(", ").concat(hello));
    

Try it yourself.

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/amzn/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

TypesIonTextIonBinaryLimitations
nullyesyesnone
boolyesyesnone
intyesyesunderscores, binary digits
floatyesyesunderscores
decimalyesyesnone
timestampyesyesnone
stringyesyesnone
symbolyesyes$0, symbol tokens
blobyesyesnone
clobyesyesnone
structyesyesnone
listyesyesnone
sexpyesyesnone
annotationsyesyesnone
local symbol tablesyesyesnone
shared symbol tablesnononone

Notes:

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

Contributing

See CONTRIBUTE.md

License

This library is licensed under Apache License version 2.0

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

Keywords

FAQs

Package last updated on 29 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc