Skip to content

darrenlangley/ssz-js

 
 

Repository files navigation

ssz-js

Simple Serialize in pure Javascript (SSZ)

TEST BRANCH

Install:

$ npm install ssz

Install mocha globally:

$ npm install -g mocha

Run tests:

$ npm test

Usage

Table of Contents

serialize

src/index.js:13-109

Simply Serializes (SSZ)

Parameters

  • value (Buffer | array | number | object) Value to serialize: hash32 (Buffer) | address (Buffer) | int8/16/32 | bytes (Buffer) | array | object
  • type (string | object) A type string ('hash32', 'address', 'int8', 'int16', 'int32', 'bytes'), or type array ['hash32'], or type object containing fields property

Returns Buffer the byte output

deserialize

src/index.js:118-232

Simply Deserializes (SSZ)

Parameters

  • data Buffer bytes (buffer) to deserialize
  • type (string | object) A type string ('hash32', 'address', 'int8', 'int16', 'int32', 'bytes'), or type array ['hash32'], or type object containing fields property

Returns (Buffer | array | number | 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:241-245

Checks if 2 simply serialized objects are equal (SSZ)

Parameters

  • x Buffer simply serialized object
  • y Buffer simply serialized object

Returns Bool the byte output

deepcopy

src/index.js:253-256

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

Parameters

Returns Buffer the deep copy of x

Contributors

Very special thank you to Darren Langley for helping build this.

About

Simple Serialized in pure Javascript

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%