The Utils class contains various useful utility functions. More...
The T/HIS JavaScript API provides many class constants, properties and methods. For Arup to
be able to extend and enhance the API in the future any constant, property or method names beginning with a lowercase
or uppercase letter are reserved.
If you need to add your own properties or methods to one of the existing classes then to avoid any potential future conflict you
should ensure that the name begins with either an underscore (_) or a dollar sign ($) or the name is prefixed with your
own unique identifier.
For example if company 'ABC' need to add a property called 'example' then to avoid any potential future conflict use one of:
Detailed DescriptionThe Utils class is used to provide various useful functions. |
Details of functionsAscii85Decode(encoded[string]) [static]DescriptionDecodes an ASCII85 encoded string. See Utils.Ascii85Encode() for details on the method. |
An ASCII85 encoded string
ReturnsArrayBuffer object Return typeArrayBuffer |
ExampleTo decode an ASCII85 encoded string: var decoded = Utils.Ascii85Decode(encoded);
|
Ascii85Encode(data[ArrayBuffer], length (optional)[integer]) [static]DescriptionEncodes an ASCII85 encoded string. This enables binary data to be represented by ASCII characters using five ASCII characters
to represent four bytes of binary data (making the encoded size 1/4 larger than the original). By doing this binary data can be stored in
JavaScript strings. Note that the method used by THIS to encode and decode strings differs from the standard ASCII85 encoding as that uses the
ASCII characters ", ' and \ which cannot be used in JavaScript strings as they have special meanings. The method in THIS uses |
ArrayBuffer containing the data
Length of data in array buffer to encode. If omitted the whole array buffer will be encoded
Returnsstring Return typeString |
ExampleTo encode ArrayBuffer data: var encoded = Utils.Ascii85Encode(data);
|
Build() [static]DescriptionReturns the build number |
No arguments
Returnsinteger Return typeNumber |
ExampleTo get the current build number var build = Utils.Build();
|
CallPromiseHandlers() [static]DescriptionManually call any promise handlers/callbacks in the job queue |
No arguments
Returnsno return value |
ExampleTo run any queued promise handlers/callbacks: Utils.CallPromiseHandlers();
|
CheckinLicense(feature[string]) [static]DescriptionChecks a license for a feature back in |
feature to check license back in for
Returnsno return value |
ExampleTo check in a license for "EXAMPLE": Utils.CheckinLicense("EXAMPLE");
|
CheckoutLicense(feature[string]) [static]DescriptionChecks out a license for a feature |
feature to check license for
Returnstrue if license available, false if not Return typeBoolean |
ExampleTo checkout a license for "EXAMPLE": var got = Utils.CheckoutLicense("EXAMPLE");
if (got == false) Exit();
|
No arguments
Returnsno return value |
ExampleTo force garbage collection to be done: Utils.GarbageCollect();
|
HTMLBrowser() [static]DescriptionReturns the path to the default HTML browser |
No arguments
Returnsstring of the path Return typeString |
ExampleTo get path to the default HTML browser var path = Utils.HTMLBrowser();
|
HiResTimer() [static]DescriptionA high resolution timer that can be used to time how long things take. The first time this is called the timer will start and return 0. Subsequent calls will return the time in nanoseconds since the first call. Note that the timer will almost certainly not have 1 nanosecond precision but, depending on the platform, should should have a resolution of at least 1 microsecond. The resolution can be found by using Utils.TimerResolution() |
No arguments
Returnsnumber Return typenumber |
PdfReader() [static]DescriptionReturns the path to the executable of the default pdf reader |
No arguments
Returnsstring of the path Return typeString |
ExampleTo get path to the default pdf reader var path = Utils.PdfReader();
|
SHA256(filename[string]) [static]DescriptionCreate a SHA-256 hash for a file |
File to calculate the hash for
Returnsstring Return typeString |
ExampleTo generate the hash for file "example.txt": var sha256 = Utils.SHA256("example.txt");
|
SHA512(filename[string]) [static]DescriptionCreate a SHA-512 hash for a file |
File to calculate the hash for
Returnsstring Return typeString |
ExampleTo generate the hash for file "example.txt": var sha512 = Utils.SHA512("example.txt");
|
TimerResolution() [static]DescriptionReturns the resolution (precision) of the Utils.HiResTimer() timer in nanoseconds |
No arguments
Returnsnumber Return typenumber |
ExampleTo find the resolution of the timer in nanoseconds: var resolution = Utils.TimerResolution();
|
UUID() [static]DescriptionCreate an UUID (Universally Unique Identifier) |
No arguments
Returnsstring Return typeString |
ExampleTo generate an UUID: var uuid = Utils.UUID();
|
Version() [static]DescriptionReturns the version number |
No arguments
Returnsreal Return typeNumber |
ExampleTo get the current version number var version = Utils.Version();
|