cafe-utility 26.13.0 → 26.14.0

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 +2 -2
  2. package/index.js +10 -10
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -510,8 +510,8 @@ declare function keccak256(bytes: Uint8Array): Uint8Array;
510
510
  declare function sha3_256(bytes: Uint8Array): Uint8Array;
511
511
  declare function proximity(one: Uint8Array, other: Uint8Array, max: number): number;
512
512
  declare function commonPrefix(one: Uint8Array, other: Uint8Array): Uint8Array;
513
- declare function setBit(bytes: Uint8Array, index: number, value: 0 | 1): void;
514
- declare function getBit(bytes: Uint8Array, index: number): 0 | 1;
513
+ declare function setBit(bytes: Uint8Array, index: number, value: 0 | 1, endian: 'LE' | 'BE'): void;
514
+ declare function getBit(bytes: Uint8Array, index: number, endian: 'LE' | 'BE'): 0 | 1;
515
515
  declare function binaryIndexOf(bytes: Uint8Array, value: Uint8Array, start?: number): number;
516
516
  declare function binaryPadStart(bytes: Uint8Array, size: number): Uint8Array;
517
517
  declare function binaryPadStartToMultiple(bytes: Uint8Array, multiple: number): Uint8Array;
package/index.js CHANGED
@@ -2123,21 +2123,21 @@ function numberToUint16(n, e) {
2123
2123
  return new DataView(t).setUint16(0, n, e === 'LE'), new Uint8Array(t)
2124
2124
  }
2125
2125
  function uint16ToNumber(n, e) {
2126
- return new DataView(n.buffer).getUint16(0, e === 'LE')
2126
+ return new DataView(n.buffer).getUint16(n.byteOffset, e === 'LE')
2127
2127
  }
2128
2128
  function numberToUint32(n, e) {
2129
2129
  const t = new ArrayBuffer(4)
2130
2130
  return new DataView(t).setUint32(0, n, e === 'LE'), new Uint8Array(t)
2131
2131
  }
2132
2132
  function uint32ToNumber(n, e) {
2133
- return new DataView(n.buffer).getUint32(0, e === 'LE')
2133
+ return new DataView(n.buffer).getUint32(n.byteOffset, e === 'LE')
2134
2134
  }
2135
2135
  function numberToUint64(n, e) {
2136
2136
  const t = new ArrayBuffer(8)
2137
2137
  return new DataView(t).setBigUint64(0, BigInt(n), e === 'LE'), new Uint8Array(t)
2138
2138
  }
2139
2139
  function uint64ToNumber(n, e) {
2140
- return new DataView(n.buffer).getBigUint64(0, e === 'LE')
2140
+ return new DataView(n.buffer).getBigUint64(n.byteOffset, e === 'LE')
2141
2141
  }
2142
2142
  function numberToUint256(n, e) {
2143
2143
  const r = new Uint8Array(32)
@@ -2445,15 +2445,15 @@ function commonPrefix(n, e) {
2445
2445
  for (let r = 0; r < t; r++) if (n[r] !== e[r]) return n.subarray(0, r)
2446
2446
  return n.subarray(0, t)
2447
2447
  }
2448
- function setBit(n, e, t) {
2448
+ function setBit(n, e, t, r) {
2449
+ const o = Math.floor(e / 8),
2450
+ i = e % 8
2451
+ t === 1 ? (n[o] |= 1 << (r === 'BE' ? 7 - i : i)) : (n[o] &= ~(1 << (r === 'BE' ? 7 - i : i)))
2452
+ }
2453
+ function getBit(n, e, t) {
2449
2454
  const r = Math.floor(e / 8),
2450
2455
  o = e % 8
2451
- t === 1 ? (n[r] |= 1 << (7 - o)) : (n[r] &= ~(1 << (7 - o)))
2452
- }
2453
- function getBit(n, e) {
2454
- const t = Math.floor(e / 8),
2455
- r = e % 8
2456
- return (n[t] >> (7 - r)) & 1
2456
+ return (n[r] >> (t === 'BE' ? 7 - o : o)) & 1
2457
2457
  }
2458
2458
  function binaryIndexOf(n, e, t = 0) {
2459
2459
  for (let r = t; r < n.length; r++)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "26.13.0",
3
+ "version": "26.14.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {