@naeemo/capnp 0.6.0 → 0.7.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.
package/dist/cli.js CHANGED
@@ -1289,6 +1289,25 @@ var StructReader = class StructReader {
1289
1289
  return new TextDecoder().decode(bytes);
1290
1290
  }
1291
1291
  /**
1292
+ * 获取数据字段
1293
+ * Data is stored as List(UInt8) without NUL terminator
1294
+ * @param pointerIndex - The index of the pointer in the pointer section
1295
+ * @returns Uint8Array of the data content, or undefined if null pointer
1296
+ */
1297
+ getData(pointerIndex) {
1298
+ const ptrOffset = this.wordOffset + this.dataWords + pointerIndex;
1299
+ const resolved = this.message.resolvePointer(this.segmentIndex, ptrOffset);
1300
+ if (!resolved) return void 0;
1301
+ const { segmentIndex, wordOffset, pointer } = resolved;
1302
+ if (pointer.tag !== PointerTag.LIST) return void 0;
1303
+ const listPtr = pointer;
1304
+ const segment = this.message.getSegment(segmentIndex);
1305
+ const byteLength = listPtr.elementCount;
1306
+ if (byteLength === 0) return new Uint8Array(0);
1307
+ const bytes = new Uint8Array(segment.dataView.buffer, wordOffset * WORD_SIZE, byteLength);
1308
+ return new Uint8Array(bytes);
1309
+ }
1310
+ /**
1292
1311
  * 获取嵌套结构
1293
1312
  */
1294
1313
  getStruct(pointerIndex, _dataWords, _pointerCount) {