npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nv-path-tree

v1.1.0

Published

nv-path-tree ============ - nv-path-tree is very simple util to change paths to a tree

Downloads

5

Readme

nv-path-tree

  • nv-path-tree is very simple util to change paths to a tree

install

  • npm install nv-path-tree

usage

   const {
        parse_one,
        paths_to_dict,
        dict_to_paths,
        load_from_paths,
        load_from_pls,
        load_from_dict,
   } = require("nv-path-tree")

example

parse_one

 > parse_one.parse('a/b/c')
 [ 'a', 'b', 'c' ]
 >
 > parse_one.parse('a/b/c/')
 [ 'a', 'b', 'c', SP { sp: '/' } ]
 >
 > parse_one.parse('/a/b/c')
 [ '', 'a', 'b', 'c' ]
 >
 > parse_one.parse('/a/b/c/')
 [ '', 'a', 'b', 'c', SP { sp: '/' } ]
 >
 > parse_one.parse('/a/b/c/./d')
 [ '', 'a', 'b', 'c', 'd' ]
 >
 > parse_one.parse('/a/b/c/../d')
 [ '', 'a', 'b', 'd' ]
 > parse_one.parse('/a/b/c/.../d')
 [ '', 'a', 'd' ]
 > parse_one.parse('/a/b/c/..../d')
 [ '', 'd' ]
 > parse_one.parse('/a/b/c/...../d')
 [ 'd' ]
 > parse_one.parse('/a/b/c/....../d')
 [ 'd' ]
 >
 > parse_one.parse('/../b/c/../d')
 [ 'b', 'd' ]
 > parse_one.parse('../b/c/../d')
 [ 'b', 'd' ]
 >

paths_to_dict

   var paths = [
     "/a/b/c",
     "/a/b/d"
   ]

   > paths_to_dict(paths)
   { a: { b: { c: null, d: null } } }
   >
   > paths_to_dict(paths,true)
   { a: { b: { c: '/a/b/c', d: '/a/b/d' } } }
   >

dict_to_paths

   > dict_to_paths({ a: { b: { c: null, d: null } } })
   [ '/a/b/c', '/a/b/d' ]
   >
   > dict_to_paths({ a: { b: { c: '/a/b/c', d: '/a/b/d' } } })
   [ '/a/b/c', '/a/b/d' ]
   >

load_from_paths

  var paths = [
   "/a/b/c",
   "/a/b/d"
  ]

  rt =load_from_paths(paths)

  > rt.$sdfs_
  [
    ‌ [/] { SP: ‌ { sp: '/' } },
    ‌ [/a/] {},
    ‌ [/a/b/] {},
    ‌ [/a/b/c] {},
    ‌ [/a/b/d] {}
  ]

  > rt.dict()
  { a: { b: { c: null, d: null } } }
  >
  > rt.dict(true)
  { a: { b: { c: '/a/b/c', d: '/a/b/d' } } }
  >

  > rt.entries()
  [ [ '/a/b/c', null ], [ '/a/b/d', null ] ]
  >
  > rt.entries(true)
  [ [ '/a/b/c', '/a/b/c' ], [ '/a/b/d', '/a/b/d' ] ]
  >

METHODS

    rt.add_with_pl                             rt.constructor
    rt.del_with_pl                             rt.dict
    rt.entries                                 rt.get_with_pl
    rt.is_dir                                  rt.is_file
    rt.is_leaf_dir                             rt.is_nonleaf_dir
    rt.k_                                      rt.path_
    rt.paths_                                  rt.pl_
    rt.pls_                                    rt.rel_dict
    rt.rel_entries                             rt.rel_path
    rt.rel_paths                               rt.rel_pl
    rt.rel_pls                                 rt.sp_
    rt.to_dir                                  rt.to_file

    rt.SP

APIS

    {
      DFLT_CFG: [Function: DFLT_CFG],
      parse_one: {
        _parse: [Function: _parse],
        parse: [Function: parse],
        parse_trim_begin: [Function: parse_trim_begin],
        parse_trim_end: [Function: parse_trim_end],
        parse_trim_both: [Function: parse_trim_both]
      },
      paths_to_dict: [Function: paths_to_dict],
      dict_to_paths: [Function: dict_to_paths],
      load_from_paths: [Function: load_from_paths],
      load_from_pls: [Function: load_from_pls],
      load_from_dict: [Function: load_from_dict]
    }

LICENSE

  • ISC