wilton.js  v202103141
 All Namespaces Functions
Functions
misc Namespace Reference

wilton/misc
Miscelanous functions. More...

Functions

Boolean isAndroid (Function|Undefined callback)
 Check whether current Wilton binary was compiled for Android.
Boolean isLinux (Function|Undefined callback)
 Check whether current Wilton binary was compiled for Linux.
Boolean isMac (Function|Undefined callback)
 Check whether current Wilton binary was compiled for macOS.
Boolean isWindows (Function|Undefined callback)
 Check whether current Wilton binary was compiled for Windows.
Array listRegisteredCalls (Function|Undefined callback)
 Return a list of registered Wilton calls.
Undefined runGC (Function|Undefined callback)
 Run a garbage collector.
String stdinReadline (Function|Undefined callback)
 Read a line from the STDIN.
Undefined systemdNotify (String state, Function|Undefined callback)
 Notify systemd service manager.
Undefined waitForSignal (Function|Undefined callback)
 Wait for Ctrl-C.
Object wiltonConfig (Function|Undefined callback)
 Access wilton configuration.
Undefined winscmStartDispatcher (String name, Function|Undefined callback)
 Connect the main thread of a wilton process to SCM.

Detailed Description

This module provides miscelanous functionality that doesn't belong to separate modules.

Function Documentation

Boolean misc::isAndroid ( Function|Undefined  callback)

Checks that compileTimeOS parameter of wiltonConfig is "android".

Parameters
callbackFunction|Undefined callback to receive result or error
Returns
Boolean true if current Wilton binary was compiled for Android, false otherwise
Boolean misc::isLinux ( Function|Undefined  callback)

Checks that compileTimeOS parameter of wiltonConfig is "linux".

Parameters
callbackFunction|Undefined callback to receive result or error
Returns
Boolean true if current Wilton binary was compiled for Linux, false otherwise
Boolean misc::isMac ( Function|Undefined  callback)

Checks that compileTimeOS parameter of wiltonConfig is "macos".

Parameters
callbackFunction|Undefined callback to receive result or error
Returns
Boolean true if current Wilton binary was compiled for macOS, false otherwise
Boolean misc::isWindows ( Function|Undefined  callback)

Checks that compileTimeOS parameter of wiltonConfig is "windows".

Parameters
callbackFunction|Undefined callback to receive result or error
Returns
Boolean true if current Wilton binary was compiled for Windows, false otherwise
Array misc::listRegisteredCalls ( Function|Undefined  callback)

Returns a list of call names, that can be used with wiltoncall function.

Parameters
callbackFunction|Undefined callback to receive result or error
Returns
Array list of registered Wilton calls
Undefined misc::runGC ( Function|Undefined  callback)

Runs a garbage collector for the default JS engine in a current thread. Actual GC run may or may not be async from this call depending on an engine. For JSC engine different versions may behave differently in that regard.

Parameters
callbackFunction|Undefined callback to receive result or error
Returns
Undefined
String misc::stdinReadline ( Function|Undefined  callback)

Reads a line from the STDIN of the current process. Blocks until the line is read.

Parameters
callbackFunction|Undefined callback to receive result or error
Returns
String line passed to STDIN
Undefined misc::systemdNotify ( String  state,
Function|Undefined  callback 
)

Sends message to systemd service manager using sd_notify API, see: https://www.freedesktop.org/software/systemd/man/sd_notify.html

Parameters
stateString message to send to systemd
callbackFunction|Undefined callback to receive result or error
Returns
Undefined
Undefined misc::waitForSignal ( Function|Undefined  callback)

Blocks curren thread untils Ctrl-C will be typed by used in console (or SIGINT or SIGTERM signal will be received by other means).

This function is not intented to be used as a "general-use use signal handler".

It can be called only once is a single process, and is typically called from the main thread of the console application after the initialization of background services.

Parameters
callbackFunction|Undefined callback to receive result or error
Returns
Undefined
Object misc::wiltonConfig ( Function|Undefined  callback)

Returns configuration object that was used for wilton initialization.

Parameters
callbackFunction|Undefined callback to receive result or error
Returns
Object configuration object with the following fields:
  • defaultScriptEngine String name of the script engine that is used by default
  • wiltonHome String path to the Wilton directory
  • environmentVariables Object system environment variables collected during the startup
  • requireJs Object RequireJS configuration
Undefined misc::winscmStartDispatcher ( String  name,
Function|Undefined  callback 
)

Connects the main thread of a wilton process to the Windos Service Control Manager. Call return after the SCM service is stopped.

Parameters
nameString name of the SCM service
callbackFunction|Undefined callback to receive result or error
Returns
Undefined