1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports["default"] = void 0;
|
7 |
|
8 | var _LRUCache = _interopRequireDefault(require("./LRUCache"));
|
9 |
|
10 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
11 |
|
12 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
13 |
|
14 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
15 |
|
16 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | var RegExpCache =
|
23 |
|
24 | function () {
|
25 | function RegExpCache(size) {
|
26 | _classCallCheck(this, RegExpCache);
|
27 |
|
28 | this.cache = new _LRUCache["default"](size);
|
29 | }
|
30 |
|
31 | _createClass(RegExpCache, [{
|
32 | key: "getPatternForRegExp",
|
33 | value: function getPatternForRegExp(pattern) {
|
34 | var regExp = this.cache.get(pattern);
|
35 |
|
36 | if (!regExp) {
|
37 | regExp = new RegExp('^' + pattern);
|
38 | this.cache.put(pattern, regExp);
|
39 | }
|
40 |
|
41 | return regExp;
|
42 | }
|
43 | }]);
|
44 |
|
45 | return RegExpCache;
|
46 | }();
|
47 |
|
48 | exports["default"] = RegExpCache;
|
49 |
|
\ | No newline at end of file |