Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

regex-cache

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regex-cache

Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of the same string and options, resulting in suprising performance improvements.

  • 0.4.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
307K
decreased by-81.06%
Maintainers
2
Weekly downloads
 
Created

What is regex-cache?

The regex-cache npm package is designed to cache the results of regular expression operations to improve performance. It is particularly useful when the same regular expressions are used repeatedly, as it avoids the overhead of recompiling the regex each time.

What are regex-cache's main functionalities?

Caching Regular Expressions

This feature allows you to cache a regular expression. The first time the regex is used, it is compiled and cached. Subsequent uses of the same regex will retrieve it from the cache, improving performance.

const regexCache = require('regex-cache');
const re = regexCache(/foo/);
console.log(re.test('foo')); // true

Using Cached Regular Expressions

This feature demonstrates that the same regular expression is retrieved from the cache, ensuring that the same instance is used, which can save memory and processing time.

const regexCache = require('regex-cache');
const re1 = regexCache(/foo/);
const re2 = regexCache(/foo/);
console.log(re1 === re2); // true

Other packages similar to regex-cache

Keywords

FAQs

Package last updated on 01 Apr 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc