@specs-feup/lara
Version:
A js port of the popular framework for building source-to-source compilers
146 lines • 6.61 kB
TypeScript
import { LaraJoinPoint } from "../../LaraJoinPoint.js";
export declare let LARA_DEBUG: boolean;
export declare function setDebug(value?: boolean): void;
export declare function isDebug(): boolean;
export declare function notImplemented(functionName?: string): void;
/**
* Returns the value if defined or the provided default value. This useful for optional parameters of functions.
*
* @param value - the original value
* @param defaultValue - the default value
*
* @deprecated Use the ECMAScript 6 default parameter value syntax instead
*/
export declare function defaultValue<T1, T2>(value: T1, defaultValue: T2): T2 | NonNullable<T1>;
/**
* Temporary method that returns true if the given value is undefined or null,
* to be used while WeaverGenerator does not support returning undefined from Java.
*
* @deprecated Use the javascript `===` operator instead
*/
export declare function isUndefined<T>(value: T): boolean;
/**
* Throws an exception if the given expression evaluates to false.
*
* @deprecated Use the javascript `throw` statement instead
*/
export declare function checkTrue(booleanExpr: boolean, message?: string, source?: string): void;
/**
* @deprecated Use the javascript '===' operator instead
*/
export declare function checkDefined<T>(value: T, varName?: string, source?: string): void;
/**
* @deprecated Use the javascript `instanceof` operator or JavaTypes.instanceOf instead
*/
export declare function checkInstance(value: any, type: any, source?: string, userTypeName?: string): void;
export declare function checkType<T>(value: T, type: string, source?: string): void;
/**
* @deprecated Use the javascript `instanceof` operator instead
*/
export declare function checkBoolean<T>(variable: T, source: string): void;
/**
* @deprecated Use the javascript `instanceof` operator instead
*/
export declare function checkString<T>(variable: T, source?: string | undefined): void;
/**
* @deprecated Use the javascript `instanceof` operator instead
*/
export declare function checkNumber<T>(variable: T, source: string): void;
/**
* @deprecated Use the javascript `instanceof` operator instead
*/
export declare function checkArray<T>(variable: T, source: string): void;
/**
* @returns true if the given value is an array, false otherwise
*
* @deprecated Use the javascript `instanceof` operator instead
*/
export declare function isArray<T>(value: T): value is T & any[];
/**
* @deprecated Use the javascript built-in methods instead
*/
export declare function toArray(objectWithLength: any): any[];
/**
* @deprecated Use the javascript `instanceof` operator instead
*/
export declare function isString<T>(variable: T): variable is (T & string) | (T & String);
/**
* @returns true if the given object is an instance of the given Java class name
*
* @deprecated Use JavaTypes.isJavaObject or JavaTypes.instanceOf instead
*/
export declare function isJavaClass<T>(variable: T, javaClassname?: string): boolean;
/**
* Converts an arguments object to a JavaScript array (Array).
*
* If there is a single argument after the start index and that argument is an array, that array will be returned.
* This helper is kept for Lara code using directly the `arguments` object. If you are using Javascript, consider using [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters](rest parameters) to extract the variadic arguments of your function, and using the `flattenArgsArray` function to perform the single-element flattening, if needed.
*
* @param args - The original arguments object.
* @param start - The index where we begin the conversion (inclusive).
* */
export declare function arrayFromArgs(args: any, start?: number): any;
export declare function info(message: string, origin?: string): void;
/**
* @deprecated Use the javascript `instanceof` operator instead
*/
export declare function isJoinPoint($jp: any, type?: string): boolean;
/**
* @deprecated Use the javascript `instanceof` operator instead
*/
export declare function checkJoinPoint($jp: any, source?: string): void;
/**
* @deprecated Use the javascript `instanceof` operator instead
*/
export declare function checkJoinPointType($jp: LaraJoinPoint, type: string, source?: string): void;
/**
* @deprecated Use the javascript `instanceof` operator instead
*/
export declare function isObject<T>(variable: T): variable is (T & object) | (T & null);
/**
* @deprecated Use the javascript `instanceof` operator instead
*/
export declare function isFunction<T>(variable: T): variable is T & Function;
/**
* @param message - The message to print. Accepts functions, that are only evaluated if debug information is enabled. Use functions if the debug message can include expensive processing.
*/
export declare function debug(message: string | (() => string), origin?: string): void;
export declare function debugObject<T>(object: T, origin?: string): void;
/**
* Flatten an Arguments array. In this context, it means that if the array only contains one element,
* and that element is an Array, it will be returned instead of the outer Array.
*
* @param args - Arguments array. Must be some array-like object.
* @returns Flattened argument array
*
* This method had been deprecated with the following justification, however, Node.JS is not handling
* well calling Java functions with variadic arguments, so this is still necessary.
*
* "This is implemented for compatibility reasons. As the Lara language used ES5 as its
* base, there was no spread operator to pass argument arrays to variadic functions, so there
* is calling code expecting to be able to pass a single array as the variadic argument."
*/
export declare function flattenArgsArray(args: any[]): any[];
export declare function laraGetter(object: any, property: string): any;
/**
* @returns an array with the keys of an object
*
* @deprecated Use the javascript built-in methods instead
*/
export declare function getKeys<T>(object: T): Extract<keyof T, string>[];
/**
* @returns an array with the values of an object
*
* @deprecated Use the javascript built-in methods instead
*/
export declare function getValues<T>(object: T): T[Extract<keyof T, string>][];
/**
* Acts as a constructor where you can pass the arguments object.
*
* @returns the constructed object, of the constructor if it could not be built.
*
* @deprecated Use the javascript built-in methods instead
*/
export declare function newObject(aClass: any, args?: any[]): any;
export declare function laraImport(importName: string): void;
//# sourceMappingURL=LaraCore.d.ts.map