JSPM

@zaur_mahmudov/user-geo

1.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q44843F
  • License ISC

Get user country data

Package Exports

  • @zaur_mahmudov/user-geo
  • @zaur_mahmudov/user-geo/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@zaur_mahmudov/user-geo) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 @zaur_mahmudov/user-geo

Import

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

import * as UserGeo from "@zaur_mahmudov/user-geo";

or;

const UserGeo = require("@zaur_mahmudov/user-geo");

Methods

import * as UserGeo from "@zaur_mahmudov/user-geo";

// 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.