You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@erboladaiorg/earum-sequi

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@erboladaiorg/earum-sequi

**XtraJson** offers a flexible solution to transform objects into JSON-serializable representations and back. Unlike other solutions, such as [superjson](https://github.com/blitz-js/superjson), XtraJson efficiently handles transformations without unnecess


Version published
Weekly downloads
397
decreased by-8.94%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

XtraJson

XtraJson offers a flexible solution to transform objects into JSON-serializable representations and back. Unlike other solutions, such as superjson, XtraJson efficiently handles transformations without unnecessarily duplicating objects.

Features

  • Out-of-the-box support for undefined, Buffer, Date, BigInt.
  • Ability to handle any other type using custom transformers.
  • Faster and more efficient than superjson.

Why XtraJson?

While libraries like SuperJSON create a copy of any object, even if it doesn't need to be transformed, XtraJson ensures optimized and efficient transformations.

Usage

Basic Setup

import XtraJson from '@erboladaiorg/earum-sequi';

const xjs = new XtraJson();

Registering Custom Transformers

xjs.register({
    name: "my custom transformer",
    key: "c", // key should be unique and as short as possible
    isApplicable(value: unknown): value is MyClass {
        // Define when this transformer should be used
    },
    serialize(value) {
        // Convert your custom type to a JSON-serializable format
    },
    deserialize(value) {
        // Convert the JSON-serializable format back to your custom type
    }
});

Serialization & Deserialization

const data = xjs.serialize(payload); // Convert to a JSON-serializable object
const json = xjs.stringify(payload); // Convert to a JSON string

// Alternate methods using built-in JSON methods
const jsonAlt = JSON.stringify(payload, xjs.replacer); // Using XtraJson as a replacer
const resultAlt = JSON.parse(payload, xjs.reviver); // Using XtraJson as a reviver

const result = xjs.deserialize(data); // Convert back from a JSON-serializable object
const resultStr = xjs.parse(json); // Convert back from a JSON string

Keywords

FAQs

Package last updated on 25 Jul 2024

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc