@chainfuse/helpers 2.0.3 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,9 @@ export declare class BufferHelpers {
10
10
  * @link https://base64.guru/standards/base64url
11
11
  */
12
12
  static readonly base64urlRegex: RegExp;
13
+ static bigintToBuffer(number: bigint): Promise<UuidExport['blob']>;
14
+ static bigintToHex(number: bigint): UuidExport['hex'];
15
+ static bufferToBigint(buffer: UuidExport['blob'] | D1Blob): Promise<bigint>;
13
16
  static hexToBuffer(hex: UuidExport['hex']): Promise<UuidExport['blob']>;
14
17
  static bufferToHex(buffer: UuidExport['blob'] | D1Blob): Promise<UuidExport['hex']>;
15
18
  static base64ToBuffer(rawBase64: string): Promise<UuidExport['blob']>;
package/dist/buffers.mjs CHANGED
@@ -10,6 +10,16 @@ export class BufferHelpers {
10
10
  * @link https://base64.guru/standards/base64url
11
11
  */
12
12
  static base64urlRegex = new RegExp(/^[a-z\d_-]+$/i);
13
+ static bigintToBuffer(number) {
14
+ const hexString = number.toString(16);
15
+ return this.hexToBuffer(hexString.length % 2 === 0 ? hexString : `0${hexString}`);
16
+ }
17
+ static bigintToHex(number) {
18
+ return number.toString(16).length % 2 === 0 ? number.toString(16) : `0${number.toString(16)}`;
19
+ }
20
+ static bufferToBigint(buffer) {
21
+ return this.bufferToHex(buffer).then((hex) => BigInt(`0x${hex}`));
22
+ }
13
23
  static hexToBuffer(hex) {
14
24
  return (import('node:buffer')
15
25
  .then(({ Buffer }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainfuse/helpers",
3
- "version": "2.0.3",
3
+ "version": "2.1.1",
4
4
  "description": "",
5
5
  "author": "ChainFuse",
6
6
  "homepage": "https://github.com/ChainFuse/packages/tree/main/packages/helpers#readme",
@@ -24,7 +24,7 @@
24
24
  "scripts": {
25
25
  "fmt": "prettier --check .",
26
26
  "fmt:fix": "prettier --write .",
27
- "lint": "eslint .",
27
+ "lint": "eslint src",
28
28
  "lint:fix": "npm run lint -- --fix",
29
29
  "clean": "npx -y rimraf@latest ./dist ./.tsbuildinfo",
30
30
  "build": "tsc",
@@ -54,9 +54,9 @@
54
54
  "uuid": "^11.1.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@chainfuse/types": "^1.7.3",
58
- "@cloudflare/workers-types": "^4.20250319.0",
59
- "@types/node": "^22.13.10"
57
+ "@chainfuse/types": "^2.0.0",
58
+ "@cloudflare/workers-types": "^4.20250320.0",
59
+ "@types/node": "^22.13.11"
60
60
  },
61
- "gitHead": "afa550b265b1815397b3c8f81939c601ff09ae7e"
61
+ "gitHead": "60babb051a4005d8495655784427e446fc7c7bcb"
62
62
  }