Gathering detailed insights and metrics for location-data-kit
Gathering detailed insights and metrics for location-data-kit
A Node.js package providing functions to access and search location data including countries, states, and cities.
npm install location-data-kit
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
847
Last Day
3
Last Week
8
Last Month
28
Last Year
847
1 Stars
27 Commits
1 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
2.0.7
Package Id
location-data-kit@2.0.7
Unpacked Size
21.52 MB
Size
2.37 MB
File Count
7
NPM Version
10.7.0
Node Version
20.15.1
Publised On
12 Aug 2024
Cumulative downloads
Total Downloads
Last day
0%
3
Compared to previous day
Last week
700%
8
Compared to previous week
Last month
300%
28
Compared to previous month
Last year
0%
847
Compared to previous year
No dependencies detected.
This is a Node.js package that provides functions to access and search location data including countries, states, and cities.
1npm install location-data-kit
1const LocationDataKit = require('location-data-kit'); 2 3// Fetch all countries 4const allCountries = LocationDataKit.fetchAllCountries(); 5console.log('All Countries:', allCountries); 6 7// Search for countries by name (case-insensitive) 8const searchTerm = "France"; 9const countriesWithName = LocationDataKit.fetchAllCountries(searchTerm); 10console.log('Countries with name:', countriesWithName); 11 12// Fetch all states in a specific country 13const countryCode = "US"; // Change this to your desired country code 14const statesInUS = LocationDataKit.fetchStatesByCountry(countryCode); 15console.log('States in US:', statesInUS); 16 17// Search for states in a specific country by name (case-insensitive) 18const stateSearchTerm = "California"; 19const statesInUSWithName = LocationDataKit.fetchStatesByCountry(countryCode, stateSearchTerm); 20console.log('States in US with name:', statesInUSWithName); 21 22// Fetch all cities in a specific state 23const stateCode = "CA"; // Change this to your desired state code 24const citiesInCA = LocationDataKit.fetchCitiesByState(stateCode); 25console.log('Cities in CA:', citiesInCA); 26 27// Search for cities in a specific state by name (case-insensitive) 28const citySearchTerm = "Los Angeles"; 29const citiesInCAWithName = LocationDataKit.fetchCitiesByState(stateCode, citySearchTerm); 30console.log('Cities in CA with name:', citiesInCAWithName);
This package expects three JSON files to be present in the data
folder within the package directory:
countries.json
: An array of objects representing countries, each object should have properties like name
and optionally code
.states.json
: An array of objects representing states, each object should have properties like name
, countryCode
(referencing a country from countries.json
).cities.json
: An array of objects representing cities, each object should have properties like name
, stateCode
(referencing a state from states.json
).Please note: You need to provide your own data for these files or use existing datasets formatted as mentioned above.
This package is licensed under the MIT License. See the LICENSE file for details.
No vulnerabilities found.
No security vulnerabilities found.