///
///
declare type int = number;
declare type float = number;
declare namespace __jymfony {
/**
* Base class for all jymfony managed objects.
*/
export class JObject {
/**
* Constructor.
*/
__construct(...args: any[]): any | undefined;
}
/**
* Applies a timeout to the promise.
*/
export function promiseTimeout, K>(timeoutMs: number, promise: T, timeoutError?: () => Error, weak?: boolean): Promise;
export function promiseTimeout, K>(timeoutMs: number, promise: T, timeoutError?: () => Error, weak?: boolean): T;
/**
* Executes a callback iterating asynchronously onto the given iterator.
*/
export function forAwait(iterator: Iterable | AsyncIterable, callback: Invokable | Function | GeneratorFunction): Promise;
/**
* Stops execution for the given number of ms.
* The returned promised resolves after the time has passed.
*/
export function sleep(ms: number): Promise;
/**
* Gets a debug representation of the value (class name of type).
*/
export function get_debug_type(value: any): string;
/**
* Emits a deprecation warning message.
*/
export function trigger_deprecated(message: string): void;
/**
* Sync-recursively creates directories.
*/
export function mkdir(dir: string, mode?: number): void;
/**
* Creates a function that delays invoking a function after
* a given time has elapsed, de-duplicating calls.
*/
export function debounce(func: Invokable, wait: number): Invokable;
/**
* Gets a method given an object and the method name.
*/
export function getFunction(object: Object, funcName: string): (...args: [...P]) => T;
/**
* Clones an object.
*/
export function clone(object: T): T;
/**
* Recursively clones an object and all its arrays/literal objects.
*/
export function deepClone(object: Object): Object;
/**
* Recursively merges literal objects/arrays.
*/
export function deepMerge(...args: (any[]|Record)[]): any|Object;
/**
* Calculate object difference by keys.
*/
export function diffKey(arr1: any[]|Record, ...arrs: (any[]|Record)[]): Object;
/**
* Get key, value pairs from any object.
*/
export function getEntries(object: V[]|Set): IterableIterator<[number, V]>;
export function getEntries(object: T): IterableIterator<[K, T[K]]>;
/**
* Deep-equality check.
*/
export function equal(left: any, right: any, strict?: boolean): boolean;
/**
* Get object keys.
*/
export function keys(obj: any[]): number[];
export function keys(obj: Record): K[];
export function keys(obj: Map): K[];
/**
* Returns an object with the common keys only.
*/
export function intersect_key(obj: any[]|Record, ...arrays: (any[]|Record)[]): Record;
/**
* Merges arrays or objects.
*/
export function objectMerge(...args: any[]): any;
/**
* Converts a key-value object to a Map object.
*/
export function obj2map(obj: Record): Map;
/**
* Converts a Map object to a key-value object.
*/
export function map2obj(obj: Map): Record;
/**
* Serializes any value to a string.
*/
export function serialize(value: any): string;
/**
* Unserializes values from a serialized string.
*/
export function unserialize(serialized: string, options?: { allowedClasses?: boolean | string[], throwOnInvalidClass?: boolean }): any;
/**
* Escapes a regex pattern.
*/
export function regex_quote(str: string): string;
/**
* Calculates a CRC32 of a string.
*/
export function crc32(stringOrBuffer: string|Buffer): number;
/**
* Escapes a shell argument.
*/
export function escapeshellarg(arg: string): string;
/**
* Encodes a string with html entities.
*/
export function htmlentities (string: string, quoteStyle?: 'ENT_COMPAT' | 'ENT_NOQUOTES' | 'ENT_QUOTES', doubleEncode?: string): string
/**
* Calculates the levenshtein distance between two strings.
*/
export function levenshtein(s: string, t: string): number;
/**
* Converts unicode domains to ascii.
*/
export function punycode_to_ascii(string: string): string;
/**
* @internal
*/
export function internal_parse_query_string(params: any): any;
/**
* Parses a query string and returns a kv object.
*/
export function parse_query_string(str: string): Record;
/**
* Formats values into a string.
*/
export function sprintf(format: string, ...args: any[]): string;
export const STR_PAD_RIGHT = 'STR_PAD_RIGHT';
export const STR_PAD_LEFT = 'STR_PAD_LEFT';
export const STR_PAD_BOTH = 'STR_PAD_BOTH';
/**
* Pad a string to a certain length with another string.
*/
export function str_pad(string: string, length?: number, pad?: string, padType?: 'STR_PAD_RIGHT' | 'STR_PAD_LEFT' | 'STR_PAD_BOTH'): string;
/**
* The strcspn() function returns the number of characters (including whitespaces)
* found in a string before any part of the specified characters are found.
*/
export function strcspn(str: string, mask: string, start?: number, length?: number): number;
/**
* Strips HTML tags from a string.
*/
export function strip_tags(input: string, allowed?: string): string;
/**
* Replaces parts of strings.
*/
export function strtr(str: string, replacePairs: Record): string;
export function strtr(str: string, from: string, to: string): string;
/**
* Replace text within a portion of a string.
*/
export function substr_replace(search: string, replacement: string, start: number, length?: number): string;
export function substr_replace(search: string[], replacement: string[], start: number[], length?: number[]): string[];
/**
* Trim characters at the end of a string.
*/
export function rtrim(str: string, charList?: string): string;
/**
* Trim characters at the beginning of a string.
*/
export function ltrim(str: string, charList?: string): string;
/**
* Trim characters at the beginning and at the end of a string.
*/
export function trim(str: string, charList?: string): string;
/**
* Make the first character upper-case and the rest lower-case.
*/
export function ucfirst(str: string): string;
/**
* Make the first character of each word upper-case and the rest lower-case.
*/
export function ucwords(str: string): string;
/**
* If operator parameter is undefined returns -1 if version1 is
* lower than version2, 0 if they are equal, 1 if the second is lower
*
* Otherwise, returns true if the relationship is the one specified
* by the operator, false otherwise
*/
export function version_compare(version1: string|number, version2: string|number): number;
export function version_compare(version1: string|number, version2: string|number, operator: '<'|'lt'|'<='|'le'|'>'|'gt'|'>='|'ge'|'=='|'='|'eq'|'!='|'<>'|'ne'): boolean;
/**
* Wraps a string to a given number of characters.
*/
export function wordwrap(str: string, width?: number, strBreak?: string, cut?: boolean): string;
}
interface WeakRef {
readonly [Symbol.toStringTag]: "WeakRef";
/**
* Returns the WeakRef instance's target value, or undefined if the target value has been
* reclaimed.
* In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
*/
deref(): T | undefined;
}
interface WeakRefConstructor {
readonly prototype: WeakRef;
/**
* Creates a WeakRef instance for the given target object.
* @param target The target object for the WeakRef instance.
*/
new(target?: T): WeakRef;
}
declare var WeakRef: WeakRefConstructor;
declare type Nullable = {
[P in keyof T]: null | T[P];
};
declare type FunctionPropertyNames = {
[K in keyof T]: T[K] extends Function ? K : never;
}[keyof T];
declare type FunctionProperties = Pick>;
declare type NonFunctionPropertyNames = {
[K in keyof T]: T[K] extends Function ? never : K;
}[keyof T];
declare type NonFunctionProperties = Pick>;
type IfEquals =
(() => T extends X ? 1 : 2) extends (() => T extends Y ? 1 : 2) ? A : B;
declare type WritableKeys = {
[P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P>
}[keyof T];
declare type ReadonlyKeys = {
[P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, never, P>
}[keyof T];
type SuppressNew = {
[ K in keyof T ] : T[ K ]
}
declare type AnyConstructorRaw = (new (...input : any[]) => Instance) & Static;
declare type Newable = (new (...input : any[]) => Instance) & SuppressNew;
declare type MixinInterface = T extends AnyConstructorRaw ? Omit & {
readonly definition: Newable;
[Symbol.hasInstance](): boolean;
} & ((...args: any[]) => any) : never;
type ArrayIntersection = T extends [infer Head, ...infer Rest] ?
Head & ArrayIntersection : unknown;
declare type Mixin = T extends Newable ? MixinInterface : never;
declare type ClassRaw = SuppressNew & {
prototype: Instance;
};
declare type ClassArrayIntersection = T extends [infer Base extends ClassRaw, ...infer Rest] ?
ClassRaw & ClassArrayIntersection : unknown;
declare function getInterface(definition: T, ...parents: [...P]): T extends Newable ? MixinInterface> : never;
declare function getTrait(definition: T): Mixin;
declare function mix(base: CBase, ...interfaces: [...TParams]):
CBase extends ClassRaw ?
Newable & ClassArrayIntersection : never;
declare function implementationOf(...interfaces: [...TParams]): ArrayIntersection & typeof __jymfony.JObject & any;
declare type AsyncFunction = (...args: any[]) => Promise;
interface AsyncGenerator extends AsyncIteratorObject {
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
next(...[value]: [] | [TNext]): Promise>;
return(value: TReturn | PromiseLike): Promise>;
throw(e: any): Promise>;
[Symbol.asyncIterator](): AsyncGenerator;
}
interface AsyncGeneratorFunction {
/**
* Creates a new AsyncGenerator object.
* @param args A list of arguments the function accepts.
*/
new (...args: any[]): AsyncGenerator;
/**
* Creates a new AsyncGenerator object.
* @param args A list of arguments the function accepts.
*/
(...args: any[]): AsyncGenerator;
/**
* The length of the arguments.
*/
readonly length: number;
/**
* Returns the name of the function.
*/
readonly name: string;
/**
* A reference to the prototype.
*/
readonly prototype: AsyncGenerator;
}
declare module NodeJS {
interface Global {
__jymfony: any;
BoundFunction: Newable>;
EmptyIterator: Newable;
RecursiveDirectoryIterator: Newable;
getInterface(definition: T, ...parents: [...P]): T extends Newable ? MixinInterface> : never;
getTrait(definition: T): T extends Newable ? MixinInterface : never;
mixins: {
isInterface: >(mixin: T) => boolean,
isTrait: >(mixin: T) => boolean,
getParents: (Class: T) => MixinInterface[],
getInterfaces: (Class: T) => MixinInterface[],
getTraits: (Class: T) => MixinInterface[],
/**
* @internal
*/
initializerSymbol: symbol
}
mix(base: CBase, ...interfaces: [...TParams]):
CBase extends ClassRaw ?
Newable & ClassArrayIntersection : never;
implementationOf(...interfaces: [...TParams]): ArrayIntersection & typeof __jymfony.JObject & any;
isArguments(value: any): value is IArguments;
isBigInt(value: any): value is bigint;
isBoolean(value: any): value is boolean;
isString(value: any): value is string;
isNumber(value: any): value is number;
isInfinite(value: T): T extends number ? boolean : false;
isNumeric(value: T): T extends number ? true : boolean;
isDate(value: any): value is Date;
isRegExp(value: any): value is RegExp;
isError(value: any): value is Error;
isSymbol(value: any): value is symbol;
isMap(value: any): value is Map;
isWeakMap(value: any): value is WeakMap;
isSet(value: any): value is Set;
isWeakSet(value: any): value is WeakSet;
isGenerator(value: any): value is Generator;
isGeneratorFunction(value: any): value is GeneratorFunction | AsyncGeneratorFunction;
isAsyncFunction(value: any): value is AsyncFunction;
isFunction(value: any): value is Invokable;
isArray(value: any): value is Array;
isArray(value: any): value is Array;
isBuffer(value: any): value is Buffer;
isObject(value: any): value is object;
isScalar(value: any): value is string | boolean | number;
isObjectLiteral(value: any): value is Object;
isPromise(value: any): value is Promise;
isStream(value: any): value is NodeJS.ReadableStream | NodeJS.WritableStream;
isCallableArray(value: any): value is [string, string];
getCallableFromArray(value: [object, string]): Invokable;
}
}
declare type Invokable = (...args: any[]) => T | {
__invoke(...args: [...A]): (...args: [...A]) => T;
};
declare function isArguments(value: any): value is IArguments;
declare function isBigInt(value: any): value is bigint;
declare function isBoolean(value: any): value is boolean;
declare function isString(value: any): value is string;
declare function isNumber(value: any): value is number;
declare function isNaN(value: T): T extends number ? boolean : false;
declare function isInfinite(value: T): T extends number ? boolean : false;
declare function isNumeric(value: T): T extends number ? true : boolean;
declare function isDate(value: any): value is Date;
declare function isRegExp(value: any): value is RegExp;
declare function isError(value: any): value is Error;
declare function isSymbol(value: any): value is symbol;
declare function isMap(value: any): value is Map;
declare function isWeakMap(value: any): value is WeakMap;
declare function isSet(value: any): value is Set;
declare function isWeakSet(value: any): value is WeakSet;
declare function isGenerator(value: any): value is Generator;
declare function isGeneratorFunction(value: any): value is GeneratorFunction | AsyncGeneratorFunction;
declare function isAsyncFunction(value: any): value is AsyncFunction;
declare function isFunction(value: any): value is Invokable;
declare function isArray(value: any): value is Array;
declare function isBuffer(value: any): value is Buffer;
declare function isObject(value: any): value is object;
declare function isScalar(value: any): value is string | boolean | number;
declare function isObjectLiteral(value: any): value is Object;
declare function isPromise(value: any): value is Promise;
declare function isStream(value: any): value is NodeJS.ReadableStream | NodeJS.WritableStream;
declare function isCallableArray(value: any): value is [string, string];
declare function getCallableFromArray(value: [object, string]): Invokable;
declare interface BoundFunction extends Function {
new(thisArg: Object, func: Invokable): Invokable;
new(thisArg: Object, func: string|symbol): Invokable;
arguments: any;
caller: Function;
readonly length: number;
readonly name: string;
prototype: any;
[Symbol.hasInstance](value: any): boolean;
apply(thisArg: any, argArray?: P): T;
bind(thisArg: any, ...argArray: [...P]): this;
call(thisArg: any, ...argArray: [...P]): T;
}
declare class EmptyIterator implements Iterable {
[Symbol.iterator](): Iterator;
}
interface ObjectConstructor {
filter: (obj: T, predicate: Invokable) => T;
ksort: (obj: T) => T;
sort: (obj: T) => T;
}
declare class RecursiveDirectoryIterator implements Iterator, Iterable {
private _path: string;
private _dir: undefined|string[];
private _current: undefined|string;
/**
* Constructor.
*/
__construct(filepath: string): void;
constructor(filepath: string);
/**
* Make this object iterable.
*/
[Symbol.iterator](): RecursiveDirectoryIterator;
/**
* Iterates over values.
*/
next(): IteratorResult;
}