Socket
Book a DemoInstallSign in
Socket

js-sion

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-sion

SION deserializer/serializer for ECMAScript

latest
Source
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

ES2015 MIT LiCENSE build status

js-sion

SION deserializer/serializer for ECMAScript

Synopsis

import {SION} from './sion.js';
//...
let obj = SION.parse('["formats":["JSON","SION"]]');
let str = SION.stringify({formats: ["JSON", "SION"]});
//...

Usage

sion.js has no dependency so you can simply put it anywhere handy. It is a ES6 module so you need a faily modern environments.

on browsers

In your JS script:

import {SION} from './sion.js'; // or wherever you put it

Or in your HTML:

<script type="module">
  import {SION} from './sion.js';
</script>

You can even directly import from CDN:

<script type="module">
  import {SION} from 'https://cdn.jsdelivr.net/npm/js-sion@1.2.0/sion.min.js';
</script>

Tree-shaken import is also supported.

import {stringify, parse} from './sion.js';

Besides SION, the trunk, the follow symbols are exported:

  • RE_HEXFLOAT: a RegExp that matches hexadecimal floating-point number.
  • RE_HEXFLOAT_G: same as RE_HEXFLOAT with a 'g' flag.
  • parseHexFloat: parses hexadecimal floating point.
  • toHexString: prints number in hexadecimal floating point format.
  • stringify: cf. JSON.stringify. stringifies a JS object to a SION string.
  • parse: cf. JSON.parse. parses SION string to a JS object.
  • version: The version of module.

on node.js

Use node 16 or later that support native esm. You can also use use standard-things/esm.

$ npm install esm js-sion
$ node
> const SION = await import('js-sion');
undefined
> SION
[Module: null prototype] {
  RE_HEXFLOAT: /([+-]?)0x([0-9A-F]+).?([0-9A-F]*)p([+-]?[0-9]+)/i,
  RE_HEXFLOAT_G: /([+-]?)0x([0-9A-F]+).?([0-9A-F]*)p([+-]?[0-9]+)/gi,
  SION: {
    version: '1.2.0',
    RE_HEXFLOAT: /([+-]?)0x([0-9A-F]+).?([0-9A-F]*)p([+-]?[0-9]+)/i,
    RE_HEXFLOAT_G: /([+-]?)0x([0-9A-F]+).?([0-9A-F]*)p([+-]?[0-9]+)/gi,
    parseHexFloat: [Function: parseHexFloat],
    toHexString: [Function: toHexString],
    stringify: [Function: stringify],
    parse: [Function: parse]
  },
  parse: [Function: parse],
  parseHexFloat: [Function: parseHexFloat],
  stringify: [Function: stringify],
  toHexString: [Function: toHexString],
  version: '1.2.0'
}
> SION.parse('["formats":["JSON","SION"]]');
{ formats: [ 'JSON', 'SION' ] }
>  SION.stringify({formats: ["JSON", "SION"]});
'["formats":["JSON","SION"]]'

Keywords

SION

FAQs

Package last updated on 21 Feb 2022

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