Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

bufferutil

Package Overview
Dependencies
1
Maintainers
3
Versions
22
Issues
File Explorer

Advanced tools

bufferutil

WebSocket buffer utils

    4.0.6latest

Version published
Maintainers
3
Yearly downloads
44,070,789
increased by28.15%

Weekly downloads

Changelog

Source

v4.0.6

Readme

Source

bufferutil

Version npm Linux/macOS/Windows Build

bufferutil is what makes ws fast. It provides some utilities to efficiently perform some operations such as masking and unmasking the data payload of WebSocket frames.

Installation

npm install bufferutil --save-optional

The --save-optional flag tells npm to save the package in your package.json under the optionalDependencies key.

API

The module exports two functions.

bufferUtil.mask(source, mask, output, offset, length)

Masks a buffer using the given masking-key as specified by the WebSocket protocol.

Arguments

  • source - The buffer to mask.
  • mask - A buffer representing the masking-key.
  • output - The buffer where to store the result.
  • offset - The offset at which to start writing.
  • length - The number of bytes to mask.

Example

'use strict'; const bufferUtil = require('bufferutil'); const crypto = require('crypto'); const source = crypto.randomBytes(10); const mask = crypto.randomBytes(4); bufferUtil.mask(source, mask, source, 0, source.length);

bufferUtil.unmask(buffer, mask)

Unmasks a buffer using the given masking-key as specified by the WebSocket protocol.

Arguments

  • buffer - The buffer to unmask.
  • mask - A buffer representing the masking-key.

Example

'use strict'; const bufferUtil = require('bufferutil'); const crypto = require('crypto'); const buffer = crypto.randomBytes(10); const mask = crypto.randomBytes(4); bufferUtil.unmask(buffer, mask);

License

MIT

Keywords

FAQs

What is bufferutil?

WebSocket buffer utils

Is bufferutil popular?

The npm package bufferutil receives a total of 973,997 weekly downloads. As such, bufferutil popularity was classified as popular.

Is bufferutil well maintained?

We found that bufferutil demonstrated a healthy version release cadence and project activity. It has 3 open source maintainers collaborating on the project.

Last updated on 02 Jan 2022
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc