# ssz

> A pure JS implementation of simple serialize

Latest version **1.5.3** (published 2018-10-17) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.5.3 |
| Published | 2018-10-17 |
| First published | 2018-10-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 66 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | ChainSafe Systems and contributors |
| Maintainers | mikerah |
| Keywords | "ssz", "simple, serialize" |

## Links

- npm: https://www.npmjs.com/package/ssz
- Repository: https://github.com/ChainSafeSystems/ssz-js
- Homepage: https://github.com/ChainSafeSystems/ssz-js#readme
- Issues: https://github.com/ChainSafeSystems/ssz-js/issues
- npm.io page: https://npm.io/package/ssz

## Dependencies (2)

- [bn.js](https://npm.io/package/bn.js.md) ^4.11.8
- [deepcopy](https://npm.io/package/deepcopy.md) ^1.0.0

## Recent versions

- 1.5.3 (latest) — 2018-10-17
- 1.5.2 — 2018-10-15
- 1.5.1 — 2018-10-15
- 1.5.0 — 2018-10-14
- 0.5.0 — 2018-10-11

## README

# ssz-js

Simple Serialize (SSZ) in pure Javascript

Install:

```bash
$ npm install ssz
```

Install mocha globally:

```bash
$ npm install -g mocha
```

Run tests:

```bash
$ npm test
```

## Usage

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

-   [serialize](#serialize)
    -   [Parameters](#parameters)
-   [deserialize](#deserialize)
    -   [Parameters](#parameters-1)
-   [eq](#eq)
    -   [Parameters](#parameters-2)
-   [deepcopy](#deepcopy)
    -   [Parameters](#parameters-3)

### serialize

[src/index.js:13-116](https://github.com/ChainSafeSystems/ssz-js/blob/b3c0bbd5a7e10a802af963829901b9375331afb0/src/index.js#L13-L116 "Source code on GitHub")

Simply Serializes (SSZ)

#### Parameters

-   `value` **([Buffer](https://nodejs.org/api/buffer.html) \| [array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))** Value to serialize: hash32 (Buffer) | address (Buffer) | int8/16/32 | bytes (Buffer) | array | object
-   `type` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))** A type string ('hash32', 'address', 'int8', 'int16', 'int32', 'bytes', 'bool', 'hash96', 'hash97'), or type array ['hash32'], or type object containing fields property

Returns **[Buffer](https://nodejs.org/api/buffer.html)** the byte output

### deserialize

[src/index.js:125-252](https://github.com/ChainSafeSystems/ssz-js/blob/b3c0bbd5a7e10a802af963829901b9375331afb0/src/index.js#L125-L252 "Source code on GitHub")

Simply Deserializes (SSZ)

#### Parameters

-   `data` **[Buffer](https://nodejs.org/api/buffer.html)** bytes (buffer) to deserialize
-   `type` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))** A type string ('hash32', 'address', 'int8', 'int16', 'int32', 'bytes', 'bool', 'hash96', 'hash97'), or type array ['hash32'], or type object containing fields property

Returns **([Buffer](https://nodejs.org/api/buffer.html) \| [array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))** deserialized value : hash32 (Buffer) | address (Buffer) | int8/16/32/64/256 | uint8/16/32/64/256 | bytes (Buffer) | array | object

### eq

[src/index.js:261-265](https://github.com/ChainSafeSystems/ssz-js/blob/b3c0bbd5a7e10a802af963829901b9375331afb0/src/index.js#L261-L265 "Source code on GitHub")

Checks if 2 simply serialized objects are equal (SSZ)

#### Parameters

-   `x` **[Buffer](https://nodejs.org/api/buffer.html)** simply serialized object
-   `y` **[Buffer](https://nodejs.org/api/buffer.html)** simply serialized object

Returns **Bool** the byte output

### deepcopy

[src/index.js:273-276](https://github.com/ChainSafeSystems/ssz-js/blob/b3c0bbd5a7e10a802af963829901b9375331afb0/src/index.js#L273-L276 "Source code on GitHub")

Returns a deep copy of a simply serialized object (SSZ)

#### Parameters

-   `x` **[Buffer](https://nodejs.org/api/buffer.html)** Value to deep copy

Returns **[Buffer](https://nodejs.org/api/buffer.html)** the deep copy of x

## Contributors

Very special thank you to [Darren Langley](https://github.com/darrenlangley) for helping build this.

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