Utility functions for Waveorb.
Various Javascript functions needed for web applications. It is included in new Waveorb applications by default.
npm i waveorb-util
Copy the dist/util.js
file to the app/assets/js/
folder in you application.
var util = require('waveorb-util')
// Include some
global.globals = ['sleep', 'clearErrors']
for (var fn of globals) {
global[fn] = util[fn]
}
// Include all
global.globals = Object.keys(util)
for (var fn in util) {
global[fn] = util[fn]
}
To make the available client side, include them in your layout, in the head
or at the end of body
tag, depending on your needs:
async function()
<head>
...
<script>
${global.globals.map(function(fn) {
return h`window.${fn} = ${util[fn]}`
})}
</script>
</head>
Install:
npm i waveorb-util
Usage:
var { sleep } = require('waveorb-util')
To install functions globally server side, use the init
hook:
var util = require('waveorb-util')
global.sleep = util.sleep
See the source code for documentation.
ISC Licensed. Enjoy!