Socket
Socket
Sign inDemoInstall

chop-stream

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    chop-stream

Chop a data stream into fixed size buffer chunks


Version published
Weekly downloads
4
decreased by-84.62%
Maintainers
1
Install size
4.59 kB
Created
Weekly downloads
 

Readme

Source

chop-stream

npm downloads dependencies license

Chop a data stream into fixed size buffer chunks. Written in ES2015.

install

$ npm install chop-stream

example

const ChopStream = require('chop-stream')

const chop = new ChopStream({ size: 8, padding: true })

chop.on('data', (chunk) => console.log(chunk))

process.stdin.pipe(chop)

output

<Buffer 61 62 63 64 65 66 67 68>
<Buffer 69 6a 6b 6c 6d 6e 6f 70>
<Buffer 71 72 73 74 75 76 77 78>
<Buffer 79 7a 0a 00 00 00 00 00>

See the examples folder for more details on how to customize the animation.

usage

ChopStream is a node Transform stream.

chop = new ChopStream(size, options = { padding: false, size: 1024 })

size: size of output chunks. Can be omitted and set in options instead.

padding: pad the end of a stream with zeroes to align the last chunk.

see also

Has this not been done before?

Sure, here are a few examples:

A few? Did we really need yet another module?

Probably not, but I wanted a small dependency-free ES2015 version.

Why open a pull request, when you can follow the trend and add yet another module.

Keywords

FAQs

Last updated on 19 Sep 2018

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc