1.0.19 • Published 5 years ago

tidy-path-tree v1.0.19

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

tidy-path-tree

Path tree that used Prefix Tree(Trie Tree)

Installation

$ npm install tidy-path-tree --save

Usage

// for typescript

import { PathTree } from 'tidy-path-tree'

const tree = new PathTree<string>()
tree.add('/a/b/:name', 'data')


/**
 * will returns : {
 *          path: 'a/b/:name',
  *         params: {
  *             name: 'tidy'
  *         }
  *     }
 */
const found = tree.find('/a/b/tidy')    

Path Grammar

    Path:  Layer  ( Layer Delimiter )*  GlobStarEnd?
    
    Layer: Seg*
    Seg: Param  |  Text  |  ReGroup
    
    GlobStarEnd: Delimiter "**"
    
    ReGroup: "("  <RegularExpressBody>  ")"
    
    Text: TextChar+
    TextChar:
      - <Char not Delimiter && not in '\r\n:(/?\\'>
      - BackslashChar
    BackslashChar: "\"  <Char not in "\r\n">
    
    Param = ":"  <JSIdentifier>  "*"?  ( ReGroup "*"? )?

Path examples:

  • /
  • /part1
  • part1/part2
  • /part1/part2/**
  • /test/:name/:type
  • /test/:country(a-z+)/:name(a-z+)?/:code?(0-9+)
1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago