# through2-objectify

> A through2 for transforming buffer (or string) streams into objectMode ones (or vice-versa).

Latest version **0.1.1** (published 2014-06-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install through2-objectify
pnpm add through2-objectify
yarn add through2-objectify
bun add through2-objectify
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2014-06-11 |
| First published | 2014-06-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Travis Collins |
| Maintainers | tec27 |
| Keywords | through2, objectMode, buffer, string, transform |

## Links

- npm: https://www.npmjs.com/package/through2-objectify
- Repository: https://github.com/tec27/through2-objectify
- Issues: https://github.com/tec27/through2-objectify/issues
- npm.io page: https://npm.io/package/through2-objectify

## Dependencies (2)

- [inherits](https://npm.io/package/inherits.md) ^2.0.1
- [through2](https://npm.io/package/through2.md) ^0.5.1

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2014-06-11
- 0.1.0 — 2014-06-11

## README

#through2-objectify
A through2 for transforming a buffer (or string) stream to an objectMode one (or vice-versa).

[![Build Status](https://img.shields.io/travis/tec27/through2-objectify.png?style=flat)](https://travis-ci.org/tec27/through2-objectify)
[![NPM](https://img.shields.io/npm/v/through2-objectify.svg?style=flat)](https://www.npmjs.org/package/through2-objectify)

[![NPM](https://nodei.co/npm/through2-objectify.png)](https://www.npmjs.org/package/through2-objectify)

## Usage
```javascript
var objectify = require('through2-objectify')
  , concat = require('concat-stream')
  , net = require('net')

var srv = net.createServer(function(c) {
  c.end('abc')
}).listen(1337)

net.connect(1337).pipe(objectify(function(chunk, enc, cb) {
  var s = chunk.toString()
  for (var i = 0; i < s.length; i++) {
    this.push({ c: s[i] })
  }
  cb()
})).pipe(concat(function(values) {
  console.dir(values)
  /* Output:
    [
      { c: 'a' },
      { c: 'b' },
      { c: 'c' }
    ]
  */

  srv.close()
})
```

## API
`var objectify = require('through2-objectify')`

<b><code>objectify([options,] transformFn [, flushFn])</code></b>

Create a through2 transform stream that converts buffers (or strings) to objects.

<b><code>objectify.ctor([options,] transformFn [, flushFn])</code></b>

Returns a constructor function for a custom stream that converts buffers (or strings) to objects. Useful if you want to have multiple streams with the same transform/flush functions, or if you want to inherit from the stream type.

<b><code>objectify.deobj([options,] transformFn [, flushFn])</code></b>

Create a through2 transform stream that converts objects to buffers (or strings).

<b><code>objectify.deobjCtor([options,] transformFn [, flushFn])</code></b>

Returns a constructor function for a custom stream that converts objects to buffers (or strings).

### options
Any options valid for Transform streams can be passed, as well as the following objectify-specific options:

<b><code>objectHighWaterMark</code></b>

Sets the highWaterMark specifically for the object side of the stream
(i.e. Readable on objectify, Writable on deobjectify). This allows you to control highWaterMarks separately
and not buffer e.g. 16k objects when you want to buffer 16k bytes.

Defaults to **16**.

### transformFn
`function(chunk, enc, cb)`

Called for each buffer/string/object that needs to be transformed. See streams and through2 documentation for further details.

### flushFn
`function(cb)`

Called just before emitting the `end` signal, but after all data has been transformed. See streams and through2 documentation for further details.

## See also
* [through2](https://github.com/rvagg/through2)
* [Node streams](http://nodejs.org/api/stream.html)

## Installation
`npm install through2-objectify`

## Running tests
`npm test`

## License
MIT

---
_Source: https://npm.io/package/through2-objectify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
