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

czdb

v0.3.0

Published

A javascript library for searching IP address-related data in a CZDB database

Downloads

13

Readme

czdb-search-node

中文文档

npm version npm downloads

A Node.js package for querying the new format data of the Pure IP offline community version database czdb. It supports two types of search algorithms: in-memory search (MEMORY) and B-tree search (BTREE). The database type (IPv4 or IPv6) and query type (MEMORY, BTREE) are determined at runtime.

JAVA Version

PHP Version

C Version

Supports IPv4 and IPv6

czdb-search supports querying both IPv4 and IPv6 addresses. When creating a DbSearcher instance, you need to provide the corresponding database file and key.

Database files and keys can be obtained from www.cz88.net.

Installation

Please use Node.js v8.0.0 or higher to get ES6 support.

npm install czdb

Usage

Note: czdb has been changed to an ESM package, so please set "type": "module" in the project's package.json when import it in the js file. For details, see Pure ESM

// Import DbSearcher
import DbSearcher, { QueryType } from "czdb";

// CommonJS require:
// const { default: DbSearcher, QueryType } = require('czdb');

// Prepare your .czdb file and key
const IPV4_DB_PATH = "YOUR_IPV4_DB_PATH";
const IPV4_IP = "1.64.219.93";
const KEY = "YOUR_KEY_HERE";

// Create a search instance
const searcher = new DbSearcher(IPV4_DB_PATH, QueryType.BTREE, KEY);

// Use the search method to search the database based on the provided IP address
const region = searcher.search(IPV4_IP);

// The returned string format is "Country–Province–City–Region ISP". If the search fails, it will return null.
console.log(region); // China–Hong Kong  PCCW Limited

Example

You can find a simple usage example in the example folder. After filling in the path and key, run the following commands to test:

pnpm i

pnpm run test

Query Types

DbSearcher supports 2 query types: MEMORY and BTREE.

MEMORY: This mode is thread-safe and stores data in memory. BTREE: This mode uses the B-tree data structure for queries. You can choose the query type when creating a DbSearcher instance.

DbSearcher searcher = new DbSearcher("YOUR_DB_PATH", QueryType.BTREE, "YOUR_KEY");

Closing the Database

When the query is finished and no longer needed, you should close the database.

searcher.close();

This will release all used resources and close access to the database file.