Socket
Socket
Sign inDemoInstall

jest-serializer

Package Overview
Dependencies
3
Maintainers
5
Versions
63
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-serializer

> DEPRECATED: Use `v8` APIs directly: https://nodejs.org/api/v8.html#serialization-api


Version published
Maintainers
5
Weekly downloads
11,895,592
decreased by-8.4%

Weekly downloads

Readme

Source

jest-serializer

DEPRECATED: Use v8 APIs directly: https://nodejs.org/api/v8.html#serialization-api

Module for serializing and deserializing object into memory and disk. The Node core v8 implementations are used. This seriializer have the advantage of being able to serialize Map, Set, undefined, NaN, etc..

Install

$ yarn add jest-serializer

API

Three kinds of API groups are exposed:

In-memory serialization: serialize and deserialize

This set of functions take or return a Buffer. All the process happens in memory. This is useful when willing to transfer over HTTP, TCP or via UNIX pipes.

import {deserialize, serialize} from 'jest-serializer';

const myObject = {
  foo: 'bar',
  baz: [0, true, '2', [], {}],
};

const buffer = serialize(myObject);
const myCopyObject = deserialize(buffer);

Synchronous persistent filesystem: readFileSync and writeFileSync

This set of functions allow to send to disk a serialization result and retrieve it back, in a synchronous way. It mimics the fs API so it looks familiar.

import {readFileSync, writeFileSync} from 'jest-serializer';

const myObject = {
  foo: 'bar',
  baz: [0, true, '2', [], {}],
};

const myFile = '/tmp/obj';

writeFileSync(myFile, myObject);
const myCopyObject = readFileSync(myFile);

FAQs

Last updated on 25 Apr 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc