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

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
Weekly downloads
11M
decreased by-9.31%
Maintainers
5
Install size
1.63 MB
Created
Weekly downloads
 

Changelog

Source

27.4.0

Features

  • [expect] Enhancing the toHaveProperty matcher to support array selection (#12092)
  • [jest-core] Add support for testResultsProcessor written in ESM (#12006)
  • [jest-diff, pretty-format] Add compareKeys option for custom sorting of object keys (#11992)
  • [jest-mock] Add ts-jest mock util functions (#12089)

Fixes

  • [expect] Allow again expect.Matchers generic with single value (#11986)
  • [jest-circus, jest-jasmine2] Avoid false concurrent test failures due to unhandled promise rejections (#11987)
  • [jest-config] Add missing slash dependency to package.json (#12080)
  • [jest-core] Incorrect detection of open ZLIB handles (#12022)
  • [jest-diff] Break dependency cycle (#10818)
  • [jest-environment-jsdom] Add @types/jsdom dependency (#11999)
  • [jest-environment-jsdom] Do not reset the global.document too early on teardown (#11871)
  • [jest-transform] Improve error and warning messages (#11998)
  • [jest-worker] Pass execArgv correctly to worker_threads worker (#12069)

Chore & Maintenance

  • [docs] CLI options alphabetized (#11586)
  • [jest-runner] Add info regarding timers to forcedExit message(#12083)
  • [*] Replaced substr method with substring (#12066)
  • [*] Add types entry to all export maps (#12073)

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 {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 29 Nov 2021

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