npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-sion

v1.2.0

Published

SION deserializer/serializer for ECMAScript

Downloads

4

Readme

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/[email protected]/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"]]'