Skip to content

Quickstart

Getting started with @nhtio/serialization is quick and easy. Just follow the steps below and you'll be up and running in no time.

Prerequisites

Installation

You can install @nhtio/serialization directly from your preferred package manager

sh
npm i @nhtio/serialization
sh
pnpm add @nhtio/serialization
sh
yarn add @nhtio/serialization

Using

This library exports 4 main methods:

typescript
import {
    canSerialize,
    confirm,
    deserialize,
    serialize
} from '@nhtio/serialization'

To serialize a value, simply use the serialize method

typescript
const serialized = serialize(...);

To return the value to its initial state, use the deserialize method

typescript
const initial = deserialize(serialized);

Supported data types

This library wraps the v8:*serialize methods, adding support for the standard types supported out of the box by v8.serialize and v8.deserialize

Additionally, this library also supports serialization/deserialization of the following types: