JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q54501F
  • License Apache-2.0

A suite of circular data structures, including CircleStack, CircleQueue, and CircleDeque. Use circular buffers with ease and supported by a variety of operations.

Package Exports

  • circle-ds

Readme

Circle DS

A suite of circular data structures, including deques, maps, queues, sets and stacks. Use circular buffers with ease.

Version Maintenance License codecov npm bundle size

Features

Install

Using npm:

npm install circle-ds

Using yarn:

yarn install circle-ds

API

Common

The following is common across all collections.

Constructor

  • constructor(): Initialize an empty collection of infinite capacity.
  • constructor(capacity: number): Initialize an empty collection with the given capacity.

Properties

  • capacity: number: A positive integer that represents the maximum size of the collection. Can be updated to grow or shrink the collection. Can also be set to Infinity.

  • size: Readonly<number>: The number of items in the collection.

  • [Symbol.toStringTag]: A string that represents the type of the object. See Symbol.toStringTag for more details.

Events

  • BoundedEvent.Overflow: Triggered when existing elements are discarded from the collection. This happens when the collection's capacity is reduced below its size or when new values are added while at capacity.

Methods

CircularDeque & CircularLinkedDeque

CircularDeque is a double-ended queue that combines the features of stacks and queues, allowing insertion and removal at both ends.

Constructor

  • CircularDeque<T>(items: Iterable<T>): Initialize a full deque with the given items.

Methods

CircularMap

Constructor

  • CircularMap<K, V>(items: Iterable<[K, V]>): Initialize a full map with the given items. Capacity will be the number of unique keys given.

Methods

CircularQueue & CircularLinkedQueue

CircularQueue is a FIFO (First In, First Out) data structure with a fixed size.

Constructor

  • CircularQueue<T>(items: Iterable<T>): Initialize a full queue with the given items.

Methods

CircularSet

Constructor

  • CircularSet<T>(items: Iterable<T>): Initialize a full set with the given items. Capacity will be the number of unique items given.

Methods

CircularStack & CircularLinkedStack

CircularStack is a LIFO (Last In, First Out) data structure with a fixed capacity.

Constructor

  • CircularStack<T>(items: Iterable<T>): Initialize a full stack with the given items.

Methods

Build

First clone the project from github:

git clone git@github.com:havelessbemore/circle-ds.git
cd circle-ds

Install the project dependencies:

npm install

Then, the project can be build by executing the build script via npm:

npm run build

This will build ESM and CommonJS outputs from the source files and put them in the dist/ folder.

Test

To execute tests for the library, install the project dependencies once:

npm install

Then, the tests can be executed:

npm test

You can separately run the code linter:

npm run lint

To automatically fix linting issue, run:

npm run format

To test code coverage of the tests:

npm run test:coverage

To see the coverage results, open the generated report in your browser:

./coverage/index.html

License

Copyright (C) 2024-2024 Michael Rojas dev.michael.rojas@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Made with ❤️ by Michael Rojas