cafe-utility 33.3.2 → 33.3.3

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.
Files changed (3) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +4 -4
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -611,7 +611,7 @@ declare function numberToUint64(number: bigint, endian: 'LE' | 'BE'): Uint8Array
611
611
  declare function uint64ToNumber(bytes: Uint8Array, endian: 'LE' | 'BE'): bigint
612
612
  declare function numberToUint256(number: bigint, endian: 'LE' | 'BE'): Uint8Array
613
613
  declare function uint256ToNumber(bytes: Uint8Array, endian: 'LE' | 'BE'): bigint
614
- declare function sliceBytes(bytes: Uint8Array, lengths: number[]): Uint8Array[]
614
+ declare function sliceBytes(bytes: Uint8Array, lengths: number[]): Uint8Array<ArrayBufferLike>[]
615
615
  declare function partition(bytes: Uint8Array, size: number): Uint8Array[]
616
616
  declare function keccak256(bytes: Uint8Array): Uint8Array
617
617
  declare function sha3_256(bytes: Uint8Array): Uint8Array
package/index.js CHANGED
@@ -401,8 +401,8 @@ function asString(n, e) {
401
401
  }
402
402
  function asHexString(n, e) {
403
403
  if (!isHexString(n)) throw new TypeError(`Expected hex string${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
404
- if (e?.strictPrefix && !n.startsWith('0x')) throw new TypeError(`Expected hex string with 0x prefix${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
405
- const t = n.replace(/^0x/, '')
404
+ if (e?.strictPrefix && !n.startsWith('0x') && !n.startsWith('0X')) throw new TypeError(`Expected hex string with 0x prefix${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
405
+ const t = n.replace(/^0x/i, '')
406
406
  if (t.length % 2 !== 0 && !e?.uneven) throw RangeError(`Expected even number of hex digits${e?.name ? ` for ${e.name}` : ''}; got: ` + n)
407
407
  if (e && e.byteLength && t.length !== e.byteLength * 2) throw RangeError(`Expected hex string${e?.name ? ` for ${e.name}` : ''} of byte length ${e.byteLength}; got: ` + t)
408
408
  return `0x${t}`
@@ -2050,13 +2050,13 @@ function numberToUint256(n, e) {
2050
2050
  for (let i = 0; i < 32; i++) (r[i] = Number(o & 0xffn)), (o >>= 8n)
2051
2051
  return r
2052
2052
  }
2053
- for (let i = 32 - 1; i >= 0; i--) (r[i] = Number(o & 0xffn)), (o >>= 8n)
2053
+ for (let i = 31; i >= 0; i--) (r[i] = Number(o & 0xffn)), (o >>= 8n)
2054
2054
  return r
2055
2055
  }
2056
2056
  function uint256ToNumber(n, e) {
2057
2057
  let r = 0n
2058
2058
  if (e === 'LE') {
2059
- for (let o = 32 - 1; o >= 0; o--) r = (r << 8n) | BigInt(n[o])
2059
+ for (let o = 31; o >= 0; o--) r = (r << 8n) | BigInt(n[o])
2060
2060
  return r
2061
2061
  }
2062
2062
  for (let o = 0; o < 32; o++) r = (r << 8n) | BigInt(n[o])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "33.3.2",
3
+ "version": "33.3.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {