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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@antonthomzz/travex

v0.0.1-alpha.1

Published

Traversal and search utility using regular expressions for structured data

Downloads

16

Readme

Travex

NPM Version NPM Downloads Donate

Features

  • Path-Based Traversal: Navigate nested data using string paths (e.g., "user>name") or arrays of paths.
  • Configurable Options:
    • default: Specify a fallback value when no data is found.
    • fallback: Define alternative paths to try if the primary path fails.
    • flatten: Flatten nested arrays in the result for simpler output.
    • unique: Remove duplicates from array results.
    • limit: Restrict the number of items in array outputs.
    • debug: Enable debug mode to log traversal details (integrates with external logging).
    • Find: Search for data at a specified path.
    • Filter: Apply a custom function to filter or transform results.
    • group: Select or group results based on an index or logic.
  • Error Handling: Validates inputs and configurations, throwing clear errors for invalid JSON, paths, or options.
  • Flexible Output: Returns results with a value property and additional methods (Find, Filter, group) for further processing.

Installation

  1. Ensure Node.js is installed on your system.
  2. Clone or download the repository containing the traversal tool.
  3. Install dependencies (if any) by running:
npm install @antonthomzz/travex
  1. Include the traversal tool in your project:
import { (Traverse|Findall|Meta|Decode) } from '@antonthomzz/travex';

Basic Setup

Set up the tool by defining the input data and traversal path:

import { Traverse } from '@antonthomzz/travex';

var result = Traverse(".value", {"data":{"name":{"value":"Anton"}}})
console.log(result); // Output: "Anton"

Available Options

  • default: Specifies a value to return if no data is found at the given path or fallback paths.
    • Example:

      import { Traverse } from '@antonthomzz/travex';
      
      var result = Traverse('.anton', {}, { default: 'Not found' });
      console.log(result); // Output: "Not found"
  • fallback: Defines alternative paths (string or array of strings) to try if the primary path yields no result.
    • Example:

      import { Traverse } from '@antonthomzz/travex';
      
      var result = Traverse('anton', {"data":{"name":"Anton"}}, { fallback: ['tes1', 'data>name'] });
      console.log(result); // Output: "Anton"
  • flatten: When true, flattens nested arrays in the result into a single array.
    • Example:

      import { Traverse } from '@antonthomzz/travex';
      
      var result = Traverse('list', {"list":[[1,2],[3,4]]}, { flatten: true });
      console.log(result); // Output: [1, 2, 3, 4]
  • unique: When true, removes duplicates from array results using a Set.
    • Example:

      import { Traverse } from '@antonthomzz/travex';
      
      var result = Traverse('items', {"items":[1,1,2,2,3]}, { unique: true });
      console.log(result); // Output: [1, 2, 3]
  • limit: Restricts the number of items in array results to the specified positive integer.
    • Example:

      import { Traverse } from '@antonthomzz/travex';
      
      var result = Traverse('numbers', {"numbers":[1,2,3,4,5]}, { limit: 3 });
      console.log(result); // Output: [1, 2, 3]
    • Throws TypeError if limit is not a positive integer.

  • debug: When true, enables debug mode to log traversal details (requires external logging setup, e.g., with TestSuite).
    • Example:

      import { Traverse } from '@antonthomzz/travex';
      
      Traverse('data>value', {"data":{"value":42}}, {
         debug: true
      }); // Output: [DEBUG]: Key: "data>value" Got: 42
  • find: search for metadata and then validate it with other data on the surface.
    • Example:

      import { Traverse } from '@antonthomzz/travex';
      
      var result = Traverse("data", {"data":[{"name":"Anton","age":20},{"name":"Tiara","age":17}]}, {
         find: ["name", "age:20"]
      });
      console.log(result); // Output: Anton
  • filter: Applies a custom function to filter or transform the result. If no function is provided, returns the original result.
    • Example:

      import { Traverse } from '@antonthomzz/travex';
      
      var result = Traverse("num", {"num": 10}, { filter: p => p * 10 });
      console.log(result); // Output: 100
  • group: Selects or groups results based on an index (n) or logic. If n is a positive number, selects the element at index n-1. If n is 0 or omitted, processes the entire result.
    • Example:

      import { Traverse } from '@antonthomzz/travex';
      
      var result = Traverse("items", {"items":["apple","banana","orange"]}, { group: 2 });
      console.log(result); // Output: banana

Advanced Usage Examples

  • search_regex: search data based on RegExp
    import { Findall } from '@antonthomzz/travex';
    
    (async (input) => {
       var result = await Findall("<title>(.*?)<title>", input);
       console.log(result); // Output: "Follow github antonthomzz (https://github.com/Antonthomzz)"
    })('<title>Follow github antonthomzz (https://github.com/Antonthomzz)<title>');

Error Handling

  • Invalid Input: Throws TypeError if input is not a valid object or JSON string (e.g., traverse.isObject or JSON parse errors).
  • Invalid Path: Returns null or the default value if no data is found, with fallback paths attempted if specified.
  • Invalid Options: Throws TypeError for invalid option values (e.g., non-boolean flatten, non-positive integer limit).
  • Empty Data: Throws TypeError (traverse.data_not_found) if the traversal path is invalid or empty without a default or fallback.

License (MIT)

This project is licensed under the MIT License. See the LICENSE file for details.