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

findme-js

v1.1.0

Published

A lightweight javascript library to get a detailed geolocation of IP address as well as to find out where you are.

Downloads

4

Readme

Findme.js

A free, open-source light-weighted javascript library to get a detailed geolocation of IP address as well as to find where you are. Works on both browser side and non-browser side!

Feature

🐰 No API key is required

🐰 Full TypeScript support

🐰 Support remote IP address

🐰 Support usage with proxy settings

🐰 Free, open source, light-weighted

🐰 Works on both browser side and non-browser side

Installation

npm i findme-js

Usage

Samples

/** Works on ESM. If you are using CommonJS, refer to next section. */
import {getGeoInfo} from 'findme-js';

/** Get the geolocation of me */
console.log(await getGeoInfo());

/**
 * Get the geolocation of me via system proxy settings.
 * This only works on non-browser side as in browser side the
 * proxy settings are always determined by your browser.
 */
console.log(await getGeoInfo('', 'system'));

/**
 * Get the geolocation of a certain remote address.
 */
console.log(await getGeoInfo('8.8.4.4');

Import

Notice: This library is an ESM. You must use it in module scope, and depends on the type of your module, the ways to import may differ.

In ESM

import {getGeoInfo} from 'findme-js';

In CommonJS

You must use dynamic-import to import an ESM.

import('findme-js').then(data => {
  const getGeoInfo = data.geoInfo();
  // ...
});

You may wrap it in an asynchronous function and use IIFE in order to use it in a more elegant way to avoid importing it multiple times.

const getGeoInfoPromise = (async () =>
  (await import('findme-js')).getGeoInfo)();
async function main() {
  const getGeoInfo = await getGeoInfoPromise;
  // ...
}

API

Function: getGeoInfo

getGeoInfo: (ip: string = '', proxySettings: ProxySettings = 'none') =>
  Promise<GeoInfo>;

| Parameters | Type | Default | Description | | -------------- | --------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ip | string | '' | The IP address of which you want to get the geolocation. You can also pass a domain name instead. Both valid IPv4 and IPv6 addresses are supported. Setting it to empty string to get your own geolocation. | | proxySettings | ProxySettings | 'none' | 'none': Don't use a proxy server. 'system': Use system proxy settings. [Object AxiosProxyConfig]: You can also pass an AxiosProxyConfig object to customize your own proxy settings. Notice: This parameter will be ignored in browser side! The proxy settings will always be determined by the browser in and you are not able to override it. |

Interface: GeoInfo

The data structure is consistent with the returned data of https://ip-api.com/docs/api:json, but with status and message field omitted.

Notice

The data source of Findme.js comes from the free open API of https://ip-api.com/.

Due to the usage limit of 45 requests per minute (refer to https://ip-api.com/docs/legal for more information), it may be not a good choice to use it in a high-payload environment.

Development

Clone this repository.

Install the dependencies.

npm i

To build the library, run

npm run build

To run the test, run

npm run dev

You can also pass options to define which test to run. For more information use

npm run dev -- -h

License

This library is licensed under GNU Affero General Public License 3.0.

As this library uses the free open API of https://ip-api.com, you must also comply their user terms to use this library, that is, you can only use this library for a NON-COMMERCIAL purpose and in a NON-COMMERCIAL environment, otherwise the grant of usage will be regarded INVALID. Findme.js shall not be liable for any result caused by such illegal usages.