@lottiefiles/relottie-parse
Version:
Parse Lottie JSON format to LAST
40 lines (38 loc) • 1.01 kB
JavaScript
import { __publicField } from './chunk-V6TY7KAL.js';
// src/stack.ts
var Stack = class {
constructor(_capacity = Infinity) {
this._capacity = _capacity;
__publicField(this, "_keys", []);
__publicField(this, "_storage", /* @__PURE__ */ new WeakMap());
}
peek() {
const size = this.size();
const key = this._keys[size - 1];
return key ? this._storage.get(key) : void 0;
}
pop() {
const key = this._keys.pop();
if (key === void 0) {
return void 0;
} else {
const item = this._storage.get(key);
this._storage.delete(key);
return item;
}
}
push(item) {
if (this.size() === this._capacity) {
throw Error("Stack has reached max capacity, you cannot add more items");
}
const key = { i: this._keys.length };
this._storage.set(key, item);
this._keys.push(key);
}
size() {
return this._keys.length;
}
};
export { Stack };
//# sourceMappingURL=chunk-VD77DRXR.js.map
//# sourceMappingURL=chunk-VD77DRXR.js.map