npm.io
0.2.1 • Published 2 weeks ago

@moq/pattern

Licence
(MIT OR Apache-2.0)
Version
0.2.1
Deps
0
Size
114 kB
Vulns
0
Weekly
0

Media over QUIC

@moq/pattern

npm version TypeScript

Exact path patterns for Media over QUIC: grammar, matching, and set algebra.

A pattern describes a set of broadcast paths. This package provides a shared grammar for tokens, origin scopes, and announce interests. Integrating patterns into those consumers is separate work. Literal paths stay coordinates; @moq/net's path module keeps construction, joins, and prefix operations.

@moq/net and @moq/auth re-export these types. The Rust twin is moq-pattern.

npm add @moq/pattern
import { Pattern, Patterns } from "@moq/pattern";

const grant = Pattern.parse("pid/*/chat");
grant.matches("pid/room1/chat"); // true
grant.contains(Pattern.parse("pid/room1/chat")); // true

const under = Pattern.parse("**/a").rebase("a");
[...under].map((p) => p.text); // ["", "**/a"]

See the package docs for the grammar, the CAT/C4M common subset, and the literal-path rollout.