@divine-dkh/fixed-size
v1.2.3
Published
Fixed-size sets, maps and arrays
Downloads
3
Maintainers
Readme
FixedSize
Fixed-size sets and maps
Installation
npm install @divine-dkh/fixed-size
Examples
Example 1: FixedSize.Set
'use strict'
const FixedSize = require('@divine-dkh/fixed-size')
// or
// const FixedSizeSet = require('@divine-dkh/fixed-size/set')
const set = new FixedSize.Set(3)
// or
// const set = new FixedSizeSet(3)
for (let i = 0; i < 4; i++) {
set.add(i)
}
console.log(set)
// => FixedSizeSet [Set] { 1, 2, 3, maxSize: 3 }
Example 2: FixedSize.Map
'use strict'
const FixedSize = require('@divine-dkh/fixed-size')
// or
// const FixedSizeMap = require('@divine-dkh/fixed-size/map')
const map = new FixedSize.Map(3)
// or
// const map = new FixedSizeMap(3)
for (let i = 0; i < 4; i++) {
map.set(i, i)
}
console.log(map)
// => FixedSizeMap [Map] { 1 => 1, 2 => 2, 3 => 3, maxSize: 3 }