@wazapp/utils
Utils are a bunch of functionalities that can make your life easier. They are used internally by Wazapp packages, but you are encourage to use them as well.

API

guidFor

Returns a unique id for the object. If the object does not yet have a guid, one will be assigned to it. You can call this on any object, string, number, whatever...
You can also use this method on DOM Element objects.

API

Properties:
  • value: any - value for which the guid will be generated
  • suffix: string - optional suffix

Example

1
import Component from "@wazapp/component";
2
import { guidFor } from '@wazapp/utils'
3
​
4
export default class FormComponent extends Component {
5
template({ name }) {
6
return (
7
<form>
8
<label htmlFor={guidFor(this, 'title')}>Title</label>
9
<input id={guidFor(this, 'title')} name="title" />
10
</form>
11
);
12
}
13
}
14
​
15
// Renders:
16
// <form>
17
// <label for="w:1-w2">Title</label>
18
// <input id="w:1-w2" name="title" />
19
// </form>
Copied!

uuid

Example

1
import { uuid } from '@wazapp/utils'
2
​
3
const newItemId = uuid();
Copied!
Last modified 1yr ago
Copy link