Skip to content
Jelle De Loecker edited this page May 26, 2014 · 2 revisions

WikiAPI ReferenceCoreFunctions

These functions are stored in the global alchemy object.

--

# alchemy.lowPriority(fnc [, wait])

Schedule a function in a low priority queue. This function will be executed only if the process isn't too busy.

Arguments

Name Type Description
fnc Function The function to execute
wait Number Minimum time (in ms) to wait before executing

# alchemy.fillPlaceholders(text , obj [, delimiter])

Replace placeholders in the text with values inside the object.
You can specify the delimiter, which is '%' by default.

Arguments

Name Type Description
text String The original text containing the placeholders
obj Object The object containing the placeholder values
delimiter String The delimiter the placeholder is between

Returns (String): The text with the found placeholders replaced

Example

alchemy.fillPlaceholders('This is a %bla%', {bla: 'test'});
// "This is a test"

# alchemy.ready(fnc)

Execute the function when alchemy is ready,
after these three stages have finished:

  • startServer
  • datasources
  • listening

Arguments

Name Type Description
fnc Function The function to execute

Example

alchemy.ready(function() {
    // This will run after the DB connection is made
    // and the http server is listening
});
Clone this wiki locally