# mysterialise

> Serialise and De-Serialise JavaScript data types including "Array" | "Date" | "RegExp" | "Buffer" | "string" | "number" | "boolean" | "object" | "null" | "undefined" data types

Latest version **1.2.8** (published 2025-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install mysterialise
pnpm add mysterialise
yarn add mysterialise
bun add mysterialise
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.8 |
| Published | 2025-07-31 |
| First published | 2024-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 27.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | friedpanseller |
| Maintainers | friedpanseller |
| Keywords | serialise, deserialise, unserialise |

## Links

- npm: https://www.npmjs.com/package/mysterialise
- Repository: https://github.com/friedpanseller/mysterialise
- Homepage: https://github.com/friedpanseller/mysterialise#readme
- Issues: https://github.com/friedpanseller/mysterialise/issues
- npm.io page: https://npm.io/package/mysterialise

## Recent versions

- 1.2.8 (latest) — 2025-07-31
- 1.2.7 — 2024-02-20
- 1.2.6 — 2024-02-05
- 1.2.5 — 2024-02-05
- 1.2.4 — 2024-02-05
- 1.2.3 — 2024-02-05
- 1.2.2 — 2024-02-05
- 1.2.1 — 2024-02-05
- 1.2.0 — 2024-02-05
- 1.1.2 — 2024-02-05
- 1.1.1 — 2024-02-05
- 1.1.0 — 2024-02-05
- 1.0.0 — 2024-02-05

## README

# Mysterialise
### Mysterious Serialisation of JavaScript data
Mysterialise will serialise a variety of NodeJS data types into a string to then deserialise later. This expands on the functionality of `JSON.stringify` as it does not handle `Buffer` and `Date` types very elegantly.

#### Issues with JSON Serialisation
1. `JSON.parse(JSON.stringify(new Date()))` becomes `"2024-02-05T00:58:08.999Z"` instead of `Date` object  
1. `JSON.parse(JSON.stringify(Buffer.from([16,24,36])))` becomes `{ type: 'Buffer', data: [ 16, 24, 36 ] }` instead of `Buffer` object  

#### Supported Data Types
Mysterialise supports nested objects and nested arrays, as well as the following types:
- `Array`
- `Date`
- `RegExp`
- `Buffer`
- `string`
- `number`
- `boolean`
- `object`
- `null`
- `undefined`

## Usage
```ts
import { mystify, clarify } from "mysterialise";

// Some complex or simple object
const obj = [{
    bird: "parrot",
    feet: 4,
    firstSeen: new Date()
}, "cage", {
    contents: [
        1,
        {
            name: "dog",
            sound: undefined,
            video: Buffer.from([12,24,48])
        },
        null
    ]
}]

// String version of the above object
const seralised = mystify(obj);
// {"t":1,"d":[{"t":"obj...
console.log(serialised);

// Original object version of the above object
const unserialised = clarify(serialised);
// dog
console.log(unserialised[2].contents[1].name);
```

## Install
```
npm i mysterialise
```

---
_Source: https://npm.io/package/mysterialise · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
