UNPKG

5.23 kBTypeScriptView Raw
1export { clearInterval, clearTimeout, setInterval, setTimeout } from '../timer';
2export * from './common';
3export * from './constants';
4export * from './debug';
5export * from './layout-helper';
6export * from './macrotask-scheduler';
7export * from './mainthread-helper';
8export * from './native-helper';
9export * from './types';
10
11export const RESOURCE_PREFIX: string;
12export const FILE_PREFIX: string;
13
14//@private
15/**
16 * Used by various android event listener implementations.
17 * @private
18 */
19interface Owned {
20 owner: any;
21}
22//@endprivate
23
24/**
25 * An utility function that invokes garbage collection on the JavaScript side.
26 */
27export function GC();
28
29/**
30 * An utility function that queues a garbage collection, multiple calls in quick succession are debounced by default and only one gc will be executed after 900ms.
31 * @param delay Customize the delay
32 * @param useThrottle Instead of default debounce strategy, use throttling
33 */
34export function queueGC(delay?: number, useThrottle?: boolean);
35
36/**
37 * A simple throttle utility
38 * @param fn Function to throttle
39 * @param delay Customize the delay (default is 300ms)
40 */
41export function throttle<T extends Function = any>(fn: T, delay?: number): T;
42
43/**
44 * A simple debounce utility
45 * @param fn Function to debounce
46 * @param delay Customize the delay (default is 300ms)
47 */
48export function debounce<T extends Function = any>(fn: T, delay?: number, options?: { leading?: boolean }): T;
49
50/**
51 * Releases the reference to the wrapped native object
52 * @param object The Java/Objective-C object to release.
53 */
54export function releaseNativeObject(object: any /*java.lang.Object | NSObject*/);
55
56/**
57 * Queues the passed function to be ran in a macroTask
58 * @param task the function to execute as a macroTask
59 */
60export function queueMacrotask(task: () => void): void;
61
62/**
63 * Checks if the current thread is the main thread. Directly calls the passed function
64 * if it is, or dispatches it to the main thread otherwise.
65 * @param func The function to execute on the main thread.
66 */
67export function executeOnMainThread(func: Function);
68
69/**
70 * Runs the passed function on the UI Thread.
71 * @param func The function to execute on the UI thread.
72 */
73export function executeOnUIThread(func: Function);
74
75/**
76 * Returns a function wrapper which executes the supplied function on the main thread.
77 * The wrapper behaves like the original function and passes all of its arguments BUT
78 * discards its return value.
79 * @param func The function to execute on the main thread
80 * @returns The wrapper function which schedules execution to the main thread
81 */
82export function mainThreadify(func: Function): (...args: any[]) => void;
83
84/**
85 * Returns true if the specified URI is a font icon URI like "fontIcon://&#xf1e0".
86 * @param uri The URI.
87 */
88export function isFontIconURI(uri: string): boolean;
89
90/**
91 * Returns true if the specified path points to a resource or local file.
92 * @param path The path.
93 */
94export function isFileOrResourcePath(path: string): boolean;
95
96/**
97 * Get file extension from file path
98 * @param path file path
99 * @returns file extension
100 */
101export function getFileExtension(path: string): string;
102
103/**
104 * Returns true if the specified URI is data URI (http://en.wikipedia.org/wiki/Data_URI_scheme).
105 * @param uri The URI.
106 */
107export function isDataURI(uri: string): boolean;
108
109/**
110 * Opens url.
111 * @param url The url.
112 */
113export function openUrl(url: string): boolean;
114
115/**
116 * Opens file.
117 * @param filePath The file.
118 * @param title Optional title for Android. Default is: 'Open File...'
119 */
120export function openFile(filePath: string, title?: string): boolean;
121
122/**
123 * Escapes special regex symbols (., *, ^, $ and so on) in string in order to create a valid regex from it.
124 * @param source The original value.
125 */
126export function escapeRegexSymbols(source: string): string;
127
128/**
129 * Converts string value to number or boolean.
130 * @param value The original value.
131 */
132export function convertString(value: any): any;
133
134/**
135 * Gets module name from path.
136 * @param path The module path.
137 */
138export function getModuleName(path: string): string;
139
140/**
141 * Sorts an array by using merge sort algorithm (which ensures stable sort since the built-in Array.sort() does not promise a stable sort).
142 * @param arr - array to be sorted
143 * @param compareFunc - function that will be used to compare two elements of the array
144 */
145export function mergeSort(arr: Array<any>, compareFunc: (a: any, b: any) => number): Array<any>;
146
147/**
148 * Checks if array has any duplicate elements.
149 * @param arr - The array to be checked.
150 */
151export function hasDuplicates(arr: Array<any>): boolean;
152
153/**
154 * Removes duplicate elements from array.
155 * @param arr - The array.
156 */
157export function eliminateDuplicates(arr: Array<any>): Array<any>;
158
159/**
160 * Checks whether the application is running on real device and not on simulator/emulator.
161 */
162export function isRealDevice(): boolean;
163
164/**
165 * Hides the soft input method, usually a soft keyboard.
166 */
167export function dismissSoftInput(nativeView?: any): void;
168
169/**
170 * Dismiss any keyboard visible on the screen.
171 */
172export function dismissKeyboard(): void;
173
174/**
175 * Copy value to device clipboard.
176 */
177export function copyToClipboard(value: string): void;