Socket
Socket
Sign inDemoInstall

jest-haste-map

Package Overview
Dependencies
38
Maintainers
6
Versions
270
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-haste-map


Version published
Maintainers
6
Weekly downloads
31,182,394
decreased by-6.96%

Weekly downloads

Package description

What is jest-haste-map?

The jest-haste-map npm package is a utility for building a Haste map, which is a mapping from module names to file paths. It is used by Jest to quickly resolve module dependencies for tests by keeping an in-memory map of all available modules. It can handle duplicate module names and provides a way to query the map for a specific module.

What are jest-haste-map's main functionalities?

Building a Haste Map

This code sample demonstrates how to create a new HasteMap instance with a configuration object, build the map, and then use it to get the module name for a specific file.

const HasteMap = require('jest-haste-map');
const config = {
  // These options are required:
  roots: ['/path/to/project'],
  extensions: ['js', 'json'],
  platforms: ['ios', 'android'],
  // You can provide additional options:
  computeSha1: true,
  // other options...
};
const hasteMap = new HasteMap(config);
hasteMap.build().then(map => {
  console.log(map.hasteFS.getModuleName('/path/to/project/file.js'));
});

Querying the Haste Map

This code sample shows how to query the built Haste map for the path of a module given its name, platform, and whether it supports the native platform.

hasteMap.build().then(map => {
  const modulePath = map.moduleMap.getModule('moduleName', 'platform', 'supportsNativePlatform');
  console.log(modulePath);
});

Other packages similar to jest-haste-map

FAQs

Last updated on 25 Aug 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