Skip to content

Commit

Permalink
bigint: use native bigint instead of big-integer
Browse files Browse the repository at this point in the history
To make it easier for our libraries to be used together, we are doing a
pass over them, standardizing on using native bigint for big numbers.
Nock-js already uses these. This library should follow.

This commit updates all aura-js library code to use native bigints, and
removed the big-integer dependency altogether.
  • Loading branch information
Fang- committed Mar 26, 2024
1 parent 15b1446 commit 5e89c56
Show file tree
Hide file tree
Showing 14 changed files with 274 additions and 323 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ This NPM package is intended to ease the flow of developing FE applications for

```typescript
// @da manipulation
function parseDa(da: string): BigInteger;
function formatDa(da: BigInteger): string;
function parseDa(da: string): bigint;
function formatDa(da: bigint): string;
// Given a bigint representing an urbit date, returns a unix timestamp.
function daToUnix(da: BigInteger): number;
function daToUnix(da: bigint): number;
// Given a unix timestamp, returns a bigint representing an urbit date
function unixToDa(unix: number): BigInteger;
function unixToDa(unix: number): bigint;

// @p manipulation
// Convert a number to a @p-encoded string.
function patp(arg: string | number | BigInteger): string;
function patp(arg: string | number | bigint): string;
function hex2patp(hex: string): string;
function patp2hex(name: string): string;
function patp2bn(name: string): BigInteger;
function patp2bn(name: string): bigint;
function patp2dec(name: string): string;
// Determine the ship class of a @p value.
function clan(who: string): string;
Expand All @@ -35,27 +35,27 @@ function cite(ship: string): string | null;

// @q manipulation
// Convert a number to a @q-encoded string.
function patq(arg: string | number | BigInteger): string;
function patq(arg: string | number | bigint): string;
function hex2patq(arg: string): string;
function patq2hex(name: string): string;
function patq2bn(name: string): BigInteger;
function patq2bn(name: string): bigint;
function patq2dec(name: string): string;
// Validate a @q string.
function isValidPatq(str: string): boolean;
// Equality comparison on @q values.
function eqPatq(p: string, q: string): boolean;

// @ud manipulation
function parseUd(ud: string): BigInteger;
function formatUd(ud: BigInteger): string;
function parseUd(ud: string): bigint;
function formatUd(ud: bigint): string;

// @uv manipulation
function parseUv(x: string): BigInteger;
function formatUv(x: BigInteger | string): string;
function parseUv(x: string): bigint;
function formatUv(x: bigint | string): string;

// @uw manipulation
function parseUw(x: string): BigInteger;
function formatUw(x: BigInteger | string): string;
function parseUw(x: string): bigint;
function formatUw(x: bigint | string): string;

// @ux manipulation
function parseUx(ux: string): string;
Expand Down
18 changes: 0 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
"size": "size-limit",
"analyze": "size-limit --why"
},
"peerDependencies": {
"big-integer": "^1.6.51"
},
"devDependencies": {
"@size-limit/preset-small-lib": "^8.2.4",
"@tsconfig/recommended": "^1.0.2",
Expand Down
Loading

0 comments on commit 5e89c56

Please sign in to comment.