Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
buffer-queue
Advanced tools
Readme
A fast buffer store, for queueing up buffer chunks to later drain as a full buffer for streams. Faster than Buffer.concat
on every chunk.
npm install buffer-queue
Example of a transform stream that only writes downstream 1MB at a time, storing up buffers in the buffer store.
var Transform = require("stream").Transform;
var util = require("util");
var Store = require("buffer-queue");
/**
* Transform stream that limits writes to 1MB at a time
*/
function ThrottleStream (limit) {
this.limit = limit || 1024 * 1024;
this.store = new Store();
Transform.call(this);
}
util.inherits(ThrottleStream, Transform);
ThrottleStream.prototype._transform = function (chunk, enc, callback) {
this.store.push(chunk);
var data;
// While we have more in our store than the limit, then push
// out a chunk
while (this.store.length() > this.limit && data = this.store.shift(this.limit)) {
this.push(data);
}
callback();
};
ThrottleStream.prototype._flush = function (callback) {
var data;
while (data = this.store.shift(this.limit)) {
this.push(data);
}
callback();
};
BufferStore()
Constructor for a buffer store.
store.push(buffer)
Pushes a buffer to the store.
store.shift(n)
Returns the first n
bytes of the entire buffer store and removes from the store.
store.empty()
Empties the entire internal buffer store.
store.length()
Returns the length of the internal buffer store in bytes.
store.drain()
Empties and returns the internal buffer store. Use store.empty()
if you are not interested in the return value.
npm test
MIT License, Copyright (c) 2015 Jordan Santell
FAQs
fast buffer storage
The npm package buffer-queue receives a total of 66,909 weekly downloads. As such, buffer-queue popularity was classified as popular.
We found that buffer-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.