Socket
Socket
Sign inDemoInstall

jest-serializer

Package Overview
Dependencies
0
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jest-serializer

Module for serializing and deserializing object into memory and disk. By default, the `v8` implementations are used, but if not present, it defaults to `JSON` implementation. Both serializers have the advantage of being able to serialize `Map`, `Set`, `un


Version published
Maintainers
1
Install size
7.02 kB
Created

Changelog

Source

22.4.0

Fixes

  • [jest-haste-map] Overhauls how Watchman crawler works fixing Windows (#5615)
  • [expect] Allow matching of Errors against plain objects (#5611)
  • [jest-haste-map] Do not read binary files in Haste, even when instructed to do so (#5612)
  • [jest-cli] Don't skip matchers for exact files (#5582)
  • [docs] Update discord links (#5586)
  • [jest-runtime] Align handling of testRegex on Windows between searching for tests and instrumentation checks (#5560)
  • [jest-config] Make it possible to merge transform option with preset (#5505)
  • [jest-util] Fix console.assert behavior in custom & buffered consoles (#5576)

Features

  • [docs] Add MongoDB guide (#5571)
  • [jest-runtime] Deprecate mapCoverage option. (#5177)
  • [babel-jest] Add option to return sourcemap from the transformer separately from source. (#5177)
  • [jest-validate] Add ability to log deprecation warnings for CLI flags. (#5536)
  • [jest-serializer] Added new module for serializing. Works using V8 or JSON (#5609)
  • [docs] Add a documentation note for project displayName configuration (#5600)

Chore & Maintenance

  • [docs] Update automatic mocks documentation (#5630)

Readme

Source

jest-serializer

Module for serializing and deserializing object into memory and disk. By default, the v8 implementations are used, but if not present, it defaults to JSON implementation. Both serializers have the advantage of being able to serialize Map, Set, undefined, NaN, etc, although the JSON one does it through a replacer/reviver.

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 {serialize, deserialize} 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 20 Feb 2018

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