Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/eldoy/waveorb-util

Utility functions for Waveorb
https://github.com/eldoy/waveorb-util

Last synced: 6 days ago
JSON representation

Utility functions for Waveorb

Awesome Lists containing this project

README

        

# Waveorb Util

Utility functions for [Waveorb.](https://waveorb.com)

Various Javascript functions needed for web applications. It is included in new Waveorb applications by default.

### Install

```
npm i waveorb-util
```

### Usage

#### Frontend

Copy the `dist/util.js` file to the `app/assets/js/` folder in you application.

```js
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:

```js
async function()

...

${global.globals.map(function(fn) {
return h`window.${fn} = ${util[fn]}`
})}

```

#### Backend

Install:
```
npm i waveorb-util
```

Usage:
```js
var { sleep } = require('waveorb-util')
```

To install functions globally server side, use the `init` hook:

```js
var util = require('waveorb-util')
global.sleep = util.sleep
```

See the source code for documentation.

### License

ISC Licensed. Enjoy!