New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@endeo/output

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@endeo/output

Send bytes to buffer list or stream

  • 0.2.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

@endeo/output

Build Status Dependency Status npm version Coverage Status

Send bytes to buffer list or stream.

See packages:

  1. endeo
  2. enbyte

Install

npm install --save @endeo/output

Usage

// get the builder
var Output = require('@endeo/output')

// build one for synchronous operation
var output = new Output()

// or, build one for async operation
var stream = getSomeStream()
// target a Writable stream
var output = new Output(stream.write, stream)
// target a Transform stream
var output = new Output(transform.push, transform)

// optionally have output prepare to accept a
// certain number of bytes.
output.prepare(8)

// either way, it is used the same.
// specify a single byte value.
// this is appended to an internal buffer.
// when the buffer is full:
//   1. the sync version stores it in an array of buffers
//   2. the async version sends it to the stream
output.byte(0xAB)

// send more than one byte at once:
output.byte2(0x01, 0x02)
output.byte3(0x01, 0x02, 0x03)
output.byte4(0x01, 0x02, 0x03, 0x04)

// send specific number sizes:
//   'short' is 2 bytes
output.short(12345)
// int is for 1 to 6 bytes ints.
output.int(1234567890, 4)

// and floats (4 bytes, 8 bytes):
output.float4(1.25)
output.float8(12345.123456789)

// and a string:
// Note: UTF8 encoding is used
output.string('some string')

// finally, a Buffer
output.buffer(someBuffer)


// when all bytes have been provided get the result:
//
// 1. sync operation provides a single Buffer with all content
buffer = output.complete()
//
// 2. async operation ensures what's left is sent forward.
//    (basically, flush)
result = output.complete()
//
// the result for async is something to show success:
result = {
  success: true
}

MIT License

FAQs

Package last updated on 18 May 2017

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

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc