Skip to content

magic8bot/fixedset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FixedSet

Is identical to a plain Javascript ES6 Set but with a cap on it's size. Once x amount of items have been added to the set it will start dropping the first item in the set.

Usage

Syntax

new Set(setSize: number, ...items: T[])`

Example

import { FixedSet } from '@magic8bot/fixedset'

const fixedSet = new FixedSet(5, [1, 2, 3, 4]) // Set [1, 2, 3, 4]
fixedSet.add(5) // Set [1, 2, 3, 4, 5]
fixedSet.add(6) // Set [2, 3, 4, 5, 6]
fixedSet.add(7) // Set [3, 4, 5, 6, 7]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published