JSPM

array_decoder

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 504
  • Score
    100M100P100Q90608F
  • License MIT

Like string_decoder but for arrays

Package Exports

  • array_decoder

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (array_decoder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Array Decoder

This class can be used to stream arrays of data when chunks may end with partial elements. Similar to string decoder but for arrays.

Installation

npm install array_decoder

Usage

var ArrayDecoder = require('array_decoder').ArrayDecoder

var decoder = new ArrayDecoder

// Outputs: ['abc', 'def']
console.log(decoder.write(['abc', 'def', 'gh']))

// Outputs: ['ghi', 'jkl']
console.log(decoder.write(['i', 'jkl', 'mn']))

// Outputs: ['mnl']
console.log(decoder.write(['l'], true))

new ArrayDecoder([format])

Output can be string or buffer. If not specified it will be as input.

write(array, complete)

array - Array of strings, buffers or array of arrays of string or buffers. complete - Set to true for last chunk.