@accordproject/concerto-util
Version:
Utilities for Concerto Modeling Language
40 lines (39 loc) • 1.22 kB
TypeScript
type Constructor<T> = new (...args: unknown[]) => T;
/**
* Tracks a stack of typed instances. The type information is used to detect
* overflow / underflow bugs by the caller. It also performs basic sanity
* checking on push/pop to make detecting bugs easier.
* @class
* @memberof module:concerto-core
*/
declare class TypedStack<T> {
stack: T[];
/**
* Create the Stack with the resource at the head.
* @param resource - the resource to be put at the head of the stack
*/
constructor(resource: T);
/**
* Push a new object.
* @param obj - the object being visited
* @param expectedType - the expected type of the object being pushed
*/
push(obj: T, expectedType?: Constructor<T>): void;
/**
* Push a new object.
* @param expectedType - the type that should be the result of pop
* @return the result of pop
*/
pop(expectedType?: Constructor<T>): T | undefined;
/**
* Peek the top of the stack
* @param expectedType - the type that should be the result of pop
* @return the result of peek
*/
peek(expectedType?: Constructor<T>): T;
/**
* Clears the stack
*/
clear(): void;
}
export = TypedStack;