import type { BinaryOperator, CallExpression, UnaryOperator } from 'estree'; import type { Chapter } from '../langs'; import type { NativeStorage } from '../types'; import { HasCorrectParameters } from './typeUtils'; export declare function throwIfTimeout(nativeStorage: NativeStorage, start: number, current: number, line: number, column: number, source: string | null): void; export declare function boolOrErr(candidate: any, line: number, column: number, source: string | null): candidate is true; export declare function unaryOp(operator: UnaryOperator, argument: any, line: number, column: number, source: string | null): number | boolean | "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"; export declare function evaluateUnaryExpression(operator: UnaryOperator, value: any): number | boolean | "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"; export declare function binaryOp(operator: BinaryOperator, chapter: Chapter, left: any, right: any, line: number, column: number, source: string | null): any; export declare function evaluateBinaryExpression(operator: BinaryOperator, left: any, right: any): any; /** * Check that the number of arguments provided falls within the range specified. * * You can call it with just a {@link CallExpression}, in which case its `callee` should be either a * {@link FunctionExpression} or {@link ArrowFunctionExpression}. * * Otherwise, the node is just used for location information and you have to manually specify * everything else. * * - If `maxArgs` is true, then there is no maximum number of arguments. Useful for functions * with a rest parameter. * - If `maxArgs` is a number, then that value is the maximum number of arguments. * - If `maxArgs` is `undefined` or not provided, then the maximum number of arguments is assumed * to be `minArgs`. */ export declare function validateFunctionArgCount(exp: CallExpression): void; export declare function validateFunctionArgCount(exp: CallExpression, received: number, minArgs: number, maxArgs?: number | true, funcName?: string): void; /** * Calls the provided value as if it were a function being called from the `line` and `column` * within the provided `source` file, checking for argument count. * * - If `nativeStorage` is provided, then infinite recursion protection is also added. */ export declare function callIfFuncAndRightArgs(f: unknown, line: number, column: number, source: string | null, nativeStorage: NativeStorage | undefined, ...args: any[]): any; /** * Convenience wrapper for {@link callIfFuncAndRightArgs} that doesn't require any * extra metadata to be passed into the function. */ export declare function callWithoutMetadata any>(f: T, ...args: Parameters): ReturnType; /** * Augment the given function with the necessary information for it to be called * properly by {@link callIfFuncAndRightArgs}. It won't redefine any existing details * that the function has already been wrapped with. * * @example * ```ts * export const wrapped = wrap((...args: any[]) => args.length, true, 'wrapped'); * ``` * * - `optArgCount`: Represents the number of optional arguments the function has * - If set to `undefined`, it will be assumed to be 0 * - If set to a number, that will be taken to be the number of optional arguments * - If set to `true`, the function is assumed to have a rest argument * * - If `stringified` is `undefined`, the function won't try to define `toReplString`. * - `funcName` * - If `funcName` is `undefined`, the function won't try to define the `name` property. * - If `funcName` is provided, the `name` property will get overriden. */ export declare function wrap any, OptArgs extends number>(f: HasCorrectParameters, optArgCount: OptArgs, funcName?: string, stringified?: string, source?: string | null): T; export declare function wrap any>(f: HasCorrectParameters, optArgCount: true, funcName?: string, stringified?: string, source?: string | null): T; export declare function wrap any>(f: HasCorrectParameters, optArgCount?: undefined, funcName?: string, stringified?: string, source?: string | null): T; /** * A type-agnostic version of {@link wrap} to make it easier * when the function type is not known. */ export declare function wrapUnsafe any>(f: T, optArgCount?: number | true, funcName?: string, stringified?: string, source?: string | null): T; export declare function setProp(obj: any, prop: any, value: any, line: number, column: number, source: string | null): any; export declare function getProp(obj: any, prop: any, line: number, column: number, source: string | null): any;