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

@iter-tools/queue

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iter-tools/queue

An es6-style iterable queue

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
43
increased by43.33%
Maintainers
1
Weekly downloads
 
Created
Source

@iter-tools/queue

Build Status codecov

A simple es6 linked FIFO queue in the pattern of es6 Map and Set. Includes typescript libdefs. Suitable for node or browser environments.

Usage

const Queue = require('@iter-tools/queue');

const q = new Queue([1, 2, 3]);
q.push(4);
[...q]; // [1, 2, 3, 4]
q.size; // 4
q.shift(); // 1
q.shift(); // 2
q.shift(); // 3
q.shift(); // 4
q.size; // 0
q.shift(); // undefined

API

/**
 * The values which has been in the queue longest is its head.
 * The most recent addition is the tail.
 */
class Queue<T> {
  /**
   * An optional iterable of `values` to be pushed
   * into the queue in sequence. If `null` or `undefined` are
   * passed the queue will have no initial values.
   */
  constructor(values?: Iterable<T>);

  /**
   * Returns true if `inst` is a Queue.
   * This does not necessarily imply instanceof, but the check
   * is safe across frame boundaries, as it is done by looking for
   * Queue[Symbol.for('@iter-tools/queue')]
   */
  static isQueue(inst);

  /**
   * The number of values in the queue
   */
  size: number;

  /**
   * Returns the value at the head of the queue.
   */
  peek(): T;

  /**
   * Removes the value at the head of the queue and returns it.
   */
  shift(): T;

  /**
   * Adds `value` at the tail of the queue.
   */
  push(value: T);

  /**
   * Calls `cb(value)` for each value in the queue.
   * If `thisArg` is specified and not null it will be used
   * as the `this` value for each callback.
   */
  forEach(cb: (T) => any, thisArg: any);

  [Symbol.iterator](): IterableIterator<T>;
}

Keywords

FAQs

Package last updated on 31 Jul 2020

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