Socket
Socket
Sign inDemoInstall

tiny-path-matcher

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-path-matcher

Tiny hierarchical path (tree node) matcher.


Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

TinyPathMatcher

This is a tiny (~50 SLOC and and zero-dependency) hierarchical path (tree node) matcher.

npm version

Installation

npm install tiny-path-matcher

(Note: an ES2018+ESM-compatible environment is required.)

Getting started

import { PathNode } from 'tiny-path-matcher';

const rootPathNode  = new PathNode(),
  usersPathNode     = new PathNode('users');
  userPathNode      = new PathNode(/^user-(?<userId>\d+)$/, { description: 'User page' });

rootPathNode.push(usersPathNode);
usersPathNode.push(userPathNode);

let [ pathNode, groups ] = rootPathNode.match([ 'users', 'user-12' ]);
// assert.strictEqual(pathNode, userPathNode)
// assert.deepStrictEqual(grooups, { 'userId': '12' });

rootPathNode.match([ 'users', 'user-12' ]);  // === null

Example

See a full example here.

Author

Alexander Kurakin <kuraga333@mail.ru>

Inspired by

Feedback and contribute

https://github.com/kuraga/tiny-path-matcher/issues

License

MIT

Keywords

FAQs

Package last updated on 02 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc