msgpackr 1.8.1 → 1.8.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/README.md CHANGED
@@ -53,8 +53,8 @@ receivingStream.on('data', (data) => {
53
53
  ```
54
54
  The `PackrStream` and `UnpackrStream` instances will have also the record structure extension enabled by default (see below).
55
55
 
56
- ## Deno Usage
57
- Msgpackr modules are standard ESM modules and can be loaded directly from the [deno.land registry for msgpackr](https://deno.land/x/msgpackr) for use in Deno. The standard pack/encode and unpack/decode functionality is available on Deno, like other platforms.
56
+ ## Deno and Bun Usage
57
+ Msgpackr modules are standard ESM modules and can be loaded directly from the [deno.land registry for msgpackr](https://deno.land/x/msgpackr) for use in Deno or using the NPM module loader with `import { unpack } from 'npm:msgpackr'`. The standard pack/encode and unpack/decode functionality is available on Deno, like other platforms. msgpackr can be used like any other package on Bun.
58
58
 
59
59
  ## Browser Usage
60
60
  Msgpackr works as standalone JavaScript as well, and runs on modern browsers. It includes a bundled script, at `dist/index.js` for ease of direct loading:
@@ -117,7 +117,7 @@
117
117
  let size = source.length;
118
118
  let value = this ? this.unpack(source, size) : defaultUnpackr.unpack(source, size);
119
119
  if (forEach) {
120
- forEach(value);
120
+ if (forEach(value) === false) return;
121
121
  while(position$1 < size) {
122
122
  lastPosition = position$1;
123
123
  if (forEach(checkedRead()) === false) {
@@ -1108,7 +1108,7 @@
1108
1108
  if (maxSharedStructures > 8160)
1109
1109
  throw new Error('Maximum maxSharedStructure is 8160')
1110
1110
  if (options.structuredClone && options.moreTypes == undefined) {
1111
- options.moreTypes = true;
1111
+ this.moreTypes = true;
1112
1112
  }
1113
1113
  let maxOwnStructures = options.maxOwnStructures;
1114
1114
  if (maxOwnStructures == null)
@@ -1803,12 +1803,11 @@
1803
1803
  if (notifySharedUpdate)
1804
1804
  return hasSharedUpdate = true;
1805
1805
  position = newPosition;
1806
- if (start > 0) {
1807
- pack(value);
1808
- if (start == 0)
1809
- return { position, targetView, target }; // indicate the buffer was re-allocated
1810
- } else
1811
- pack(value);
1806
+ let startTarget = target;
1807
+ pack(value);
1808
+ if (startTarget !== target) {
1809
+ return { position, targetView, target }; // indicate the buffer was re-allocated
1810
+ }
1812
1811
  return position;
1813
1812
  }, this);
1814
1813
  if (newPosition === 0) // bail and go to a msgpack object