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

dutch-cities-formatter

v1.0.4

Published

small util library to get dutch cities in a formatted way

Downloads

1

Readme

Dutch Cities Formatter

Build status

Build and Test

Description

The dutch-cities-formatter is a lightweight JavaScript package that provides two essential functions for handling Dutch city names: search and searchOne. These functions allow you to search for Dutch city names, correct capitalization, expand abbreviations, and handle common misspellings.

This package is particularly useful when dealing with user-generated data where city names may come in various formats with different capitalization, abbreviations, or misspellings.

Features

  • Corrects capitalization for city names.
  • Expands abbreviations to full city names.
  • Handles common misspellings and variations.
  • Provides search capabilities for Dutch city names.
  • Returns city objects with keys and titles.

Installation

To use the dutch-cities-formatter package in your project, follow these steps:

  1. Install the Package:

    You can install the package using npm or yarn:

    npm install dutch-cities-formatter

    or

    yarn add dutch-cities-formatter
  2. Import and Use:

    Import the package into your JavaScript or TypeScript file:

    // CommonJS
    const { search, searchOne } = require("dutch-cities-formatter");
    
    // ES modules (for modern JavaScript)
    import { search, searchOne } from "dutch-cities-formatter";

Usage

search(cityName: string): City[]

The search function allows you to search for Dutch city names that match the input cityName. It returns an array of city objects, each containing a key and title.

const matchingCities = search("amst"); // Example search for cities starting with 'amst'
console.log(matchingCities);
/* Output:
[
  { key: 'WP3594', title: 'Amsterdam' },
  { key: 'WP1050', title: 'Amstelveen' },
  // ...
]
*/

searchOne(cityName: string): City | null

The searchOne function searches for a Dutch city name that most closely matches the input cityName. It returns a single city object that is the best match or null if no match is found.

const bestMatch = searchOne("rottrdam"); // Example search for a closely matching city
console.log(bestMatch);
/* Output:
{
  key: 'WP3086',
  title: 'Rotterdam',
}
*/

These functions return city objects with key, title ensuring that your Dutch city names are consistently formatted and corrected, making them suitable for various applications.

License

This package is open-source and available under the MIT License. Feel free to use it in your projects and contribute to its development on GitHub.

For more details and usage examples, please refer to the documentation.