Namespaces
Utils
Summary
References
Functions
- clearInterval
- clearTimeout
- convertString
- copyToClipboard
- dataDeserialize
- dataSerialize
- debounce
- dismissKeyboard
- dismissSoftInput
- dispatchToMainThread
- dispatchToUIThread
- eliminateDuplicates
- escapeRegexSymbols
- executeOnMainThread
- executeOnUIThread
- GC
- getBaseClasses
- getClass
- getClassInfo
- getDurationWithDampingFromSpring
- getFileExtension
- getModuleName
- hasDuplicates
- isBoolean
- isDataURI
- isDefined
- isEmoji
- isFileOrResourcePath
- isFontIconURI
- isFunction
- isMainThread
- isNullOrUndefined
- isNumber
- isObject
- isRealDevice
- isString
- isUndefined
- mainThreadify
- merge
- mergeSort
- numberHasDecimals
- numberIs64Bit
- openFile
- openUrl
- queueGC
- queueMacrotask
- releaseNativeObject
- sanitizeModuleName
- setInterval
- setTimeout
- throttle
- toUIString
- verifyCallback
References
Variables
CORE_ANIMATION_DEFAULTS
defined in @nativescript/core/utils/common.d.ts:37:21
Default animation values used throughout core
FILE_PREFIX
defined in @nativescript/core/utils/index.d.ts:12:13
RESOURCE_PREFIX
defined in @nativescript/core/utils/index.d.ts:11:13
SDK_VERSION
defined in @nativescript/core/utils/constants.d.ts:1:13
debug
defined in @nativescript/core/utils/debug.d.ts:4:11
A runtime option indicating whether the build has debugging enabled.
Functions
GC
defined in @nativescript/core/utils/index.d.ts:27
An utility function that invokes garbage collection on the JavaScript side.
Returns any
clearInterval
defined in @nativescript/core/timer/index.d.ts:27
Clears repeated function which was set up by calling setInterval().
Parameter | Default | Description |
id |
| number The identifier returned by the setInterval() method. |
Returns void
clearTimeout
defined in @nativescript/core/timer/index.d.ts:13
Clears the delay set by a call to the setTimeout function.
Parameter | Default | Description |
id |
| number The identifier returned by the previously called setTimeout() method. |
Returns void
convertString
defined in @nativescript/core/utils/index.d.ts:132
Converts string value to number or boolean.
Parameter | Default | Description |
value |
| any The original value. |
Returns any
copyToClipboard
defined in @nativescript/core/utils/index.d.ts:177
Copy value to device clipboard.
Parameter | Default | Description |
value |
| string |
Returns void
dataDeserialize
Data deserialization from Native > JS
Parameter | Default | Description |
nativeData |
| any Native platform data |
Returns any
dataSerialize
Data serialization from JS > Native
Parameter | Default | Description |
data |
| any |
wrapPrimitives |
| boolean Optionally wrap primitive types (Some APIs may require this) |
Returns any
debounce
defined in @nativescript/core/utils/index.d.ts:48
A simple debounce utility
Parameter | Default | Description |
fn |
| any Function to debounce |
delay |
| number Customize the delay (default is 300ms) |
Returns any
dismissKeyboard
defined in @nativescript/core/utils/index.d.ts:172
Dismiss any keyboard visible on the screen.
Returns void
dismissSoftInput
defined in @nativescript/core/utils/index.d.ts:167
Hides the soft input method, usually a soft keyboard.
Parameter | Default | Description |
nativeView |
| any |
Returns void
dispatchToMainThread
Dispatches the passed function for execution on the main thread
Parameter | Default | Description |
func |
| Function The function to execute on the main thread. |
Returns any
dispatchToUIThread
Dispatches the passed function for execution on the UI thread
Parameter | Default | Description |
func |
| Function The function to execute on the UI thread. |
Returns any
eliminateDuplicates
defined in @nativescript/core/utils/index.d.ts:157
Removes duplicate elements from array.
Parameter | Default | Description |
arr |
| any[] The array. |
Returns any[]
escapeRegexSymbols
defined in @nativescript/core/utils/index.d.ts:126
Escapes special regex symbols (., *, ^, $ and so on) in string in order to create a valid regex from it.
Parameter | Default | Description |
source |
| string The original value. |
Returns string
executeOnMainThread
defined in @nativescript/core/utils/index.d.ts:67
Checks if the current thread is the main thread. Directly calls the passed function
if it is, or dispatches it to the main thread otherwise.
Parameter | Default | Description |
func |
| Function The function to execute on the main thread. |
Returns any
executeOnUIThread
defined in @nativescript/core/utils/index.d.ts:73
Runs the passed function on the UI Thread.
Parameter | Default | Description |
func |
| Function The function to execute on the UI thread. |
Returns any
getBaseClasses
defined in @nativescript/core/utils/types.d.ts:88
A function that gets the entire class hierarchy of an object.
Parameter | Default | Description |
object |
| any The object.
Returns an array of strings with the name of all base classes. |
Returns string[]
getClass
defined in @nativescript/core/utils/types.d.ts:81
A function that gets the class name of an object.
Parameter | Default | Description |
object |
| any The object.
Returns a string with the name of the class. |
Returns string
getClassInfo
getClassInfo(object: Object): ClassInfo
defined in @nativescript/core/utils/types.d.ts:95
A function that gets the ClassInfo for an object.
Parameter | Default | Description |
object |
| Object The object.
Returns a ClassInfo for the object. |
Returns ClassInfo
getDurationWithDampingFromSpring
getDurationWithDampingFromSpring(springSettings?: {
friction?: number
mass?: number
tension?: number
}): {
damping: number
}
defined in @nativescript/core/utils/common.d.ts:52
Get a duration with damping value from various spring related settings.
Helpful when needing to convert spring settings to isolated duration value.
Parameter | Default | Description |
springSettings |
| {
friction?: number
mass?: number
tension?: number
} various spring settings |
Returns {
damping: number
}
getFileExtension
defined in @nativescript/core/utils/index.d.ts:101
Get file extension from file path
Parameter | Default | Description |
path |
| string file path |
Returns string
getModuleName
defined in @nativescript/core/utils/index.d.ts:138
Gets module name from path.
Parameter | Default | Description |
path |
| string The module path. |
Returns string
hasDuplicates
defined in @nativescript/core/utils/index.d.ts:151
Checks if array has any duplicate elements.
Parameter | Default | Description |
arr |
| any[] The array to be checked. |
Returns boolean
isBoolean
defined in @nativescript/core/utils/types.d.ts:20
A function that checks if something is a valid boolean.
Parameter | Default | Description |
value |
| any The value which will be checked.
Returns true if value is a boolean. |
Returns boolean
isDataURI
defined in @nativescript/core/utils/index.d.ts:107
Returns true if the specified URI is data URI (http://en.wikipedia.org/wiki/Data_URI_scheme).
Parameter | Default | Description |
uri |
| string The URI. |
Returns boolean
isDefined
defined in @nativescript/core/utils/types.d.ts:48
A function that checks if something is defined (not undefined).
Parameter | Default | Description |
value |
| any The value which will be checked.
Returns true if value is defined. |
Returns boolean
isEmoji
defined in @nativescript/core/utils/common.d.ts:33
Parameter | Default | Description |
value |
| string |
Returns boolean
isFileOrResourcePath
defined in @nativescript/core/utils/index.d.ts:94
Returns true if the specified path points to a resource or local file.
Parameter | Default | Description |
path |
| string The path. |
Returns boolean
isFontIconURI
defined in @nativescript/core/utils/index.d.ts:88
Returns true if the specified URI is a font icon URI like "fontIcon://".
Parameter | Default | Description |
uri |
| string The URI. |
Returns boolean
isFunction
defined in @nativescript/core/utils/types.d.ts:27
A function that checks if something is a function.
Parameter | Default | Description |
value |
| any The value which will be checked.
Returns true if value is a function. |
Returns boolean
isMainThread
Returns boolean
isNullOrUndefined
defined in @nativescript/core/utils/types.d.ts:55
A function that checks if something is not defined (null or undefined).
Parameter | Default | Description |
value |
| any The value which will be checked.
Returns true if value is null or undefined. |
Returns boolean
isNumber
defined in @nativescript/core/utils/types.d.ts:13
A function that checks if something is a valid number.
Parameter | Default | Description |
value |
| any The value which will be checked.
Returns true if value is a number. |
Returns boolean
isObject
defined in @nativescript/core/utils/types.d.ts:34
A function that checks if something is an object.
Parameter | Default | Description |
value |
| any The value which will be checked.
Returns true if value is an object. |
Returns boolean
isRealDevice
defined in @nativescript/core/utils/index.d.ts:162
Checks whether the application is running on real device and not on simulator/emulator.
Returns boolean
isString
defined in @nativescript/core/utils/types.d.ts:6
A function that checks if something is a valid string.
Parameter | Default | Description |
value |
| any The value which will be checked.
Returns true if value is a string. |
Returns boolean
isUndefined
defined in @nativescript/core/utils/types.d.ts:41
A function that checks if something is "undefined".
Parameter | Default | Description |
value |
| any The value which will be checked.
Returns true if value is "undefined". |
Returns boolean
mainThreadify
defined in @nativescript/core/utils/index.d.ts:82
Returns a function wrapper which executes the supplied function on the main thread.
The wrapper behaves like the original function and passes all of its arguments BUT
discards its return value.
Parameter | Default | Description |
func |
| Function The function to execute on the main thread |
Returns (...args: any[]) => void
merge
defined in @nativescript/core/utils/common.d.ts:24
Parameter | Default | Description |
left |
| any |
right |
| any |
compareFunc |
| any |
Returns any[]
mergeSort
defined in @nativescript/core/utils/index.d.ts:145
Sorts an array by using merge sort algorithm (which ensures stable sort since the built-in Array.sort() does not promise a stable sort).
Parameter | Default | Description |
arr |
| any[] array to be sorted |
compareFunc |
| (a: any, b: any) => number function that will be used to compare two elements of the array |
Returns any[]
numberHasDecimals
defined in @nativescript/core/utils/types.d.ts:68
Checks if the number has decimals
Parameter | Default | Description |
value |
| number Number to check |
Returns boolean
numberIs64Bit
defined in @nativescript/core/utils/types.d.ts:74
Checks if the number is 64 bit
Parameter | Default | Description |
value |
| number Number to check |
Returns boolean
openFile
defined in @nativescript/core/utils/index.d.ts:120
Opens file.
Parameter | Default | Description |
filePath |
| string The file. |
title |
| string Optional title for Android. Default is: 'Open File...' |
Returns boolean
openUrl
defined in @nativescript/core/utils/index.d.ts:113
Opens url.
Parameter | Default | Description |
url |
| string The url. |
Returns boolean
queueGC
defined in @nativescript/core/utils/index.d.ts:34
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.
Parameter | Default | Description |
delay |
| number Customize the delay |
useThrottle |
| boolean Instead of default debounce strategy, use throttling |
Returns any
queueMacrotask
defined in @nativescript/core/utils/index.d.ts:60
Queues the passed function to be ran in a macroTask
Parameter | Default | Description |
task |
| () => void the function to execute as a macroTask |
Returns void
releaseNativeObject
defined in @nativescript/core/utils/index.d.ts:54
Releases the reference to the wrapped native object
Parameter | Default | Description |
object |
| any The Java/Objective-C object to release. |
Returns any
sanitizeModuleName
defined in @nativescript/core/utils/common.d.ts:13
Helps sanitize a module name if it is prefixed with '~/', '~' or '/'
Parameter | Default | Description |
moduleName |
| string the name |
removeExtension |
| boolean whether to remove extension |
Returns string
setInterval
defined in @nativescript/core/timer/index.d.ts:21
Calls a function repeatedly with a delay between each call.
Parameter | Default | Description |
callback |
| Function The function to be called. |
milliseconds |
| number The delay between each function call. |
args |
| any[] One or more parameter to use once the function is called. Defaults to no parameters. |
Returns number
setTimeout
defined in @nativescript/core/timer/index.d.ts:7
Calls a function after a specified delay.
Parameter | Default | Description |
callback |
| Function The function to be called. |
milliseconds |
| number The time to wait before the function is called. Defaults to 0. |
args |
| any[] One or more parameter to use once the function is called. Defaults to no parameters. |
Returns number
throttle
defined in @nativescript/core/utils/index.d.ts:41
A simple throttle utility
Parameter | Default | Description |
fn |
| any Function to throttle |
delay |
| number Customize the delay (default is 300ms) |
Returns any
toUIString
defined in @nativescript/core/utils/types.d.ts:116
Returns a string representation of an object to be shown in UI.
Parameter | Default | Description |
object |
| any The object. |
Returns string
verifyCallback
defined in @nativescript/core/utils/types.d.ts:62
A function that checks if something is a valid function.
Parameter | Default | Description |
value |
| any The value which will be checked.
Throws exception if passed value is not a valid function. |
Returns void
- Previous
- Trace
- Next
- capitalizationType