utilium 2.2.1 → 2.2.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.
package/dist/buffer.js CHANGED
@@ -46,11 +46,14 @@ export function initView(view, buffer, byteOffset, byteLength) {
46
46
  }
47
47
  if (!buffer
48
48
  || buffer instanceof ArrayBuffer
49
- || (globalThis.SharedArrayBuffer && buffer instanceof globalThis.SharedArrayBuffer)) {
50
- const { size = 0 } = view.constructor?.[Symbol.metadata]?.struct ?? {}; // Memium structs
49
+ || (globalThis.SharedArrayBuffer && buffer instanceof SharedArrayBuffer)) {
50
+ const size = byteLength
51
+ ?? view.constructor?.[Symbol.metadata]?.struct?.size // Memium structs
52
+ ?? buffer?.byteLength
53
+ ?? 0;
51
54
  view.buffer = buffer ?? new ArrayBuffer(size);
52
55
  view.byteOffset = byteOffset ?? 0;
53
- view.byteLength = byteLength ?? size;
56
+ view.byteLength = size;
54
57
  return;
55
58
  }
56
59
  if (ArrayBuffer.isView(buffer)) {
package/dist/misc.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { resolveConstructors } from './objects.js';
1
2
  export function wait(time) {
2
3
  return new Promise(resolve => setTimeout(resolve, time));
3
4
  }
@@ -44,6 +45,8 @@ export function canary(error = new Error()) {
44
45
  * @see https://github.com/tc39/proposal-throw-expressions
45
46
  */
46
47
  export function _throw(e) {
48
+ if (e && typeof e == 'object' && resolveConstructors(e).includes('Error'))
49
+ Error?.captureStackTrace(e, _throw);
47
50
  throw e;
48
51
  }
49
52
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utilium",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "Typescript utilities",
5
5
  "funding": {
6
6
  "type": "individual",