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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gisce/bigint-helper

v1.0.1

Published

BigInt helper functions for GISCE ecosystem

Downloads

10

Readme

@gisce/bigint-helper

BigInt helper functions for the GISCE ecosystem. This library provides utilities for safely working with BigInt IDs in JavaScript/TypeScript applications.

Why BigInt?

JavaScript's Number type loses precision for integers larger than Number.MAX_SAFE_INTEGER (9,007,199,254,740,991). Database IDs often exceed this limit, causing bugs when IDs get truncated or compared incorrectly.

BigInt solves this, but introduces challenges:

  • 5n === 5 is false (strict equality fails across types)
  • [1n, 2n, 3n].includes(2) is false
  • JSON.parse/JSON.stringify don't support BigInt

This library provides drop-in utilities to handle these edge cases.

Installation

npm install @gisce/bigint-helper

API

parseJSON<T>(text: string): T

Parses JSON with BigInt support. Numbers larger than Number.MAX_SAFE_INTEGER are automatically parsed as BigInt.

import { parseJSON } from "@gisce/bigint-helper";

const data = parseJSON('{"id": 9007199254740993}');
// data.id is 9007199254740993n (BigInt), not 9007199254740992 (truncated)

stringifyJSON(value: unknown, space?: number): string

Stringifies values to JSON with BigInt support. BigInt values are serialized as numbers without quotes.

import { stringifyJSON } from "@gisce/bigint-helper";

const json = stringifyJSON({ id: 9007199254740993n });
// '{"id":9007199254740993}'

toSafeBigIntKey(id: number | bigint | undefined | null): string

Converts an ID to a string safe for use as object keys or React keys.

import { toSafeBigIntKey } from "@gisce/bigint-helper";

toSafeBigIntKey(123n);      // "123"
toSafeBigIntKey(456);       // "456"
toSafeBigIntKey(undefined); // "undefined"
toSafeBigIntKey(null);      // "null"

isValidId(value: unknown): value is number | bigint

Type guard to check if a value is a valid ID (number or bigint).

import { isValidId } from "@gisce/bigint-helper";

isValidId(123);       // true
isValidId(123n);      // true
isValidId("123");     // false
isValidId(undefined); // false

idsEqual(a, b): boolean

Compares two IDs for equality, handling BigInt/number mixed comparisons.

import { idsEqual } from "@gisce/bigint-helper";

idsEqual(5n, 5);           // true (unlike 5n === 5 which is false)
idsEqual(123n, 123n);      // true
idsEqual(null, undefined); // false

includesId(arr: (number | bigint)[], id: number | bigint): boolean

Checks if an array includes an ID, handling BigInt/number mixed comparisons. Replacement for arr.includes(id) which uses strict equality.

import { includesId } from "@gisce/bigint-helper";

const ids = [1n, 2n, 3n];
includesId(ids, 2);  // true (unlike ids.includes(2) which is false)
includesId(ids, 2n); // true
includesId(ids, 5);  // false

findIdIndex(arr: (number | bigint)[], id: number | bigint): number

Finds the index of an ID in an array, handling BigInt/number mixed comparisons.

import { findIdIndex } from "@gisce/bigint-helper";

const ids = [10n, 20n, 30n];
findIdIndex(ids, 20);  // 1 (unlike ids.indexOf(20) which is -1)
findIdIndex(ids, 20n); // 1
findIdIndex(ids, 99);  // -1

License

ISC