abstract-list
v1.0.16
Published
Provide an interface for abstract lists. An abstract list behaves like a read-only array, but without storage. It can virtually store an infinite number of elements. It's meant for working flexibly with arrays. Regular arrays can be used as abstract lists
Downloads
11
Maintainers
Readme
abstract-list
Abstract list for working with arrays that aren't really arrays.
Usage
// This is an abstract list
const arrayList: List<number> = [1, 2, 3];
// This is also an abstract list
const aList: List<number> = {
at(index) {
return index;
},
length: Number.MAX_SAFE_INTEGER,
};
// This is a giant list for which elem.at(x) === x^2
const squareList: List<number> = {
at(index) {
return index * index;
},
length: Number.MAX_SAFE_INTEGER,
};
In bun-engine, abstract lists are used to represent a large number sprites flexibly, without storing each sprite structure.
Install bun
curl -fsSL https://bun.sh/install | bash