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

sypexgeo-vyvid

v0.2.9

Published

Unnoficial Sypex Geo API bindings for Node.JS

Downloads

15

Readme

Unofficial Sypex Geo API bindings for Node.JS.

The latest version works only with:
* SypexGeo 2.2! See changelog.
* SxGeoCity_utf8 (See Gruntfile.js)

Getting Started

Warning! This package does not compile on Windows.

Requirements

  • g++ >= 4.8 for supporting C++11.

Setup

$ npm i --save sypexgeo-vyvid

Using

var sypex = require('sypexgeo-vyvid');
var geoDb = new sypex.Geo('/a/full/path/to/the/SypexGeoCity.dat');
var location = geoDb.find('46.148.53.103');

console.log(JSON.stringify(location, null, '  '));

Documentation

sypex.Geo

Creates an instance.

var geoDb = new sypex.Geo('/var/www/geo/SypexGeoCity.dat');

Parameters

  1. {String} filePath - A full path to the SypexGeo DB file.
  2. [deprecated] {Number} mode - Specifies a behaviour. Available only SXGEO_MEMORY. It will be removed in 0.3.0

The mode is always SXGEO_BATCH | SXGEO_MEMORY regardless of arguments you pass in.

find

Looks up for a location by its IP.

var location = geoDb.find('46.148.53.103');

console.log(JSON.stringify(location, null, '  '));
/** Output:
{
  "latitude": 55.39485,
  "longitude": 43.83992,
  "country": {
    "id": 185,
    "iso": "RU",
    "name": {
      "en": "Russia",
      "ru": "Россия"
    }
  },
  "region": {
    "id": 559838,
    "iso": "RU-NIZ",
    "name": {
      "en": "Nizhegorodskaya Oblast'",
      "ru": "Нижегородская область"
    }
  },
  "city": {
    "id": 580724,
    "name": {
      "en": "Arzamas",
      "ru": "Арзамас"
    }
  }
} 
**/

Parameters

  • {String} ip - The IP-address, for example: 46.148.53.103.

Returns

  • {Object, null} - null if the database hasn't a location with a specified ip.

An object describes a found location:

  • {Number} longitude - 5 digits (e.g., 55.39485) after the decimal point if the city is detected. Otherwise, 2 (e.g. 51.5)
  • {Number} latitude
  • {Object} country
    • {Number} id
    • {String} iso
    • {Object} name
      • {String} en
      • {String} ru
  • [optional] {Object} region - The information about a region. Omitted if wasn't detected
    • {Number} id
    • {String} iso
    • {Object} name
      • {String} en
      • {String} ru
  • [optional] {Object} city - The information about a city. Omitted if wasn't detected
    • {Number} id
    • {Object} name
      • {String} en
      • {String} ru

getCountryIso

Get a country ISO (3166-1 alpha-2) by its IP.

var location = geoDb.getCountryIso('46.148.53.103');

console.log(location); // Output: RU

Parameters

  • {String} ip - The IP-address, for example: 46.148.53.103.

[deprecated] getCity

The method will be removed in 0.3.0.

var city = geoDb.getCityFull('46.148.53.103');

console.log(JSON.stringify(city, null, '  '));
/** Output:
{
  "region": "Нижегородская область",
  "country": "RU",
  "name": "Арзамас",
  "latitude": 55.39485,
  "longitude": 43.83992
}
*/

[deprecated] getCityFull

The method will be removed in 0.3.0.

Alias to getCity.

[deprecated] getCountry

The method will be removed in 0.3.0.

alias to getCountryIso.

Grunt commands

  • grunt test - run tests. Downloads a base if it necessary. At this time we have only JS-tests :)
  • grunt cpplint - check a cpp code for some rules.

Contributing

  • Please check your code by the command: grunt cpplint

  • If you need a manual build, then run:

    npm run-script configure &&\
    npm run-script build &&\
    npm run-script test

Local development

  1. Install cmake:
  • macOS: brew install cmake
  1. Install dependencies:
  • npm i if you want to update package-lock.json;
  • npm ci if not.

How to check a CPP version

cmake CMakeLists.txt &&\
make &&\
./sypexgeo_vyvid

You will see the output:

=== City at 77.50.211.86 ===
Longitude: 100
Latitude: 60
Country id: 185
Country ISO: RU
Russian country name: Россия
English country name: Russia
Region id: 0
Region ISO:
Russian region name:
English region name:
City id: 0
Russian city name:
English city name:
...

Changelog

0.2.*

Works with SypexGeo 2.2.

  • [-] The fips field has been removed (removed from a database);
  • [+] The find and getCountryIso methods have been added;
  • [!] The getCountry, getCity and getCityFull now is deprecated;
  • [!] Completely rewritten code;
  • [!] Requires GCC 4.8.

0.1.*

Works with SypexGeo 2.1.

  • 0.1.1 - Ported to Nan

License

Copyright by Vyatcheslav Suharnikov and contributors.

See contributors list in AUTHORS.

Licensed under the MIT license, see license text in LICENSE file.