Template Upload
This commit is contained in:
21
node_modules/regex-cache/LICENSE
generated
vendored
Normal file
21
node_modules/regex-cache/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2016, Jon Schlinkert.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
160
node_modules/regex-cache/README.md
generated
vendored
Normal file
160
node_modules/regex-cache/README.md
generated
vendored
Normal file
@ -0,0 +1,160 @@
|
||||
# regex-cache [](https://www.npmjs.com/package/regex-cache) [](https://npmjs.org/package/regex-cache) [](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 suprising performance improvements.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install regex-cache --save
|
||||
```
|
||||
|
||||
* Read [what this does](#what-this-does).
|
||||
* See [the benchmarks](#benchmarks)
|
||||
|
||||
## Usage
|
||||
|
||||
Wrap a function like this:
|
||||
|
||||
```js
|
||||
var cache = require('regex-cache');
|
||||
var someRegex = cache(require('some-regex-lib'));
|
||||
```
|
||||
|
||||
**Caching a regex**
|
||||
|
||||
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:
|
||||
|
||||
```js
|
||||
var cache = require('regex-cache');
|
||||
|
||||
function yourRegex(str, opts) {
|
||||
// do stuff to str and opts
|
||||
return new RegExp(str, opts.flags);
|
||||
}
|
||||
|
||||
var regex = cache(yourRegex);
|
||||
```
|
||||
|
||||
## Recommendations
|
||||
|
||||
### Use this when...
|
||||
|
||||
* **No options are passed** to the function that creates the regex. Regardless of how big or small the regex is, when zero options are passed, caching will be faster than not.
|
||||
* **A few options are passed**, and the values are primitives. The limited benchmarks I did show that caching is beneficial when up to 8 or 9 options are passed.
|
||||
|
||||
### Do not use this when...
|
||||
|
||||
* **The values of options are not primitives**. When non-primitives must be compared for equality, the time to compare the options is most likely as long or longer than the time to just create a new regex.
|
||||
|
||||
### Example benchmarks
|
||||
|
||||
Performance results, with and without regex-cache:
|
||||
|
||||
```bash
|
||||
# no args passed (defaults)
|
||||
with-cache x 8,699,231 ops/sec ±0.86% (93 runs sampled)
|
||||
without-cache x 2,777,551 ops/sec ±0.63% (95 runs sampled)
|
||||
|
||||
# string and six options passed
|
||||
with-cache x 1,885,934 ops/sec ±0.80% (93 runs sampled)
|
||||
without-cache x 1,256,893 ops/sec ±0.65% (97 runs sampled)
|
||||
|
||||
# string only
|
||||
with-cache x 7,723,256 ops/sec ±0.87% (92 runs sampled)
|
||||
without-cache x 2,303,060 ops/sec ±0.47% (99 runs sampled)
|
||||
|
||||
# one option passed
|
||||
with-cache x 4,179,877 ops/sec ±0.53% (100 runs sampled)
|
||||
without-cache x 2,198,422 ops/sec ±0.47% (95 runs sampled)
|
||||
|
||||
# two options passed
|
||||
with-cache x 3,256,222 ops/sec ±0.51% (99 runs sampled)
|
||||
without-cache x 2,121,401 ops/sec ±0.79% (97 runs sampled)
|
||||
|
||||
# six options passed
|
||||
with-cache x 1,816,018 ops/sec ±1.08% (96 runs sampled)
|
||||
without-cache x 1,157,176 ops/sec ±0.53% (100 runs sampled)
|
||||
|
||||
#
|
||||
# diminishing returns happen about here
|
||||
#
|
||||
|
||||
# ten options passed
|
||||
with-cache x 1,210,598 ops/sec ±0.56% (92 runs sampled)
|
||||
without-cache x 1,665,588 ops/sec ±1.07% (100 runs sampled)
|
||||
|
||||
# twelve options passed
|
||||
with-cache x 1,042,096 ops/sec ±0.68% (92 runs sampled)
|
||||
without-cache x 1,389,414 ops/sec ±0.68% (97 runs sampled)
|
||||
|
||||
# twenty options passed
|
||||
with-cache x 661,125 ops/sec ±0.80% (93 runs sampled)
|
||||
without-cache x 1,208,757 ops/sec ±0.65% (97 runs sampled)
|
||||
|
||||
#
|
||||
# when non-primitive values are compared
|
||||
#
|
||||
|
||||
# single value on the options is an object
|
||||
with-cache x 1,398,313 ops/sec ±1.05% (95 runs sampled)
|
||||
without-cache x 2,228,281 ops/sec ±0.56% (99 runs sampled)
|
||||
```
|
||||
|
||||
## Run benchmarks
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```bash
|
||||
npm i -d && npm run benchmarks
|
||||
```
|
||||
|
||||
## 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.
|
||||
|
||||
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).
|
||||
|
||||
## 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:
|
||||
|
||||
```sh
|
||||
$ npm install -d && npm test
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## 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](https://github.com/verbose/verb), v, on April 01, 2016._
|
69
node_modules/regex-cache/index.js
generated
vendored
Normal file
69
node_modules/regex-cache/index.js
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
/*!
|
||||
* regex-cache <https://github.com/jonschlinkert/regex-cache>
|
||||
*
|
||||
* Copyright (c) 2015 Jon Schlinkert.
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var isPrimitive = require('is-primitive');
|
||||
var equal = require('is-equal-shallow');
|
||||
var basic = {};
|
||||
var cache = {};
|
||||
|
||||
/**
|
||||
* Expose `regexCache`
|
||||
*/
|
||||
|
||||
module.exports = regexCache;
|
||||
|
||||
/**
|
||||
* Memoize the results of a call to the new RegExp constructor.
|
||||
*
|
||||
* @param {Function} fn [description]
|
||||
* @param {String} str [description]
|
||||
* @param {Options} options [description]
|
||||
* @param {Boolean} nocompare [description]
|
||||
* @return {RegExp}
|
||||
*/
|
||||
|
||||
function regexCache(fn, str, opts) {
|
||||
var key = '_default_', regex, cached;
|
||||
|
||||
if (!str && !opts) {
|
||||
if (typeof fn !== 'function') {
|
||||
return fn;
|
||||
}
|
||||
return basic[key] || (basic[key] = fn(str));
|
||||
}
|
||||
|
||||
var isString = typeof str === 'string';
|
||||
if (isString) {
|
||||
if (!opts) {
|
||||
return basic[str] || (basic[str] = fn(str));
|
||||
}
|
||||
key = str;
|
||||
} else {
|
||||
opts = str;
|
||||
}
|
||||
|
||||
cached = cache[key];
|
||||
if (cached && equal(cached.opts, opts)) {
|
||||
return cached.regex;
|
||||
}
|
||||
|
||||
memo(key, opts, (regex = fn(str, opts)));
|
||||
return regex;
|
||||
}
|
||||
|
||||
function memo(key, opts, regex) {
|
||||
cache[key] = {regex: regex, opts: opts};
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose `cache`
|
||||
*/
|
||||
|
||||
module.exports.cache = cache;
|
||||
module.exports.basic = basic;
|
122
node_modules/regex-cache/package.json
generated
vendored
Normal file
122
node_modules/regex-cache/package.json
generated
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"regex-cache@^0.4.2",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\micromatch"
|
||||
]
|
||||
],
|
||||
"_from": "regex-cache@>=0.4.2-0 <0.5.0-0",
|
||||
"_id": "regex-cache@0.4.3",
|
||||
"_inCache": true,
|
||||
"_location": "/regex-cache",
|
||||
"_nodeVersion": "5.5.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/regex-cache-0.4.3.tgz_1459536604904_0.22530420310795307"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "github@sellside.com",
|
||||
"name": "jonschlinkert"
|
||||
},
|
||||
"_npmVersion": "3.6.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "regex-cache",
|
||||
"raw": "regex-cache@^0.4.2",
|
||||
"rawSpec": "^0.4.2",
|
||||
"scope": null,
|
||||
"spec": ">=0.4.2-0 <0.5.0-0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/micromatch"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz",
|
||||
"_shasum": "9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "regex-cache@^0.4.2",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\micromatch",
|
||||
"author": {
|
||||
"name": "Jon Schlinkert",
|
||||
"url": "https://github.com/jonschlinkert"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/regex-cache/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-equal-shallow": "^0.1.3",
|
||||
"is-primitive": "^2.0.0"
|
||||
},
|
||||
"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.",
|
||||
"devDependencies": {
|
||||
"benchmarked": "^0.1.5",
|
||||
"chalk": "^1.1.3",
|
||||
"gulp-format-md": "^0.1.7",
|
||||
"micromatch": "^2.3.7",
|
||||
"should": "^8.3.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145",
|
||||
"tarball": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "06ce46bda29a19064a968bd5d2d5596440be05ca",
|
||||
"homepage": "https://github.com/jonschlinkert/regex-cache",
|
||||
"installable": true,
|
||||
"keywords": [
|
||||
"cache",
|
||||
"expression",
|
||||
"regex",
|
||||
"regexp",
|
||||
"regular",
|
||||
"regular expression",
|
||||
"store",
|
||||
"to-regex"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "jonschlinkert",
|
||||
"email": "github@sellside.com"
|
||||
},
|
||||
{
|
||||
"name": "doowb",
|
||||
"email": "brian.woodward@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "regex-cache",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jonschlinkert/regex-cache.git"
|
||||
},
|
||||
"scripts": {
|
||||
"benchmarks": "node benchmark",
|
||||
"test": "mocha"
|
||||
},
|
||||
"verb": {
|
||||
"layout": "default",
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
},
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"reflinks": [
|
||||
"verb"
|
||||
],
|
||||
"run": true,
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"toc": false
|
||||
},
|
||||
"version": "0.4.3"
|
||||
}
|
Reference in New Issue
Block a user