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

address-complete

v1.1.6

Published

What are you looking for?

Downloads

7

Readme

address-complete

What are you looking for? Or how?

Address-complete provide unified way to perform address autocomplete using 3 geo-data providers:

  1. Google autocomplete + places API
  2. MapZen (Pelias) autocomplete API
  3. Yandex Geocoder

This library provides both basic address autocompete features, and extended address details extraction to enable complex forms to shine.

Setup

npm install address-autocomplete

API

%provider_name%.search(term): Promise %provider_name%.getDetails(term): Promise

MAPZEN all the things.

Nor google, nor yandex will NOT work in browser due to CORS limitations.

Use mapzen instead.

Example

there is live example at codesandbox - https://codesandbox.io/s/y382k7n61j

import mapzen, {configure} from 'address-autocomplete/mapzen';
import google, {configure} from 'address-autocomplete/google';
import yandex, {configure} from 'address-autocomplete/yandex';

// Google and MapZen does require an API key;
configure('YOUR_API_KEY');

mapzen
.search('something')
.then(autocompletedData => async {
  // array of objects with .text field
  const fullData = await Promise.all(autocompletedData.map(mapzen.getDetails));
  // array of object with coordinates as AddressDetails data
})

PS: To say they truth - you have to call getDetails only for Google API. All other API just mimic Google's behavior.

mapzen
.search('something')
.then(fullData => {
  // hooray! I've already got everything!
})
google
.search('something')
.then(fullData => {
  // only fullData[0].text
  // noooo :( :(
})

Types

This library comes with TS and Flow definition, but anyway

Response from Google.search is AddressResponse

interface AddressResponse {
    id: number,
    text: string,
}

Response and any other API, or from google.getDetails

interface DetailedAddressResponse extends AddressResponse {
    point: number[],
    addressDetails: {
        country: {
            name: string,
            code?: string  // as iso3166-1
        },
        region: {
            name: string,
            code?: string, // as iso3166-2
        },
        locality: {
            name: string
        },
        street: {
            name: string,
            house: string,
            label: string,
        },
        postalcode: string
    }
}

Country list

Hey! How to get list of countries or list of states for a country?

Just use iso3166-2-db

import listOfCountries from 'iso3166-2-db/countryList/UN/en';

address complete uses iso3166-2-db to extract iso3166-2 regions names from MapZen answers.

Which API to use?

I could recommend:

  • MapZen - it is almost free, and high quality.
  • Google is a standard defacto.
  • Yandex, for Europe.

License

MIT