Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Break up messages into randomly-sized chunks

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 example
Octocat-spinner-32 test
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 README.markdown
Octocat-spinner-32 index.js
Octocat-spinner-32 package.json
README.markdown

chunky

Split up a string or buffer into lots of randomly-sized chunks.

This module is useful for writing unit tests against streams with buffer-boundary conditions.

build status

example

string.js

var chunky = require('chunky');
var chunks = chunky('Beep boop. I am a computer.');
console.dir(chunks);

output:

[ 'Beep boop. I ', 'am a com', 'p', 'ute', 'r.' ]

buffer.js

var chunky = require('chunky')
var chunks = chunky(new Buffer([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]));
console.dir(chunks);

output:

[ <Buffer 00 01>,
  <Buffer >,
  <Buffer 02 03>,
  <Buffer 04 05 06 07>,
  <Buffer 08 09> ]

methods

var chunky = require('chunky')

chunky(msg)

Turn msg into lots of little randomly-sized chunks.

If msg is a string, return an array of strings.

If msg is a Buffer, return an array of Buffers.

license

MIT/X11

install

With npm do:

npm install chunky
Something went wrong with that request. Please try again.