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 - npm Package Compare versions

Comparing version 0.4.2 to 0.4.3

8

index.js

@@ -12,2 +12,4 @@ /*!

var equal = require('is-equal-shallow');
var basic = {};
var cache = {};

@@ -37,3 +39,3 @@ /**

}
return basic[key] || (basic[key] = fn());
return basic[key] || (basic[key] = fn(str));
}

@@ -68,3 +70,3 @@

var cache = module.exports.cache = {};
var basic = module.exports.basic = {};
module.exports.cache = cache;
module.exports.basic = basic;
{
"name": "regex-cache",
"description": "Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of the same string and options, resulting in dramatic speed improvements.",
"version": "0.4.2",
"description": "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.",
"version": "0.4.3",
"homepage": "https://github.com/jonschlinkert/regex-cache",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/regex-cache.git"
},
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "jonschlinkert/regex-cache",
"bugs": {
"url": "https://github.com/jonschlinkert/regex-cache/issues"
},
"license": {
"type": "MIT",
"url": "https://github.com/jonschlinkert/regex-cache/blob/master/LICENSE"
},
"license": "MIT",
"files": [

@@ -33,11 +24,11 @@ "index.js"

"dependencies": {
"is-equal-shallow": "^0.1.1",
"is-equal-shallow": "^0.1.3",
"is-primitive": "^2.0.0"
},
"devDependencies": {
"benchmarked": "^0.1.4",
"chalk": "^1.0.0",
"micromatch": "^2.1.0",
"mocha": "^2.1.0",
"should": "*"
"benchmarked": "^0.1.5",
"chalk": "^1.1.3",
"gulp-format-md": "^0.1.7",
"micromatch": "^2.3.7",
"should": "^8.3.0"
},

@@ -53,3 +44,20 @@ "keywords": [

"to-regex"
]
],
"verb": {
"run": true,
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"reflinks": [
"verb"
],
"lint": {
"reflinks": true
}
}
}

@@ -1,14 +0,16 @@

# regex-cache [![NPM version](https://badge.fury.io/js/regex-cache.svg)](http://badge.fury.io/js/regex-cache) [![Build Status](https://travis-ci.org/jonschlinkert/regex-cache.svg)](https://travis-ci.org/jonschlinkert/regex-cache)
# regex-cache [![NPM version](https://img.shields.io/npm/v/regex-cache.svg?style=flat)](https://www.npmjs.com/package/regex-cache) [![NPM downloads](https://img.shields.io/npm/dm/regex-cache.svg?style=flat)](https://npmjs.org/package/regex-cache) [![Build Status](https://img.shields.io/travis/jonschlinkert/regex-cache.svg?style=flat)](https://travis-ci.org/jonschlinkert/regex-cache)
> Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of the same string and options, resulting in dramatic speed improvements.
> 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.
- Read [what this does](#what-this-does).
- See [the benchmarks](#benchmarks)
## Install
## Install with [npm](npmjs.org)
Install with [npm](https://www.npmjs.com/):
```bash
npm i regex-cache --save
```sh
$ npm install regex-cache --save
```
* Read [what this does](#what-this-does).
* See [the benchmarks](#benchmarks)
## Usage

@@ -25,3 +27,3 @@

If you want to cache a regex after calling `new RegExp()`, or you're requiring a module that returns a regex, wrap it with a function first:
If you want to cache a regex after calling `new RegExp()`, or you're requiring a module that returns a regex, wrap it with a function first:

@@ -50,3 +52,2 @@ ```js

### Example benchmarks

@@ -114,6 +115,5 @@

## What this does
If you're using `new RegExp('foo')` instead of a regex literal, it's probably because you need to dyamically generate a regex based on user options or some other potentially changing factors.
If you're using `new RegExp('foo')` instead of a regex literal, it's probably because you need to dyamically generate a regex based on user options or some other potentially changing factors.

@@ -123,30 +123,42 @@ When your function creates a string based on user inputs and passes it to the `RegExp` constructor, regex-cache caches the results. The next time the function is called if the key of a cached regex matches the user input (or no input was given), the cached regex is returned, avoiding unnecessary runtime compilation.

Using the RegExp constructor offers a lot of flexibility, but the runtime compilation comes at a price - it's slow. Not specifically because of the call to the RegExp constructor, but **because you have to build up the string before `new RegExp()` is even called**.
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/regex-cache/issues/new).
## Run tests
## Building docs
Generate readme and API documentation with [verb](https://github.com/verbose/verb):
```sh
$ npm install verb && npm run docs
```
Or, if [verb](https://github.com/verbose/verb) is installed globally:
```sh
$ verb
```
## Running tests
Install dev dependencies:
```bash
npm i -d && npm test
```sh
$ npm install -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/regex-cache/issues)
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/regex-cache/blob/master/LICENSE).
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 25, 2015._
[mentions-regex]: https://github.com/regexps/mentions-regex
_This file was generated by [verb](https://github.com/verbose/verb), v, on April 01, 2016._

Sorry, the diff of this file is not supported yet

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