@chainfuse/helpers 2.1.1 → 2.2.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.
- package/dist/buffers.d.mts +4 -5
- package/dist/buffers.mjs +4 -4
- package/package.json +5 -5
package/dist/buffers.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PrefixedUuid, UndefinedProperties, UuidExport } from '@chainfuse/types';
|
|
2
2
|
export declare class BufferHelpers {
|
|
3
3
|
static readonly utf8Regex: RegExp;
|
|
4
4
|
static readonly hexRegex: RegExp;
|
|
@@ -12,18 +12,17 @@ export declare class BufferHelpers {
|
|
|
12
12
|
static readonly base64urlRegex: RegExp;
|
|
13
13
|
static bigintToBuffer(number: bigint): Promise<UuidExport['blob']>;
|
|
14
14
|
static bigintToHex(number: bigint): UuidExport['hex'];
|
|
15
|
-
static bufferToBigint(buffer: UuidExport['blob']
|
|
15
|
+
static bufferToBigint(buffer: UuidExport['blob']): Promise<bigint>;
|
|
16
16
|
static hexToBuffer(hex: UuidExport['hex']): Promise<UuidExport['blob']>;
|
|
17
|
-
static bufferToHex(buffer: UuidExport['blob']
|
|
17
|
+
static bufferToHex(buffer: UuidExport['blob']): Promise<UuidExport['hex']>;
|
|
18
18
|
static base64ToBuffer(rawBase64: string): Promise<UuidExport['blob']>;
|
|
19
|
-
static bufferToBase64(buffer: UuidExport['blob']
|
|
19
|
+
static bufferToBase64(buffer: UuidExport['blob'], urlSafe: boolean): Promise<string>;
|
|
20
20
|
static get generateUuid(): Promise<UuidExport>;
|
|
21
21
|
static uuidConvert(input: undefined): Promise<UndefinedProperties<UuidExport>>;
|
|
22
22
|
static uuidConvert(prefixedUtf: PrefixedUuid): Promise<UuidExport>;
|
|
23
23
|
static uuidConvert(input: UuidExport['utf8']): Promise<UuidExport>;
|
|
24
24
|
static uuidConvert(input: UuidExport['hex']): Promise<UuidExport>;
|
|
25
25
|
static uuidConvert(input: UuidExport['blob']): Promise<UuidExport>;
|
|
26
|
-
static uuidConvert(input: D1Blob): Promise<UuidExport>;
|
|
27
26
|
static uuidConvert(input: UuidExport['base64']): Promise<UuidExport>;
|
|
28
27
|
static uuidConvert(input: UuidExport['base64url']): Promise<UuidExport>;
|
|
29
28
|
}
|
package/dist/buffers.mjs
CHANGED
|
@@ -33,12 +33,12 @@ export class BufferHelpers {
|
|
|
33
33
|
}
|
|
34
34
|
static bufferToHex(buffer) {
|
|
35
35
|
return (import('node:buffer')
|
|
36
|
-
// @ts-expect-error `ArrayBufferLike`
|
|
36
|
+
// @ts-expect-error `ArrayBufferLike` is actually accepted and fine
|
|
37
37
|
.then(({ Buffer }) => Buffer.from(buffer).toString('hex'))
|
|
38
38
|
/**
|
|
39
39
|
* @link https://jsbm.dev/AoXo8dEke1GUg
|
|
40
40
|
*/
|
|
41
|
-
// @ts-expect-error `ArrayBufferLike`
|
|
41
|
+
// @ts-expect-error `ArrayBufferLike` is actually accepted and fine
|
|
42
42
|
.catch(() => new Uint8Array(buffer).reduce((output, elem) => output + ('0' + elem.toString(16)).slice(-2), '')));
|
|
43
43
|
}
|
|
44
44
|
static base64ToBuffer(rawBase64) {
|
|
@@ -73,7 +73,7 @@ export class BufferHelpers {
|
|
|
73
73
|
}
|
|
74
74
|
static bufferToBase64(buffer, urlSafe) {
|
|
75
75
|
return (import('node:buffer')
|
|
76
|
-
// @ts-expect-error `ArrayBufferLike`
|
|
76
|
+
// @ts-expect-error `ArrayBufferLike` is actually accepted and fine
|
|
77
77
|
.then(({ Buffer }) => Buffer.from(buffer).toString(urlSafe ? 'base64url' : 'base64'))
|
|
78
78
|
.catch(() => {
|
|
79
79
|
// @ts-expect-error `ArrayBufferLike` is actually accepted and fine
|
|
@@ -152,7 +152,7 @@ export class BufferHelpers {
|
|
|
152
152
|
return Promise.all([this.bufferToHex(input), this.bufferToBase64(input, false), this.bufferToBase64(input, true)]).then(([hex, base64, base64url]) => ({
|
|
153
153
|
utf8: `${hex.substring(0, 8)}-${hex.substring(8, 12)}-${hex.substring(12, 16)}-${hex.substring(16, 20)}-${hex.substring(20)}`,
|
|
154
154
|
hex,
|
|
155
|
-
// @ts-expect-error `ArrayBufferLike`
|
|
155
|
+
// @ts-expect-error `ArrayBufferLike` is actually accepted and fine
|
|
156
156
|
blob: new Uint8Array(input).buffer,
|
|
157
157
|
base64,
|
|
158
158
|
base64url,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainfuse/helpers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "ChainFuse",
|
|
6
6
|
"homepage": "https://github.com/ChainFuse/packages/tree/main/packages/helpers#readme",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"uuid": "^11.1.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@chainfuse/types": "^2.
|
|
58
|
-
"@cloudflare/workers-types": "^4.
|
|
59
|
-
"@types/node": "^22.13.
|
|
57
|
+
"@chainfuse/types": "^2.1.1",
|
|
58
|
+
"@cloudflare/workers-types": "^4.20250321.0",
|
|
59
|
+
"@types/node": "^22.13.13"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "f0eaab21228260be471a6fac0874068139677035"
|
|
62
62
|
}
|