apply-hooks
Version:
A high-quality & reliable JavaScript Hooks library.
33 lines (32 loc) • 665 B
TypeScript
/**
* push 入栈
* pop 出栈
* peek 返回栈顶元素,栈中不做操作
* isEmpty 判断是否为空
* size 返回个数
* toString 以字符串形式返回
*/
declare const enum IStackType {
Array = 0,
LinkedList = 1
}
interface IPush<T> {
(value: T): boolean;
}
interface IPop<T> {
(): T | boolean;
}
interface IPeek<T> {
(): T | boolean;
}
interface IIsEmpty {
(): boolean;
}
interface IToString {
(splitSign?: string): string;
}
interface IGetSize {
(): number;
}
declare const useStack: <T>(type?: IStackType, max?: number) => [IPush<T>, IPop<T>, IPeek<T>, IIsEmpty, IToString, IGetSize];
export default useStack;