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

findstate-cli

v1.0.0

Published

A CLI for querying data optimized for Real Estate

Downloads

64

Readme

findstate-cli

A lightweight, extensible command-line tool for querying and filtering data with support for operations like equality, range comparisons, inclusion, pattern matching, and more complex distance calculations, and fuzzy search.

Includes interactive mode, customizable logic, and formatted outputs (table or JSON).

Features

  • Query Operations:
    • Equality: Filter by exact values.
    • Range: Filter by greater than, less than.
    • Inclusion: Check if a field includes specific values.
    • Pattern Matching: Check if text fields match certain patterns.
    • Fuzzy Matching: Find approximate matches in text fields using Levenshtein distance.
    • Distance Filtering: Filter data by geospatial distance.
  • Interactive Mode: Step-by-step query building.
  • Export Results: Save results to JSON files.
  • Flexible Output Formats: Results displayed as a table or JSON.

Development

Setting Up Locally

Clone the repository:

git clone https://github.com/pabloandura/findstate-cli.git
cd findstate-cli

Install dependencies:

npm install

Building the Project

Build the TypeScript code to JavaScript:

npm run build

If it is the first time you run the application you should link:

npm link

At the end remember to:

npm unlink -g

Running Tests

Run the unit tests:

npm test

Commands

query

Run a query with specified filters.

Options:

  • -q, --queries <queries...>: Query filters in the format field:operation:value.
  • -s, --source <source>: Data source. Default: mock.
  • -o, --output <output>: Output format (table or json). Default: table.

Example:

findstate-cli query -q price:greaterThan:300000 -q rooms:equal:4

interactive

Start interactive mode to build queries step by step.

Options:

  • -s, --source <source>: Data source. Default: mock.
  • -o, --output <output>: Output format (table or json). Default: table.

Example:

findstate-cli interactive

Sample Interaction:

> Enter field to query: price
> Select operation: greaterThan
> Enter value for the operation: 300000
> Do you want to add another query? (y/n): y
> Enter field to query: rooms
> Select operation: equal
> Enter value for the operation: 4

export

Export query results to a file.

Options:

  • -q, --query <queries...>: Queries to filter data.
  • -s, --source <source>: Data source. Default: mock.
  • -f, --fileName <fileName>: Output file name. Default: results.json.

Example:

findstate-cli export -q price:greaterThan:300000 -q rooms:equal:4 -f filteredResults.json

help

Display usage information.

Example:

findstate-cli help

Supported Query Operations

| Operation | Description | Example Query | |------------------|------------------------------------------------------|---------------------------------------| | equal | Matches exact field value. | rooms:equal:3 | | lessThan | Matches fields with values less than the provided. | price:lessThan:500000 | | greaterThan | Matches fields with values greater than the provided.| price:greaterThan:300000 | | match | Matches fields containing a substring. | description:match:city | | fuzzy | Matches fields approximately similar to the value. | description:fuzzy:garage | | distance | Matches locations within a specific radius. | location:distance:40.7128,-74.0060,10| | include | Checks if a field includes a specific property. | ammenities:include:pool |


Fuzzy Matching

Fuzzy matching uses Levenshtein distance to find approximate matches for text fields. Matches within a distance of 3 are considered valid.

Example:

findstate-cli query -q description:fuzzy:garage

This query will return all properties with descriptions approximately matching the word garage.