// runtime/subsystems/storage/storage.utils.ts
async function toBuffer(data) {
  if (Buffer.isBuffer(data)) {
    return data;
  }
  const reader = data.getReader();
  const chunks = [];
  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    if (value) chunks.push(value);
  }
  return Buffer.concat(chunks);
}

export {
  toBuffer
};
//# sourceMappingURL=chunk-J6MN42LG.js.map