@lunjs/pathname-store
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@lunjs/pathname-store

Installation

npm install @lunjs/pathname-store

Usage

import { PathnameStore } from '@lunjs/pathname-store';

const s = new PathnameStore();
s.add('/users', {});
s.add('/user/:name', {});

let r = s.find('/users');
console.log(r);
// output: { found: true, box: { store: {}, pnames: [] }, params: [] }

Pattern Rule

Syntax Description
:name named param
* match-all param
:name* named match-all param
  • Named parameters match anything until the next '/' or the path end.
  • Match-all param match anything until the path end.

Path matching order

  • Static
  • Param
  • Match all

Inspired by

License

MIT

Package Sidebar

Install

npm i @lunjs/pathname-store

Weekly Downloads

24

Version

0.1.0

License

MIT

Unpacked Size

16.4 kB

Total Files

6

Last publish

Collaborators

  • jkeylu