Skip to content

Commit

Permalink
Merge pull request #5 from hatsyjs/v2
Browse files Browse the repository at this point in the history
ES2022
  • Loading branch information
surol committed Sep 17, 2023
2 parents 8660307 + 437a712 commit 0ec2b91
Show file tree
Hide file tree
Showing 64 changed files with 256 additions and 252 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hatsy/route-match",
"version": "1.4.2",
"version": "2.0.0-pre.0",
"description": "Route matching library",
"keywords": [
"path-matcher",
Expand All @@ -25,8 +25,8 @@
},
"sideEffects": false,
"dependencies": {
"@frontmeans/httongue": "^2.4.0",
"@proc7ts/primitives": "^3.0.2"
"httongue": "^3.1.0",
"@proc7ts/primitives": "^4.0.1"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
Expand Down
12 changes: 6 additions & 6 deletions src/classify-route-capture.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import type { Mock } from 'jest-mock';
import { classifyRouteCapture } from './classify-route-capture';
import { rcaptureEntry } from './matchers';
import type { PathRoute } from './path';
import type { RouteCaptor, RouteCaptorSignatureMap } from './route-captor';
import { routeMatch } from './route-match';
import { classifyRouteCapture } from './classify-route-capture.js';
import type { RouteCaptor, RouteCaptorSignatureMap } from './route-captor.js';
import { routeMatch } from './route-match.js';
import { RouteMatcher } from './route-matcher.js';
import { urlRoute } from './url';
import { rcaptureEntry } from './matchers/rcapture-entry.js';
import { PathRoute } from './path/path-route.js';
import { urlRoute } from './url/url-route.js';

describe('classifyRouteCapture', () => {
const pattern = [rcaptureEntry('out')];
Expand Down
4 changes: 2 additions & 2 deletions src/classify-route-capture.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { noop } from '@proc7ts/primitives';
import type { PathRoute } from './path';
import type { RouteCaptor, RouteCaptorSignatureMap } from './route-captor';
import type { RouteCaptor, RouteCaptorSignatureMap } from './route-captor.js';
import { PathRoute } from './path/path-route.js';

/**
* Route capture classifier.
Expand Down
13 changes: 0 additions & 13 deletions src/index.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/matchers/index.ts

This file was deleted.

10 changes: 10 additions & 0 deletions src/matchers/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export * from './rcapture-any.js';
export * from './rcapture-dirs.js';
export * from './rcapture-entry.js';
export * from './rcapture-regexp.js';
export * from './rmatch-any.js';
export * from './rmatch-dirs.js';
export * from './rmatch-entry.js';
export * from './rmatch-dir-sep.js';
export * from './rmatch-name.js';
export * from './rmatch-string.js';
14 changes: 7 additions & 7 deletions src/matchers/rcapture-any.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import { RouteCaptor } from '../route-captor';
import { routeMatch, RoutePattern } from '../route-match';
import { RouteCaptor } from '../route-captor.js';
import { routeMatch, RoutePattern } from '../route-match.js';
import { RouteMatcher } from '../route-matcher.js';
import { URLRoute, urlRoute } from '../url';
import { rcaptureAny } from './rcapture-any';
import { rmatchAny } from './rmatch-any';
import { rmatchDirSep } from './rmatch-dir-sep';
import { rmatchString } from './rmatch-string';
import { rcaptureAny } from './rcapture-any.js';
import { rmatchAny } from './rmatch-any.js';
import { rmatchDirSep } from './rmatch-dir-sep.js';
import { rmatchString } from './rmatch-string.js';
import { URLRoute, urlRoute } from '../url/url-route.js';

describe('rcaptureAny', () => {
let captor: RouteCaptor<URLRoute>;
Expand Down
2 changes: 1 addition & 1 deletion src/matchers/rcapture-any.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RouteMatcher } from '../route-matcher';
import type { RouteMatcher } from '../route-matcher.js';

/**
* Builds a route matcher that matches any part of entry name and optionally captures its name.
Expand Down
12 changes: 6 additions & 6 deletions src/matchers/rcapture-dirs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import { RouteCaptor } from '../route-captor';
import { routeMatch } from '../route-match';
import { RouteCaptor } from '../route-captor.js';
import { routeMatch } from '../route-match.js';
import { RouteMatcher } from '../route-matcher.js';
import { URLRoute, urlRoute } from '../url';
import { rcaptureDirs } from './rcapture-dirs';
import { rmatchDirSep } from './rmatch-dir-sep';
import { rmatchName } from './rmatch-name';
import { rcaptureDirs } from './rcapture-dirs.js';
import { rmatchDirSep } from './rmatch-dir-sep.js';
import { rmatchName } from './rmatch-name.js';
import { URLRoute, urlRoute } from '../url/url-route.js';

describe('rcaptureDirs', () => {
let captor: RouteCaptor<URLRoute>;
Expand Down
4 changes: 2 additions & 2 deletions src/matchers/rcapture-dirs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { valueProvider } from '@proc7ts/primitives';
import { routeMatch } from '../route-match';
import type { RouteMatcher } from '../route-matcher';
import { routeMatch } from '../route-match.js';
import type { RouteMatcher } from '../route-matcher.js';

/**
* Builds a route matcher that matches any number of directories, and captures them.
Expand Down
8 changes: 4 additions & 4 deletions src/matchers/rcapture-entry.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import { RouteCaptor } from '../route-captor';
import { routeMatch } from '../route-match';
import { RouteCaptor } from '../route-captor.js';
import { routeMatch } from '../route-match.js';
import { RouteMatcher } from '../route-matcher.js';
import { URLRoute, urlRoute } from '../url';
import { rcaptureEntry } from './rcapture-entry';
import { rcaptureEntry } from './rcapture-entry.js';
import { URLRoute, urlRoute } from '../url/url-route.js';

describe('rcaptureEntry', () => {
let captor: RouteCaptor<URLRoute>;
Expand Down
2 changes: 1 addition & 1 deletion src/matchers/rcapture-entry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RouteMatcher } from '../route-matcher';
import type { RouteMatcher } from '../route-matcher.js';

/**
* Builds a route matcher that matches any entry and captures its name.
Expand Down
10 changes: 5 additions & 5 deletions src/matchers/rcapture-regexp.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import type { Mock } from 'jest-mock';
import { routeMatch } from '../route-match';
import { urlRoute } from '../url';
import { rcaptureAny } from './rcapture-any';
import { rcaptureRegExp } from './rcapture-regexp';
import { rmatchAny } from './rmatch-any';
import { routeMatch } from '../route-match.js';
import { urlRoute } from '../url/url-route.js';
import { rcaptureAny } from './rcapture-any.js';
import { rcaptureRegExp } from './rcapture-regexp.js';
import { rmatchAny } from './rmatch-any.js';

describe('rcaptureRegExp', () => {
let captor: Mock<(kind: unknown, key: string | number, ...capture: any[]) => void>;
Expand Down
8 changes: 4 additions & 4 deletions src/matchers/rcapture-regexp.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { RouteCaptor } from '../route-captor';
import type { RouteMatch } from '../route-match';
import { routeMatch } from '../route-match';
import type { RouteMatcher } from '../route-matcher';
import type { RouteCaptor } from '../route-captor.js';
import type { RouteMatch } from '../route-match.js';
import { routeMatch } from '../route-match.js';
import type { RouteMatcher } from '../route-matcher.js';

const removeGlobalAndStickyFlagsPattern = /[gy]/;

Expand Down
10 changes: 5 additions & 5 deletions src/matchers/rmatch-any.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import { RouteCaptor } from '../route-captor';
import { routeMatch, RoutePattern } from '../route-match';
import { RouteCaptor } from '../route-captor.js';
import { routeMatch, RoutePattern } from '../route-match.js';
import { RouteMatcher } from '../route-matcher.js';
import { URLRoute, urlRoute } from '../url';
import { rmatchAny } from './rmatch-any';
import { rmatchDirSep } from './rmatch-dir-sep';
import { URLRoute, urlRoute } from '../url/url-route.js';
import { rmatchAny } from './rmatch-any.js';
import { rmatchDirSep } from './rmatch-dir-sep.js';

describe('rmatchAny', () => {
let captor: RouteCaptor<URLRoute>;
Expand Down
4 changes: 2 additions & 2 deletions src/matchers/rmatch-any.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RouteMatcher } from '../route-matcher';
import { rcaptureAny } from './rcapture-any';
import type { RouteMatcher } from '../route-matcher.js';
import { rcaptureAny } from './rcapture-any.js';

/**
* Route matcher that matches any part of the entry name.
Expand Down
12 changes: 6 additions & 6 deletions src/matchers/rmatch-dir-sep.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { describe, expect, it } from '@jest/globals';
import { routeMatch } from '../route-match';
import { urlRoute } from '../url';
import { rmatchAny } from './rmatch-any';
import { rmatchDirSep } from './rmatch-dir-sep';
import { rmatchName } from './rmatch-name';
import { rmatchString } from './rmatch-string';
import { routeMatch } from '../route-match.js';
import { urlRoute } from '../url/url-route.js';
import { rmatchAny } from './rmatch-any.js';
import { rmatchDirSep } from './rmatch-dir-sep.js';
import { rmatchName } from './rmatch-name.js';
import { rmatchString } from './rmatch-string.js';

describe('rmatchDirSep', () => {
describe('/', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/matchers/rmatch-dir-sep.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { valueProvider } from '@proc7ts/primitives';
import { routeMatch } from '../route-match';
import type { RouteMatcher } from '../route-matcher';
import { routeMatch } from '../route-match.js';
import type { RouteMatcher } from '../route-matcher.js';

/**
* Route matcher that matches directory separator.
Expand Down
12 changes: 6 additions & 6 deletions src/matchers/rmatch-dirs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import { RouteCaptor } from '../route-captor';
import { routeMatch } from '../route-match';
import { RouteCaptor } from '../route-captor.js';
import { routeMatch } from '../route-match.js';
import { RouteMatcher } from '../route-matcher.js';
import { URLRoute, urlRoute } from '../url';
import { rmatchDirSep } from './rmatch-dir-sep';
import { rmatchDirs } from './rmatch-dirs';
import { rmatchName } from './rmatch-name';
import { URLRoute, urlRoute } from '../url/url-route.js';
import { rmatchDirSep } from './rmatch-dir-sep.js';
import { rmatchDirs } from './rmatch-dirs.js';
import { rmatchName } from './rmatch-name.js';

describe('rmatchDirs', () => {
let captor: RouteCaptor<URLRoute>;
Expand Down
4 changes: 2 additions & 2 deletions src/matchers/rmatch-dirs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RouteMatcher } from '../route-matcher';
import { rcaptureDirs } from './rcapture-dirs';
import type { RouteMatcher } from '../route-matcher.js';
import { rcaptureDirs } from './rcapture-dirs.js';

/**
* Route matcher that matches any number of directories, including none.
Expand Down
8 changes: 4 additions & 4 deletions src/matchers/rmatch-entry.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import { RouteCaptor } from '../route-captor';
import { routeMatch } from '../route-match';
import { RouteCaptor } from '../route-captor.js';
import { routeMatch } from '../route-match.js';
import { RouteMatcher } from '../route-matcher.js';
import { URLRoute, urlRoute } from '../url';
import { rmatchEntry } from './rmatch-entry';
import { URLRoute, urlRoute } from '../url/url-route.js';
import { rmatchEntry } from './rmatch-entry.js';

describe('rmatchEntry', () => {
let captor: RouteCaptor<URLRoute>;
Expand Down
4 changes: 2 additions & 2 deletions src/matchers/rmatch-entry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RouteMatcher } from '../route-matcher';
import { rcaptureEntry } from './rcapture-entry';
import type { RouteMatcher } from '../route-matcher.js';
import { rcaptureEntry } from './rcapture-entry.js';

/**
* Route matcher that matches any route entry.
Expand Down
6 changes: 3 additions & 3 deletions src/matchers/rmatch-name.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it } from '@jest/globals';
import { routeMatch } from '../route-match';
import { urlRoute } from '../url';
import { rmatchName } from './rmatch-name';
import { routeMatch } from '../route-match.js';
import { urlRoute } from '../url/url-route.js';
import { rmatchName } from './rmatch-name.js';

describe('rmatchName', () => {
describe('<name>', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/matchers/rmatch-name.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RouteMatcher } from '../route-matcher';
import type { RouteMatcher } from '../route-matcher.js';

/**
* Builds a route matcher that matches the entry with the given name.
Expand Down
8 changes: 4 additions & 4 deletions src/matchers/rmatch-string.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, expect, it } from '@jest/globals';
import { routeMatch, RoutePattern } from '../route-match';
import { urlRoute } from '../url';
import { rmatchAny } from './rmatch-any';
import { rmatchString } from './rmatch-string';
import { routeMatch, RoutePattern } from '../route-match.js';
import { urlRoute } from '../url/url-route.js';
import { rmatchAny } from './rmatch-any.js';
import { rmatchString } from './rmatch-string.js';

describe('rmatchString', () => {
describe('<string>', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/matchers/rmatch-string.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RouteMatch } from '../route-match';
import { routeMatch } from '../route-match';
import type { RouteMatcher } from '../route-matcher';
import type { RouteMatch } from '../route-match.js';
import { routeMatch } from '../route-match.js';
import type { RouteMatcher } from '../route-matcher.js';

/**
* Builds a route matcher that matches if part of the entry name equals to the expected string.
Expand Down
4 changes: 0 additions & 4 deletions src/matrix/index.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/matrix/match-matrix-route.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, expect, it } from '@jest/globals';
import { rcaptureEntry } from '../matchers';
import { matchMatrixRoute } from './match-matrix-route';
import { matrixRoute } from './matrix-route';
import { rmatchMatrixAttr } from './rmatch-matrix-attr';
import { matchMatrixRoute } from './match-matrix-route.js';
import { matrixRoute } from './matrix-route.js';
import { rmatchMatrixAttr } from './rmatch-matrix-attr.js';
import { rcaptureEntry } from '../matchers/rcapture-entry.js';

describe('matchMatrixRoute', () => {
it('returns `null` when route doe not match', () => {
Expand Down
12 changes: 6 additions & 6 deletions src/matrix/match-matrix-route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { routeCapture } from '../route-capture';
import type { RoutePattern } from '../route-match';
import { routeMatch } from '../route-match';
import { isURL } from '../url/url.impl';
import { MatrixRoute, matrixRoute } from './matrix-route';
import { matrixRoutePattern } from './matrix-route-pattern';
import { routeCapture } from '../route-capture.js';
import type { RoutePattern } from '../route-match.js';
import { routeMatch } from '../route-match.js';
import { isURL } from '../url/url.impl.js';
import { matrixRoutePattern } from './matrix-route-pattern.js';
import { MatrixRoute, matrixRoute } from './matrix-route.js';

/**
* Checks whether the given {@link MatrixRoute matrix route} matches {@link matrixRoutePattern matrix route pattern}.
Expand Down
8 changes: 4 additions & 4 deletions src/matrix/matrix-route-pattern.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import { RouteCaptor } from '../route-captor';
import { routeMatch } from '../route-match';
import { RouteCaptor } from '../route-captor.js';
import { routeMatch } from '../route-match.js';
import { RouteMatcher } from '../route-matcher.js';
import { MatrixRoute, matrixRoute } from './matrix-route';
import { matrixRoutePattern } from './matrix-route-pattern';
import { MatrixRoute, matrixRoute } from './matrix-route.js';
import { matrixRoutePattern } from './matrix-route-pattern.js';

describe('matrixRoutePattern', () => {
let captor: RouteCaptor<MatrixRoute>;
Expand Down
16 changes: 8 additions & 8 deletions src/matrix/matrix-route-pattern.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { decodeURLComponent } from '@frontmeans/httongue';
import { addPathEntryMatchers } from '../path/path-route-pattern.impl';
import type { RoutePattern } from '../route-match';
import type { RouteMatcher } from '../route-matcher';
import { parseURLRoutePattern } from '../url/url-route-pattern.impl';
import type { MatrixRoute } from './matrix-route';
import { rmatchMatrixAttr } from './rmatch-matrix-attr';
import { decodeURISearchPart } from 'httongue';
import { addPathEntryMatchers } from '../path/path-route-pattern.impl.js';
import type { RoutePattern } from '../route-match.js';
import type { RouteMatcher } from '../route-matcher.js';
import { parseURLRoutePattern } from '../url/url-route-pattern.impl.js';
import type { MatrixRoute } from './matrix-route.js';
import { rmatchMatrixAttr } from './rmatch-matrix-attr.js';

/**
* @internal
Expand All @@ -17,7 +17,7 @@ function addMatrixEntryMatchers(pattern: string, matchers: RouteMatcher<MatrixRo
const [name, value] = parts[i].split('=', 2);

matchers.push(
rmatchMatrixAttr(decodeURLComponent(name), value ? decodeURLComponent(value) : undefined),
rmatchMatrixAttr(decodeURISearchPart(name), value ? decodeURISearchPart(value) : undefined),
);
}
}
Expand Down
Loading

0 comments on commit 0ec2b91

Please sign in to comment.