New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

queue-buffer

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

queue-buffer

A flexible buffer with a complete but limited Buffer API.

Source
npmnpm
Version
0.1.3
Version published
Weekly downloads
18
-10%
Maintainers
1
Weekly downloads
 
Created
Source

Queue-Buffer

A flex buffer which behaves as a dynamic queue with a complete but limited Buffer API.

  • Queue-Buffer extends Flex-Buffer.
  • Tested on Node 0.8-0.12, latest iojs on Mac, Linux and Windows.
  • Entities in the queue are kept in order and the only operations on the collection are the addition of entities to the rear terminal position, known as enqueue(write), and removal of entities from the front terminal position, known as dequeue(read).

NPM version Deps Build Status Build status

Quick Start

npm install queue-buffer -S

then

QueueBuffer = require("queue-buffer");

buf = new QueueBuffer(10);
buf.write([1, 2, 3, 4, 5]);
buf.writeInt32LE(14);
buf.read(5);

API

QueueBuffer extends Flexbuffer, please see Flex-Buffer for more API info.

  • QueueBuffer.AUTO_RELEASE_THRESHOLD

    Auto release threshold(ms)

    • type: { number }
  • constructor(arg, opts = {})

    see FlexBuffer

    • param: arg { number | Buffer | Array | string }

      The same arg as Buffer.

    • param: opts { Object={} }

      options

    • option: autoRelease { boolean }

      auto release useless space

    • option: autoReleaseThreshold { number }

      auto release threshold(ms)

  • free()

    Release useless space which has been read.

  • move(size)

    Move current read offset.

    • param: size { number }

      number of bytes to move, can be negative.

  • skip(size)

    Move current read offset forward.

    • param: size { number }

      number of bytes to skip

  • rewind(size)

    Move current read offset backward.

    • param: size { number }

      number of bytes to rewind

  • read(size) (alias: unshift, dequeue)

    Read bytes from the head of the buffer.

    • param: size { number }

      number of bytes to read

    • return: { Buffer }

      data

  • write(value, encoding = "utf8") (alias: push, enqueue)

    see FlexBuffer

    • param: value { number | string | Array | Buffer }

      The value to write

    • param: encoding { string="utf8" }

      string encoding

  • length

    length of the data

    • type: { number }

All the native Buffer API is wrapped. However, read* methods can only read data from head, with no offset argument.

Test

npm test

Benchmark

npm run benchmark

Environment: io.js v2.0.0, OS X 10.10.2, Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz

  • Read

    • Buffer x 710,928 ops/sec ±0.40% (91 runs sampled)
    • FlexBuffer x 687,658 ops/sec ±1.44% (90 runs sampled)
  • wrapped native API

    • Buffer x 20,815,938 ops/sec ±0.59% (94 runs sampled)
    • FlexBuffer x 14,698,706 ops/sec ±0.84% (93 runs sampled)

License

MIT@Dracupid

Keywords

flex

FAQs

Package last updated on 09 May 2015

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