webstudio/ui/src/core/extensions/extensions.ts

28 lines
839 B
TypeScript
Raw Normal View History

2023-11-10 12:06:40 +03:00
import { ArrayExtensions } from "./array";
2023-12-10 21:44:41 +03:00
import { MapExtensions } from "./map";
2023-11-10 21:43:57 +03:00
import { StringExtensions } from "./string";
2023-11-10 12:06:40 +03:00
2023-12-10 21:44:41 +03:00
export type CallBackFunction = <T>(value: T) => void;
2023-11-10 21:43:57 +03:00
declare global {
interface Array<T> {
// @strict: The parameter is determined whether the arrays must be exactly the same in content and order of this relationship or simply follow the same requirements.
equals(array: Array<T>, strict: boolean): boolean;
lastElement(): T | undefined;
isEmpty(): boolean;
2023-12-10 21:44:41 +03:00
isNotEmpty(): boolean;
hasIncludeElement(element: T): boolean;
2023-11-10 21:43:57 +03:00
}
interface String {
isEmpty(): boolean;
}
2023-12-10 21:44:41 +03:00
interface Map<K, V> {
addValueOrMakeCallback(key: K, value: V, callBack: CallBackFunction): void;
}
2023-11-10 12:06:40 +03:00
}
2023-11-10 21:43:57 +03:00
export const extensions = () => {
ArrayExtensions();
StringExtensions();
2023-12-10 21:44:41 +03:00
MapExtensions();
2023-11-10 21:43:57 +03:00
};