You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f92e14a
Browse filesBrowse the repository at this point in the historyBrowse files
docs: update the bundle sizes after the tree-shaking work
The bundle size table of the getting started page (English and Portuguese) is refreshed from
`node scripts/tree-shaking.ts --json`: a root import of isValidCpf is now about 0.5 KB minified
(0.3 KB gzipped) instead of 1.4 KB (0.8 KB), in the README too. The lookup validators no longer
share a row with their getters, since they now bundle the codes alone: isValidCbo, isValidCnae,
isValidNbs, isValidCest and isValidCid10 get rows of their own, and isValidCfop (2.8 KB) and
isValidServiceItem (1.2 KB) leave the table of heavy utils. The getCities, isValidCid10 and
getCid10 notes of the utilities page get their new sizes as well.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLkm9YrtAifc6XCLFVEsdH
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ Brazilian Utils is a zero-dependency library of small utilities for the day-to-d
34
34
## Why Brazilian Utils
35
35
36
36
-**Zero runtime dependencies.** Nothing else lands in your `node_modules` or in your bundle.
37
-
-**Tree-shakeable, down to the function.**`import { isValidCpf }` costs about 1.4 KB minified (0.8 KB gzipped). Every util is also its own subpath entry, so the heavy ones can be lazy-loaded.
37
+
-**Tree-shakeable, down to the function.**`import { isValidCpf }` costs about 0.5 KB minified (0.3 KB gzipped). Every util is also its own subpath entry, so the heavy ones can be lazy-loaded.
38
38
-**Runs everywhere.** Node.js `^20.19.0 || >=22.12.0`, Bun, Deno and evergreen browsers, all tested in CI.
39
39
-**Written in TypeScript.** Types ship with the package, and every pull request is checked against the last release so the public API never changes silently.
40
40
-**Validated against the official rules.** Every validator cites the specification, law or dataset it implements, and the test suite is mutation-tested, not just covered.
Copy file name to clipboardExpand all lines: docs/getting-started.md
+19-2Lines changed: 19 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Brazilian Utils is a zero-dependency library of small utilities for the day-to-d
9
9
## Why Brazilian Utils
10
10
11
11
-**Zero runtime dependencies.** Nothing else lands in your `node_modules` or in your bundle.
12
-
-**Tree-shakeable, down to the function.**`import { isValidCpf }` costs about 1.4 KB minified (0.8 KB gzipped). Every util is also its own subpath entry, so the heavy ones can be lazy-loaded.
12
+
-**Tree-shakeable, down to the function.**`import { isValidCpf }` costs about 0.5 KB minified (0.3 KB gzipped). Every util is also its own subpath entry, so the heavy ones can be lazy-loaded.
13
13
-**Runs everywhere.** Node.js `^20.19.0 || >=22.12.0`, Bun, Deno and evergreen browsers, all tested in CI.
14
14
-**Written in TypeScript.** Types ship with the package, and every pull request is checked against the last release so the public API never changes silently.
15
15
-**Validated against the official rules.** Every validator cites the specification, law or dataset it implements, and the test suite is mutation-tested, not just covered.
@@ -62,12 +62,29 @@ Without Context7, point the assistant at [llms.txt](https://brazilian-utils.com.
62
62
63
63
## Bundle size
64
64
65
-
The package is tree-shakeable: importing one util from the root pulls in only that util's code. `isValidCpf`, for example, adds about 1.4 KB minified (0.8 KB gzipped) to your bundle.
65
+
The package is tree-shakeable: importing one util from the root pulls in only that util's code. `isValidCpf`, for example, adds about 0.5 KB minified (0.3 KB gzipped) to your bundle.
66
66
67
67
A few utils embed an official dataset and weigh far more than everything else combined:
68
68
69
69
| Util | Dataset | Minified | Gzipped |
70
70
| --- | --- | --- | --- |
71
+
|`getCid10`| CID-10 V2008 categories and subcategories, with the DATASUS descriptions | 988.2 KB | 123.5 KB |
Copy file name to clipboardExpand all lines: docs/pt-br/getting-started.md
+19-2Lines changed: 19 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Brazilian Utils é uma biblioteca de utilitários, sem dependências, para os pr
9
9
## Por que Brazilian Utils
10
10
11
11
-**Zero dependências de runtime.** Nada além da biblioteca entra no seu `node_modules` ou no seu bundle.
12
-
-**Tree-shakeable até a função.**`import { isValidCpf }` custa cerca de 1,4 KB minificado (0,8 KB com gzip). Cada utilitário também é um subpath próprio, então os pesados podem ser carregados sob demanda.
12
+
-**Tree-shakeable até a função.**`import { isValidCpf }` custa cerca de 0,5 KB minificado (0,3 KB com gzip). Cada utilitário também é um subpath próprio, então os pesados podem ser carregados sob demanda.
13
13
-**Roda em qualquer lugar.** Node.js `^20.19.0 || >=22.12.0`, Bun, Deno e navegadores modernos, todos testados no CI.
14
14
-**Escrita em TypeScript.** Os tipos vêm no pacote, e todo pull request é comparado com a última versão publicada para que a API pública nunca mude em silêncio.
15
15
-**Validada contra as regras oficiais.** Cada validador cita a especificação, lei ou base de dados que implementa, e a suíte de testes passa por mutation testing, não só por cobertura.
@@ -62,12 +62,29 @@ Sem o Context7, aponte o assistente para o [llms.txt](https://brazilian-utils.co
62
62
63
63
## Tamanho do bundle
64
64
65
-
O pacote é tree-shakeable: importar um utilitário da raiz traz apenas o código daquele utilitário. `isValidCpf`, por exemplo, adiciona cerca de 1,4 KB minificado (0,8 KB com gzip) ao seu bundle.
65
+
O pacote é tree-shakeable: importar um utilitário da raiz traz apenas o código daquele utilitário. `isValidCpf`, por exemplo, adiciona cerca de 0,5 KB minificado (0,3 KB com gzip) ao seu bundle.
66
66
67
67
Alguns utilitários embutem uma base de dados oficial e pesam muito mais que todos os outros somados:
68
68
69
69
| Utilitário | Base de dados | Minificado | Gzip |
70
70
| --- | --- | --- | --- |
71
+
|`getCid10`| categorias e subcategorias da CID-10 V2008, com as descrições do DATASUS | 988,2 KB | 123,5 KB |
72
+
|`getMunicipalities` · `getMunicipalityByCode` · `getMunicipality`| 5571 municípios do IBGE, com nomes e códigos | 153,6 - 154,0 KB | 49,4 - 49,7 KB |
73
+
|`getCities`| nomes dos 5571 municípios do IBGE | 153,4 KB | 49,2 KB |
74
+
|`getCbo`| títulos das ocupações da CBO 2002 | 115,7 KB | 29,5 KB |
75
+
|`getCest`| descrições e segmentos do CEST (Convênio ICMS 142/18) | 115,6 KB | 26,1 KB |
Copy file name to clipboardExpand all lines: docs/pt-br/utilities.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1817,7 +1817,7 @@ Retorna os nomes das cidades brasileiras: todas as cidades, ou só as de um esta
1817
1817
- Ordenadas no locale "pt-BR".
1818
1818
- Qualquer `state` falsy pede a lista completa, enquanto `getMunicipalities` retorna `[]`.
1819
1819
- `state` diferencia maiúsculas de minúsculas: `'sp'`, como um código desconhecido, retorna `[]`.
1820
-
- Embute os 5571 nomes (~154,2 KB minificado, ~49,8 KB com gzip). Veja [Tamanho do bundle](pt-br/getting-started.md#tamanho-do-bundle) para carregá-la sob demanda via `@brazilian-utils/brazilian-utils/get-cities`.
1820
+
- Embute os 5571 nomes (~153,4 KB minificado, ~49,2 KB com gzip). Veja [Tamanho do bundle](pt-br/getting-started.md#tamanho-do-bundle) para carregá-la sob demanda via `@brazilian-utils/brazilian-utils/get-cities`.
@@ -3301,7 +3301,7 @@ Valida um código CID-10 contra as tabelas que o DATASUS publica, a edição bra
3301
3301
- Os dois níveis da classificação são válidos: as categorias de 3 caracteres (`A00`) e as subcategorias de 4 caracteres, escritas com o ponto (`A00.0`) ou sem ele (`A000`).
3302
3302
- Maiúsculas, minúsculas e espaços em volta são ignorados. Qualquer outra coisa (outro separador, um quinto caractere, um sufixo de cruz ou asterisco, um valor que não é string) é rejeitada.
3303
3303
- As tabelas V2008 do DATASUS são a única fonte, então um código que não está nelas não é encontrado; os códigos de COVID-19 que a OMS acrescentou depois de 2008 não são encontrados: `U07.1` (COVID-19, vírus identificado), `U07.2` (vírus não identificado), `U09.9` (condição pós-COVID-19) e `U10.9` (síndrome inflamatória multissistêmica associada à COVID-19).
3304
-
- Só uma tabela de códigos é lida (cerca de 27 KB minificada), não as descrições que `getCid10` carrega.
3304
+
- Só uma tabela de códigos é lida (cerca de 26 KB minificada), não as descrições que `getCid10` carrega.
@@ -3351,7 +3351,7 @@ Busca um código CID-10 e retorna a sua descrição oficial em português. O res
3351
3351
3352
3352
- Mesmas regras de entrada de `isValidCid10`. O `code` vem em maiúsculas e sem o ponto. Retorna `null` quando o código é desconhecido ou o valor não está em uma forma documentada.
3353
3353
- Mesma tabela de `isValidCid10`, a V2008 do DATASUS: os códigos de COVID-19 que a OMS acrescentou depois de 2008 não são encontrados: `U07.1` (COVID-19, vírus identificado), `U07.2` (vírus não identificado), `U09.9` (condição pós-COVID-19) e `U10.9` (síndrome inflamatória multissistêmica associada à COVID-19).
3354
-
- Este é o utilitário mais pesado do pacote: ele embute as 2045 categorias e 12188 subcategorias com suas descrições, cerca de 1 MB minificado (147 KB com gzip). Carregue-o sob demanda pelo seu subpath, como mostrado em [Tamanho do bundle](pt-br/getting-started.md#tamanho-do-bundle), e use `isValidCid10` quando a descrição não for necessária.
3354
+
- Este é o utilitário mais pesado do pacote: ele embute as 2045 categorias e 12188 subcategorias com suas descrições, cerca de 990 KB minificado (124 KB com gzip). Carregue-o sob demanda pelo seu subpath, como mostrado em [Tamanho do bundle](pt-br/getting-started.md#tamanho-do-bundle), e use `isValidCid10` quando a descrição não for necessária.
Copy file name to clipboardExpand all lines: docs/utilities.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1817,7 +1817,7 @@ Get the names of Brazilian cities: every city, or only those of one state. **Dep
1817
1817
- Sorted in the "pt-BR" locale.
1818
1818
- Any falsy `state` asks for the full list, where `getMunicipalities` returns `[]`.
1819
1819
- `state` is case-sensitive: `'sp'`, like an unknown code, returns `[]`.
1820
-
- Embeds all 5571 names (~154.2 KB minified, ~49.8 KB gzipped). See [Bundle size](getting-started.md#bundle-size) to lazy-load it via `@brazilian-utils/brazilian-utils/get-cities`.
1820
+
- Embeds all 5571 names (~153.4 KB minified, ~49.2 KB gzipped). See [Bundle size](getting-started.md#bundle-size) to lazy-load it via `@brazilian-utils/brazilian-utils/get-cities`.
@@ -3301,7 +3301,7 @@ Check if a CID-10 code exists in the tables DATASUS publishes, the Brazilian Por
3301
3301
- Both levels of the classification are valid: the 3 character categories (`A00`) and the 4 character subcategories, written with the dot (`A00.0`) or without it (`A000`).
3302
3302
- Letter case and surrounding whitespace are ignored. Anything else (another separator, a fifth character, a dagger or asterisk suffix, a value that is not a string) is rejected.
3303
3303
- The DATASUS V2008 tables are the only source, so a code that is not in them is not found; the COVID-19 codes the WHO added after 2008 are not found: `U07.1` (COVID-19, virus identified), `U07.2` (virus not identified), `U09.9` (post COVID-19 condition) and `U10.9` (multisystem inflammatory syndrome associated with COVID-19).
3304
-
- Only a table of codes is read (about 27 KB minified), not the descriptions `getCid10` carries.
3304
+
- Only a table of codes is read (about 26 KB minified), not the descriptions `getCid10` carries.
@@ -3351,7 +3351,7 @@ Look a CID-10 code up and get its official Brazilian Portuguese description. The
3351
3351
3352
3352
- Same input rules as `isValidCid10`. `code` is upper case and has no dot. Returns `null` when the code is unknown or the value is not in a documented form.
3353
3353
- Same table as `isValidCid10`, the DATASUS V2008 one: the COVID-19 codes the WHO added after 2008 are not found: `U07.1` (COVID-19, virus identified), `U07.2` (virus not identified), `U09.9` (post COVID-19 condition) and `U10.9` (multisystem inflammatory syndrome associated with COVID-19).
3354
-
- This is the heaviest util of the package: it embeds the 2045 categories and 12188 subcategories with their descriptions, about 1 MB minified (147 KB gzipped). Load it lazily through its subpath, as shown in [Bundle size](getting-started.md#bundle-size), and use `isValidCid10` when the description is not needed.
3354
+
- This is the heaviest util of the package: it embeds the 2045 categories and 12188 subcategories with their descriptions, about 990 KB minified (124 KB gzipped). Load it lazily through its subpath, as shown in [Bundle size](getting-started.md#bundle-size), and use `isValidCid10` when the description is not needed.
0 commit comments