@cloudflare/util-routes 5.1.112 → 5.1.113

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.1.113](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/util-routes@5.1.112...@cloudflare/util-routes@5.1.113) (2021-04-26)
7
+
8
+ **Note:** Version bump only for package @cloudflare/util-routes
9
+
10
+
11
+
12
+
13
+
6
14
  ## [5.1.112](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/util-routes@5.1.111...@cloudflare/util-routes@5.1.112) (2021-04-23)
7
15
 
8
16
  **Note:** Version bump only for package @cloudflare/util-routes
package/es/route.js CHANGED
@@ -1,34 +1,28 @@
1
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
-
3
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
2
 
5
3
  import pathToRegExp from 'path-to-regexp';
6
- export var RoutePatternResult =
7
- /**
8
- * Interperolate arguments into the route pattern
9
- */
10
- function RoutePatternResult(pattern) {
11
- _classCallCheck(this, RoutePatternResult);
4
+ export class RoutePatternResult {
5
+ /**
6
+ * Interperolate arguments into the route pattern
7
+ */
8
+ constructor(pattern) {
9
+ _defineProperty(this, "pattern", void 0);
12
10
 
13
- _defineProperty(this, "pattern", void 0);
11
+ _defineProperty(this, "toUrl", void 0);
14
12
 
15
- _defineProperty(this, "toUrl", void 0);
13
+ this.pattern = pattern;
14
+ this.toUrl = pathToRegExp.compile(this.pattern);
15
+ }
16
16
 
17
- this.pattern = pattern;
18
- this.toUrl = pathToRegExp.compile(this.pattern);
19
- };
17
+ }
20
18
  /**
21
19
  * Tag a template string with route data
22
20
  */
23
21
 
24
- export function route(strings) {
25
- for (var _len = arguments.length, paramNames = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
26
- paramNames[_key - 1] = arguments[_key];
27
- }
28
-
29
- var pattern = strings.reduce(function (accum, str, i) {
30
- var result = accum + str;
31
- var paramName = paramNames[i];
22
+ export function route(strings, ...paramNames) {
23
+ const pattern = strings.reduce((accum, str, i) => {
24
+ let result = accum + str;
25
+ const paramName = paramNames[i];
32
26
 
33
27
  if (paramName instanceof RoutePatternResult) {
34
28
  result += paramName.pattern;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudflare/util-routes",
3
3
  "description": "Wraps path-to-regexp with a convenient, type-safe tagged template function",
4
- "version": "5.1.112",
4
+ "version": "5.1.113",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -21,8 +21,8 @@
21
21
  "autoGeneratedReadme": false
22
22
  },
23
23
  "dependencies": {
24
- "@cloudflare/types": "^6.7.25",
24
+ "@cloudflare/types": "^6.7.26",
25
25
  "path-to-regexp": "^3.0.0"
26
26
  },
27
- "gitHead": "3b74aee5f2437d3981de017126c02cd66ffbeb2d"
27
+ "gitHead": "11b4b0406288199b69d9dd931997d56b2be20e8c"
28
28
  }