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

@kuankuan/uint53

v0.1.2

Published

A utility library for performing bitwise operations on unsigned 53-bit integers in JavaScript.

Readme

Uint53 位操作

一个用于在 JavaScript 中对无符号 53 位整数执行位操作的实用工具库。该库提供了在遵循 JavaScript Number 限制的同时处理位操作的功能。

不要问为什么是53位,因为Number.MAX_SAFE_INTEGER9007199254740991,也就是53位。

功能

  • 将数字转换为 53 位二进制字符串,或从中还原。
  • 对无符号 53 位整数执行位操作(ANDORXORNOT)。
  • 在 53 位范围内对数字进行左移或右移操作。
  • 提供用于切割二进制字符串的实用函数。

安装

您可以通过 npm 或 yarn 安装此库:

npm install @kuankuan/uint53

yarn add @kuankuan/uint53

使用方法

导入库并使用提供的函数:

import Uint53BitOperations from '@kuankuan/uint53';

// 示例用法
const a = 42;
const b = 15;

console.log(Uint53BitOperations.uint53_and(a, b)); // 执行按位与操作
console.log(Uint53BitOperations.uint53_or(a, b)); // 执行按位或操作
console.log(Uint53BitOperations.uint53_xor(a, b)); // 执行按位异或操作
console.log(Uint53BitOperations.uint53_not(a)); // 执行按位取反操作
console.log(Uint53BitOperations.uint53_shift_left(a, 2)); // 左移操作
console.log(Uint53BitOperations.uint53_shift_right(a, 2)); // 右移操作

API 参考

常量

  • JS_MAX_SAFE_INTEGER_LENGTH:JavaScript 中的最大安全整数长度(53 位)。

函数

to53binary(n: number): string

将数字转换为 53 位二进制字符串。

from53binary(n: string): number

将 53 位二进制字符串转换回数字。

slice_from_end(n: string, keep?: number): string

从字符串末尾切割,保留指定数量的位。

slice_from_start(n: string, keep?: number): string

从字符串开头切割,保留指定数量的位。

uint53_shift_left(n: number, shift: number): number

将数字左移指定的位数。

uint53_shift_right(n: number, shift: number): number

将数字右移指定的位数。

uint53_and(a: number, b: number): number

对两个数字执行按位与操作。

uint53_or(a: number, b: number): number

对两个数字执行按位或操作。

uint53_xor(a: number, b: number): number

对两个数字执行按位异或操作。

uint53_not(n: number): number

对数字执行按位取反操作。

示例

import {
  to53binary,
  from53binary,
  uint53_and,
  uint53_or,
  uint53_xor,
  uint53_not,
  uint53_shift_left,
  uint53_shift_right,
} from '@kuankuan/uint53';

const a = 42;
const b = 15;

console.log(to53binary(a)); // 转换为二进制
console.log(from53binary('0000000000000000000000000000000000000000000000101010')); // 转换回数字
console.log(uint53_and(a, b)); // 执行按位与操作
console.log(uint53_or(a, b)); // 执行按位或操作
console.log(uint53_xor(a, b)); // 执行按位异或操作
console.log(uint53_not(a)); // 执行按位取反操作
console.log(uint53_shift_left(a, 2)); // 左移操作
console.log(uint53_shift_right(a, 2)); // 右移操作

许可证

本项目基于 MulanPSL-2.0 许可证授权。详情请参阅 LICENSE 文件。