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

@ofrepose/citystates

v1.0.0

Published

A package for working with city and state data

Downloads

5

Readme

Introduction

CityStates is a versatile Node.js package that provides access to detailed information about states and cities. It simplifies the retrieval of state data, including their names, state codes, and geographic coordinates. Additionally, CityStates allows you to explore city information within specific states, making it a valuable resource for location-based applications, data analysis, and more.

Installation

To use Logtastic in your project, you can install it using npm:

npm install @ofrepose/citystates

Features

CityStates offers the following key features:

  • State Information: Retrieve an array of all states with essential properties such as name, state code, and geographic coordinates.

  • State Lookup: Easily find a state by its name or state code. This feature simplifies state-based queries and ensures quick access to state details.

  • City Listings: Get a comprehensive list of city names across all states or specifically for a chosen state. This is particularly useful for applications that require city-level data.

  • City Lookup: Search for a city by name within a specific state. CityStates streamlines the process of finding city details, saving you time and effort.

With CityStates, you can effortlessly integrate state and city data into your Node.js applications, enhancing their geographical capabilities and improving user experiences.

Usage


const CityStates = require('@ofrepose/citystate');

CityStates.getAllStates();
CityStates.getCities({ state: 'North carolina' });
CityStates.getAllCities();
CityStates.getCity({ state: 'nc', city: 'wilmington'});

API Reference

getAllStates()

Retrieves an array of all states with simplified properties.

  • Returns an array of state objects.
  • Each state object has the following properties:
    • name: The state's name.
    • stateCode: The state's code.
    • coordinates: The state's coordinates, including long (longitude) and lat (latitude).

getState({ state })

Retrieves a state object by name or state code.

  • state: The name or state code of the state to retrieve.
  • Returns a state object if found, or null if not found.

getAllCities()

Retrieves an array of city names for all cities across all states.

getCities({ state })

Retrieves an array of city names for a specific state.

  • state: The name or state code of the state to retrieve cities for.
  • Returns an array of city names for the specified state, or null if the state is not found.

getCity({ state, city })

Retrieves a city object by name within a specific state.

  • state: The name or state code of the state to search within.
  • city: The name of the city to retrieve.
  • Returns a city object if found, or null if not found or if the state is not found.

License

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