-
Notifications
You must be signed in to change notification settings - Fork 2
Functions
Jelle De Loecker edited this page May 26, 2014
·
2 revisions
Wiki ▸ API Reference ▸ Core ▸ Functions
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
});
# alchemy.createDir(path [, callback])
Create a directory
Arguments
Name | Type | Description |
---|---|---|
path | String | The path to create |
callback | Function | The optional function to callback |
Example
alchemy.createDir('/tmp/myTempDir', function() {
// Directory /tmp/myTempDir has been created
});