import { Result } from "../helper/result"; import { ArrayExtensions } from "./array"; import { MapExtensions } from "./map"; import { NumberExtensions } from "./number"; import { StringExtensions } from "./string"; export type CallBackVoidFunction = (value: T) => void; export type CallBackStringVoidFunction = (value: string) => void; export type CallBackEventTarget = (value: EventTarget) => void; export type OptionalProperties = { [P in keyof T]?: T[P]; }; declare global { interface Array { // @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, strict: boolean): boolean; lastElement(): T | undefined; isEmpty(): boolean; isNotEmpty(): boolean; hasIncludeElement(element: T): boolean; repeat(quantity: number): Array; rFind(predicate: (value: T, index: number, obj: never[]) => boolean, thisArg?: any): Result; maxLength(length: number): Array; } interface Number { fromArray(): number[]; toPx(): string; unixFromDate(): string; isValid(str: string): boolean; randRange(min: number, max: number): number; isPositive(): boolean; isNegative(): boolean; } interface String { isEmpty(): boolean; isNotEmpty(): boolean; replaceMany(searchValues: string[], replaceValue: string): string; isEqual(str: string): boolean; isEqualMany(str: string[]): boolean; hasPattern(pattern: string): boolean; hasNoPattern(pattern: string): boolean; } interface Map { addValueOrMakeCallback(key: K, value: V, callBack: CallBackVoidFunction): void; getKeyFromValueIsExists(value: V): K | undefined; overrideValue(key: K, value: OptionalProperties): void; keysToJson(): string; toArray(): V[]; getPredicateValue(callBack: (value: V) => boolean): K[]; incrementValue(key: K): void; } } export const extensions = () => { StringExtensions(); ArrayExtensions(); NumberExtensions(); MapExtensions(); };