Socket
Book a DemoInstallSign in
Socket

@intrnl/chunked-uint8-iterator

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@intrnl/chunked-uint8-iterator

Create chunked iterator from Uint8Array iterables

0.2.0
latest
npmnpm
Version published
Maintainers
1
Created
Source

chunked-uint8-iterator

Create chunked iterator from Uint8Array iterables

import { createReadStream } from 'node:fs';
import chunked from '@intrnl/chunked-uint8-iterator';

let stream = createReadStream('./archive.zip');

for (let values of chunked(stream)) {
  // ...
}

This will default to yielding 512 bytes of chunks at a time, you can configure this by passing a number as the second argument.

for (let values of chunked(stream, 1024)) {
  // ...
}

If the iterable ends with less than the given chunk size, it will yield the remaining bytes as is without padding.

Using web streams

Your web browser might not support using ReadableStream directly as an async iterable, if that's the case, this library provides createStreamIterator which you can pass directly into chunked.

import chunked, { createStreamIterator } from '@intrnl/chunked-uint8-iterator';

let stream = file.stream();

for (let chunks of chunked(createStreamIterator(stream))) {
  // ...
}

FAQs

Package last updated on 29 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.