0.3.1 • Published 8 months ago

pathern v0.3.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 months ago

Build Status Code Coverage downloads version MIT License

size gzip size

Install

npm install pathern

Usage

import * as pathern from 'pathern';

replace

pathern.replace('posts/:postId', '1');                      // 'posts/1'
pathern.replace('posts/:postId', { postId: '1' });          // 'posts/1'
pathern.replace(':a/:b/:c', { a: '1', b: '2', c: '3' });    // '1/2/3'
pathern.replace('$a\\$b\\$c', { a: '1', b: '2', c: '3' }, { // '1/2/3'
  prefix: '$',
  delimiter: '\\',
});

extract

pathern.extract('a/:b/c', 'a/2/c'); // { b: '2' }

matches

pathern.matches('a/:b/c', 'a/2/c'); // true
0.3.0

8 months ago

0.3.1

8 months ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago