@zma-lab/user-geolocation
TypeScript icon, indicating that this package has built-in type declarations

1.1.32 • Public • Published

User-Geo

User Geo is javascript library that can define user country,city, region whether or not GDPR or CCPA is applied in user's country

Installation

npm install @zma-lab/user-geolocation

Import

User Geo supports both ECMAscript and CommonJS so it can be imported and required

import * as UserGeo from "@zma-lab/user-geolocation";

or;

const UserGeo = require("@zma-lab/user-geolocation");

Methods

import * as UserGeo from "@zma-lab/user-geolocation";

// getFullLocation - returns full object with user geo location
UserGeo.getFullLocation();

// getCountry - returns user country name
UserGeo.getCountry();

// getCountryCode - returns user country code
UserGeo.getCountryCode();

// getCity - returns user city name
UserGeo.getCity();

// getRegion - returns user region
UserGeo.getRegion();

// getDial - returns dial code of user's country
UserGeo.getDial();

// getGDPRApplies - returns whether or not GDPR is applied in user's country
UserGeo.getGDPRApplies();

// getCCPAApplies - returns whether or not CCPA is applied in user's country
UserGeo.getCCPAApplies();

Examples

/**
 * getFullLocation method returns user full geo data object. E.g.:
*/
{
  country: 'Hungary',
  countryCode: 'HU',
  city: 'Budapest',
  region: 'Europe',
  dial: '+36',
  isGDPR: true,
  isCCPA: false
}

/**
 * All other methods returns string. E.g.:
*/

UserGeo.getCountry(); // returns - "Budapest"
UserGeo.getCountryCode(); // returns - "HU"

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Package Sidebar

Install

npm i @zma-lab/user-geolocation

Weekly Downloads

3

Version

1.1.32

License

ISC

Unpacked Size

336 kB

Total Files

24

Last publish

Collaborators

  • zaur_mahmudov