# Pequenos helpers: GUID, HASH, parseConfig, format e group

> Use as funções auxiliares que o jComponent acrescenta: ids aleatórios, hashes, strings de configuração, formatação de texto e datas e agrupamento.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: pt
Content-SHA256: b8ac3d92255c7ff050aaa6dfe3021e8e21bf5052eb3038752a12f1aa48dea5f7
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: jcomponent20@3fedd009a277f50fddc608b97afbec553b67c51b
Review: not-recorded

O jComponent acrescenta alguns helpers que o poupam a carregar uma biblioteca de utilitários:

- `GUID(length)` devolve um id aleatório; `HASH(value)` devolve um hash numérico de qualquer valor
- `'key:value;key2:value2'.parseConfig()` interpreta uma string de configuração num objeto, convertendo números e booleanos
- `'{0} is {1}'.format('a', 'b')` substitui marcadores `{index}`
- `number.format(decimals, thousandsSeparator, decimalSeparator)` e `date.format('yyyy-MM-dd')` formatam números e datas
- `array.group('field')` agrupa objetos por um campo em `[{ name, items }]`
- `PARSE(json)` interpreta JSON e converte strings de data em objetos `Date`; `date.add('1 day')` desloca uma data

```html public/index.html
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>jComponent</title>
	<link rel="stylesheet" href="//cdn.componentator.com/spa.min@20.css" />
	<script src="//cdn.componentator.com/spa.min@20.js"></script>
</head>
<body>
	<p class="out"></p>

	<script>

		window.sample = {
			guid: GUID(12),
			samehash: HASH('total') === HASH('total'),
			config: 'size:3;active:true;name:Peter'.parseConfig(),
			text: '{0} is {1}'.format('Total.js', 'great'),
			price: (1234.5).format(2),
			date: new Date(2026, 9, 16).format('yyyy-MM-dd'),
			groups: [{ type: 'a', n: 1 }, { type: 'b', n: 2 }, { type: 'a', n: 3 }].group('type'),
			parsed: PARSE('{"created":"2026-10-16T10:00:00.000Z"}').created instanceof Date,
			tomorrow: new Date(2026, 9, 16).add('1 day').getDate()
		};

	</script>

</body>
</html>
```
