Registry / serialization / cuint
library0.2.2jsnpmunverified

The `cuint` library provides functionality for handling C-like unsigned 32-bit and 64-bit integers in JavaScript, a capability not natively supported by the language. It represents unsigned integers as objects, splitting them into 16-bit segments (e.g., two for UINT32, four for UINT64) to emulate fixed-width arithmetic. Designed for performance, it aims to provide C-like behavior, including truncation on overflow. The current and only stable version is 0.2.2, last updated approximately 9 years ago (as of 2026). Due to its age and lack of updates, it is considered an abandoned project, meaning it likely does not receive bug fixes, security patches, or compatibility updates for newer JavaScript environments or Node.js versions. Its primary differentiator was bringing explicit unsigned integer arithmetic to JavaScript before `BigInt` was standardized.

npm install cuint
INSTALL
IMPORT
SIG · CUINT
C
cuint
serializationjavascriptv0.2.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

UINT32
✓ const { UINT32 } = require('cuint');
✗ import { UINT32 } from 'cuint';
Primarily designed for CommonJS. For browser usage, include `uint32.js` via a `<script>` tag to expose `UINT32` globally. Native ESM import syntax is not supported and will likely result in an error or require a transpilation step.
UINT64
✓ const { UINT64 } = require('cuint');
✗ import { UINT64 } from 'cuint';
Similar to `UINT32`, `UINT64` is exposed via CommonJS `require()` or globally in the browser when `uint64.js` (or a combined build) is included.
UINT32 (Browser Global)
✓ // After including <script src="/your/path/to/uint32.js"></script> const val = UINT32('326648991');
✗ import { UINT32 } from 'cuint/build/uint32.js';
When used in a browser environment by including the build script, `UINT32` is directly available as a global variable. No explicit import or `require` is needed in this context.

Demonstrates importing `UINT32` and `UINT64` in Node.js, instantiating unsigned integer objects, performing in-place addition, and showcasing the `clone()` method for immutable operations, highlighting the library's C-like behavior with fixed-width arithmetic.

// In Node.js environment const { UINT32, UINT64 } = require('cuint'); // Instantiate a 32-bit unsigned integer const thirtyTwoBitValue = UINT32('4294967290'); // Close to max 32-bit unsigned value console.log(`Initial UINT32 value: ${thirtyTwoBitValue.toString()}`); // Instantiate another 32-bit value const smallThirtyTwoBitValue = UINT32(10); // Perform an addition (modifies thirtyTwoBitValue in place) thirtyTwoBitValue.add(smallThirtyTwoBitValue); console.log(`UINT32 after adding 10: ${thirtyTwoBitValue.toString()}`); // Will demonstrate truncation if it overflows // Instantiate a 64-bit unsigned integer const sixtyFourBitValue = UINT64('18446744073709551600'); // Close to max 64-bit unsigned value console.log(`Initial UINT64 value: ${sixtyFourBitValue.toString()}`); // Instantiate another 64-bit value const smallSixtyFourBitValue = UINT64(15); // Perform an addition (modifies sixtyFourBitValue in place) sixtyFourBitValue.add(smallSixtyFourBitValue); console.log(`UINT64 after adding 15: ${sixtyFourBitValue.toString()}`); // Demonstrate cloning for immutable operations const originalValue = UINT32(100); const addedValue = UINT32(50); const resultValue = originalValue.clone().add(addedValue); console.log(`Original value (immutable check): ${originalValue.toString()}`); // Should still be 100 console.log(`Result of clone().add(): ${resultValue.toString()}`); // Should be 150
Debug
Known issues
breakingMethods modify the object in place, requiring explicit `.clone()` for immutable operations. This behavior is C-like but non-idiomatic for typical JavaScript object operations.
fix
Always call `.clone()` on the original object before performing operations if you need to preserve the original value, e.g., `z = x.clone().add(y)`.
affects: >=0.2.0
gotchaThe library is abandoned and has not been updated in over 9 years. This means it may have compatibility issues with newer Node.js versions, JavaScript engines, or security vulnerabilities that will not be patched.
fix
Consider using JavaScript's native `BigInt` for arbitrary precision integers or a more actively maintained library for fixed-width integer arithmetic if modern environments and security are concerns.
affects: *
gotchaOverflows are handled by C-like truncation to the respective 32-bit or 64-bit limit. This differs significantly from JavaScript's standard number behavior or `BigInt`'s arbitrary precision, which might lead to unexpected results if not accounted for.
fix
Be aware of the truncation behavior. Implement explicit checks if specific overflow handling (e.g., throwing an error) is required, rather than relying solely on the library's default behavior.
affects: *
gotchaThe package does not provide native ES Module (ESM) exports. Direct `import ... from 'cuint'` syntax will not work in ESM-only Node.js environments or modern browser module contexts without a transpilation step.
fix
In CommonJS environments, use `const { UINT32 } = require('cuint');`. In ESM, you may need dynamic `import()` or to configure your build system to handle CJS modules, or use a tool like `esm` for Node.js.
affects: *
Errors
Common errors & fixes
ReferenceError: UINT32 is not defined
Attempting to use `UINT32` in Node.js without `require('cuint')` or in a browser without including the build script.
fix
In Node.js: `const { UINT32 } = require('cuint');`. In browser: ensure `<script src='/path/to/uint32.js'></script>` is present and loaded before usage.
TypeError: Cannot read properties of undefined (reading 'add')
Trying to call a method like `.add()` on a variable that is not an instance of `UINT32` or `UINT64`, possibly due to incorrect instantiation or a lost `this` context.
fix
Ensure the variable is correctly instantiated with `UINT32(...)` or `UINT64(...)` and that method calls are chained correctly or called on valid instances.
SyntaxError: Named export 'UINT32' not found. The requested module 'cuint' does not provide an export named 'UINT32'
Attempting to use ES Module `import { UINT32 } from 'cuint';` syntax with an abandoned CommonJS-only package in an ESM context.
fix
Use CommonJS `require()` syntax: `const { UINT32 } = require('cuint');`.
TypeError: UINT32 is not a constructor
Trying to use `new UINT32(...)` instead of `UINT32(...)` as the library's functions are factory functions, not traditional constructors.
fix
Call `UINT32()` or `UINT64()` directly without the `new` keyword, e.g., `const value = UINT32(123);`.
Upgrade
Version history
0.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
14
Resources