Coder Social home page Coder Social logo

dutch-cities-search's Introduction

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.


dutch-cities-search's People

Stargazers

Mike Woudenberg avatar

Watchers

Mark van der Steenhoven avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.